Inject the reverse prompt again after eos in interactive mode

This commit is contained in:
Slaren 2023-03-21 04:56:47 +01:00
parent 2479c78bc6
commit 8009a8ddb0

View file

@ -1004,7 +1004,11 @@ int main(int argc, char ** argv) {
// replace end of text token with newline token when in interactive mode // replace end of text token with newline token when in interactive mode
if (id == EOS_TOKEN_ID && params.interactive) { if (id == EOS_TOKEN_ID && params.interactive) {
id = NEWLINE_TOKEN_ID; 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 // add it to the context
@ -1091,18 +1095,9 @@ int main(int argc, char ** argv) {
// end of text token // end of text token
if (embd.back() == EOS_TOKEN_ID) { 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"); fprintf(stderr, " [end of text]\n");
break; break;
} }
}
// In interactive mode, respect the maximum number of tokens and drop back to user input when reached. // In interactive mode, respect the maximum number of tokens and drop back to user input when reached.
if (params.interactive && remaining_tokens <= 0) { if (params.interactive && remaining_tokens <= 0) {