From e1ec489ef2f1e90650f0ffeb4c2ac234df541d09 Mon Sep 17 00:00:00 2001 From: KerfuffleV2 Date: Tue, 23 May 2023 07:05:44 -0600 Subject: [PATCH] Use existing session behavior when in instruct or interact first mode --- examples/main/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index c05a49dd3..868dc03a2 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -166,7 +166,7 @@ int main(int argc, char ** argv) { // tokenize the prompt std::vector embd_inp; - if (!params.prompt.empty() || session_tokens.empty()) { + if (params.interactive_first || params.instruct || !params.prompt.empty() || session_tokens.empty()) { // Add a space in front of the first character to match OG llama tokenizer behavior params.prompt.insert(0, 1, ' '); @@ -191,7 +191,9 @@ int main(int argc, char ** argv) { } n_matching_session_tokens++; } - if (n_matching_session_tokens >= embd_inp.size()) { + if (params.prompt.empty() && n_matching_session_tokens == embd_inp.size()) { + fprintf(stderr, "%s: using full prompt from session file\n", __func__); + } else if (n_matching_session_tokens >= embd_inp.size()) { fprintf(stderr, "%s: session file has exact match for prompt!\n", __func__); } else if (n_matching_session_tokens < (embd_inp.size() / 2)) { fprintf(stderr, "%s: warning: session file has low similarity to prompt (%zu / %zu tokens); will mostly be reevaluated\n",