Merge pull request #2 from slaren/interactive-eos-fix
Inject the reverse prompt again after eos in interactive mode
This commit is contained in:
commit
1f4abb8dae
1 changed files with 7 additions and 12 deletions
19
main.cpp
19
main.cpp
|
@ -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,17 +1095,8 @@ 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) {
|
fprintf(stderr, " [end of text]\n");
|
||||||
// is_interacting = true;
|
break;
|
||||||
// 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.
|
// In interactive mode, respect the maximum number of tokens and drop back to user input when reached.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue