Skip to content

Commit 368d0c8

Browse files
tjohnmanJohnmanggerganov
authored
Respect the maximum number of tokens in interactive. (#298)
Co-authored-by: Johnman <johnman@github> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
1 parent 50fae10 commit 368d0c8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,6 @@ int main(int argc, char ** argv) {
10621062
}
10631063

10641064
// end of text token
1065-
10661065
if (embd.back() == EOS_TOKEN_ID) {
10671066
if (params.interactive) {
10681067
is_interacting = true;
@@ -1071,6 +1070,12 @@ int main(int argc, char ** argv) {
10711070
break;
10721071
}
10731072
}
1073+
1074+
// In interactive mode, respect the maximum number of tokens and drop back to user input when reached.
1075+
if (params.interactive && remaining_tokens <= 0) {
1076+
remaining_tokens = params.n_predict;
1077+
is_interacting = true;
1078+
}
10741079
}
10751080

10761081
#if defined (_WIN32)

0 commit comments

Comments
 (0)