aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortjohnman <tjohnman@users.noreply.github.com>2023-03-19 19:31:17 +0100
committerGitHub <noreply@github.com>2023-03-19 20:31:17 +0200
commit368d0c8a9ebae16a20e1c8971b21ee888bdefad5 (patch)
treeb74069dd4fe7bfe28a254a037ebf0c5cdeeea52f
parent50fae10d0339f2bd639f69dd679c0201d939a265 (diff)
Respect the maximum number of tokens in interactive. (#298)
Co-authored-by: Johnman <johnman@github> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
-rw-r--r--main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index e181056..57e9249 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;
@@ -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)