From 8af1991e2a0b371391cc3dc7da9b1a48bd8d847e Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 21 Aug 2023 15:40:51 +0300 Subject: [PATCH] main : restore old EOS behavior in interactive mode --- examples/main/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index a632bea1c..26ec48ed5 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -634,6 +634,11 @@ int main(int argc, char ** argv) { llama_grammar_accept_token(ctx, grammar, id); } + // replace end of text token with newline token when in interactive mode + if (id == llama_token_eos() && params.interactive && !params.instruct && !params.input_prefix_bos) { + id = llama_token_nl(); + } + last_n_tokens.erase(last_n_tokens.begin()); last_n_tokens.push_back(id); }