Skip to content

Commit 863f65e

Browse files
authored
fix instruct mode (#445)
changes to EOS behavior in interactive and reverse prompt handling broke instruct mode by erroneously injecting instruct mode's reverse prompt and an extra newline.
1 parent afd220d commit 863f65e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ int main(int argc, char ** argv) {
387387
}
388388

389389
// replace end of text token with newline token when in interactive mode
390-
if (id == llama_token_eos() && params.interactive) {
390+
if (id == llama_token_eos() && params.interactive && !params.instruct) {
391391
id = llama_token_newline.front();
392392
if (params.antiprompt.size() != 0) {
393393
// tokenize and inject first reverse prompt
@@ -488,8 +488,12 @@ int main(int argc, char ** argv) {
488488

489489
// end of text token
490490
if (embd.back() == llama_token_eos()) {
491-
fprintf(stderr, " [end of text]\n");
492-
break;
491+
if (params.instruct) {
492+
is_interacting = true;
493+
} else {
494+
fprintf(stderr, " [end of text]\n");
495+
break;
496+
}
493497
}
494498

495499
// In interactive mode, respect the maximum number of tokens and drop back to user input when reached.

0 commit comments

Comments
 (0)