From b64067704e18d00782923b2643f0280694e48298 Mon Sep 17 00:00:00 2001 From: rabidcopy Date: Thu, 23 Mar 2023 17:56:16 -0500 Subject: [PATCH] fix instruct mode changes to EOS behavior in interactive and reverse prompt handling broke instruct mode by erroneously injecting instruct mode's reverse prompt and an extra newline. --- main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 5ba6d5a75..b4d068d73 100644 --- a/main.cpp +++ b/main.cpp @@ -363,7 +363,7 @@ int main(int argc, char ** argv) { } // replace end of text token with newline token when in interactive mode - if (id == llama_token_eos() && params.interactive) { + if (id == llama_token_eos() && params.interactive && !params.instruct) { id = llama_token_newline.front(); if (params.antiprompt.size() != 0) { // tokenize and inject first reverse prompt @@ -464,8 +464,12 @@ int main(int argc, char ** argv) { // end of text token if (embd.back() == llama_token_eos()) { - fprintf(stderr, " [end of text]\n"); - break; + if (params.instruct) { + is_interacting = true; + } else { + fprintf(stderr, " [end of text]\n"); + break; + } } // In interactive mode, respect the maximum number of tokens and drop back to user input when reached.