diff options
author | Christian Demsar <crasm@git.vczf.us> | 2023-08-10 10:28:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 16:28:27 +0200 |
commit | e59fcb2bc129881f4a269fee748fb38bce0a64de (patch) | |
tree | f96cb28cdf28e315cd4bea28dbc10b77afbc7fde /examples/main/main.cpp | |
parent | 1638757767072a4957f52b9e3594f0b67610631b (diff) |
Add --n-predict -2 for stopping generation on full context (#2565)
Diffstat (limited to 'examples/main/main.cpp')
-rw-r--r-- | examples/main/main.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 56ada7e6..a632bea1 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -431,8 +431,12 @@ int main(int argc, char ** argv) { // - take the n_keep first tokens from the original prompt (via n_past) // - take half of the last (n_ctx - n_keep) tokens and recompute the logits in batches if (n_past + (int) embd.size() + std::max<int>(0, guidance_offset) > n_ctx) { - const int n_left = n_past - params.n_keep; + if (params.n_predict == -2) { + fprintf(stderr, "\n\n%s: context full, stopping generation\n", __func__); + break; + } + const int n_left = n_past - params.n_keep; // always keep the first token - BOS n_past = std::max(1, params.n_keep); n_past_guidance = std::max(1, params.n_keep + guidance_offset); |