From 52f46ef78afd65e13179436fce7930e1dfdfc8de Mon Sep 17 00:00:00 2001 From: rabidcopy Date: Tue, 21 Mar 2023 14:10:20 -0500 Subject: [PATCH] tokenize first reverse prompt once --- main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 915558e2b..c38032481 100644 --- a/main.cpp +++ b/main.cpp @@ -885,6 +885,9 @@ int main(int argc, char ** argv) { antipromptv_inp.push_back(::llama_tokenize(vocab, antiprompt, false)); } + // tokenize the first reverse prompt + std::vector first_antiprompt = ::llama_tokenize(vocab, params.antiprompt.front(), false); + // enable interactive mode if reverse prompt is specified if (antipromptv_inp.size() != 0) { params.interactive = true; @@ -1005,8 +1008,7 @@ int main(int argc, char ** argv) { if (id == EOS_TOKEN_ID && params.interactive) { id = NEWLINE_TOKEN_ID; if (params.antiprompt.size() != 0) { - // tokenize the first reverse prompt and inject on the newline - std::vector first_antiprompt = ::llama_tokenize(vocab, params.antiprompt.front(), false); + // inject first reverse prompt embd_inp.insert(embd_inp.end(), first_antiprompt.begin(), first_antiprompt.end()); } }