From 795a6449621cd5c47b6db7d0b0c2f2cafe943f56 Mon Sep 17 00:00:00 2001 From: Ivan Stepanov Date: Thu, 4 May 2023 14:57:55 +0300 Subject: [PATCH] Avoid hardcoding a space at the beginning of the prompt. --- examples/main/main.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 125c189a3..49ebffc57 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -137,9 +137,6 @@ int main(int argc, char ** argv) { return 0; } - // Add a space in front of the first character to match OG llama tokenizer behavior - params.prompt.insert(0, 1, ' '); - std::string path_session = params.path_session; std::vector session_tokens; @@ -215,9 +212,6 @@ int main(int argc, char ** argv) { params.interactive = true; } - // determine newline token - auto llama_token_newline = ::llama_tokenize(ctx, "\n", false); - if (params.verbose_prompt) { fprintf(stderr, "\n"); fprintf(stderr, "%s: prompt: '%s'\n", __func__, params.prompt.c_str()); @@ -456,7 +450,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 && !params.instruct) { - id = llama_token_newline.front(); + id = llama_token_nl(); if (params.antiprompt.size() != 0) { // tokenize and inject first reverse prompt const auto first_antiprompt = ::llama_tokenize(ctx, params.antiprompt.front(), false);