tokenize and inject only first reverse prompt

thanks to tjohnman
This commit is contained in:
rabidcopy 2023-03-21 13:37:36 -05:00 committed by GitHub
parent 3c211c64bd
commit e33df8e1a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1005,14 +1005,9 @@ int main(int argc, char ** argv) {
if (id == EOS_TOKEN_ID && params.interactive) { if (id == EOS_TOKEN_ID && params.interactive) {
id = NEWLINE_TOKEN_ID; id = NEWLINE_TOKEN_ID;
if (params.antiprompt.size() != 0) { if (params.antiprompt.size() != 0) {
// tokenize the reverse prompt to inject // tokenize the first reverse prompt and inject on the newline
std::vector<std::vector<llama_vocab::id>> antipromptv_inp; std::vector<llama_vocab::id> first_antiprompt = ::llama_tokenize(vocab, params.antiprompt.front(), false);
for (auto antiprompt : params.antiprompt){ embd_inp.insert(embd_inp.end(), first_antiprompt.begin(), first_antiprompt.end());
antipromptv_inp.push_back(::llama_tokenize(vocab, antiprompt, false));
}
// inject the reverse prompt to return control to the user
auto& ap_inp = antipromptv_inp.front();
embd_inp.insert(embd_inp.end(), ap_inp.begin(), ap_inp.end());
} }
} }