Skip to content

Commit

Permalink
Respect the maximum number of tokens in interactive. (#298)
Browse files Browse the repository at this point in the history
Co-authored-by: Johnman <johnman@github>
Co-authored-by: Georgi Gerganov <[email protected]>
  • Loading branch information
3 people authored Mar 19, 2023
1 parent 50fae10 commit 368d0c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,6 @@ int main(int argc, char ** argv) {
}

// end of text token

if (embd.back() == EOS_TOKEN_ID) {
if (params.interactive) {
is_interacting = true;
Expand All @@ -1071,6 +1070,12 @@ int main(int argc, char ** argv) {
break;
}
}

// In interactive mode, respect the maximum number of tokens and drop back to user input when reached.
if (params.interactive && remaining_tokens <= 0) {
remaining_tokens = params.n_predict;
is_interacting = true;
}
}

#if defined (_WIN32)
Expand Down

0 comments on commit 368d0c8

Please sign in to comment.