Merge pull request #2 from slaren/interactive-eos-fix

Inject the reverse prompt again after eos in interactive mode
This commit is contained in:
rabidcopy 2023-03-21 11:34:30 -05:00 committed by GitHub
commit 1f4abb8dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1004,7 +1004,11 @@ int main(int argc, char ** argv) {
// replace end of text token with newline token when in interactive mode
if (id == EOS_TOKEN_ID && params.interactive) {
id = NEWLINE_TOKEN_ID;
is_interacting = true;
if (!antipromptv_inp.empty()) {
// 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());
}
}
// add it to the context
@ -1091,18 +1095,9 @@ int main(int argc, char ** argv) {
// end of text token
if (embd.back() == EOS_TOKEN_ID) {
if (params.interactive) {
// is_interacting = true;
// embd.back() = NEWLINE_TOKEN_ID;
// last_n_tokens.back() = NEWLINE_TOKEN_ID;
// if (params.antiprompt.size() != 0) {
// fprintf(stderr, "\n");
// }
} 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.
if (params.interactive && remaining_tokens <= 0) {