]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
main : fix off by one error for context shift (#6921)
authorl3utterfly <redacted>
Wed, 1 May 2024 19:27:41 +0000 (04:27 +0900)
committerGitHub <redacted>
Wed, 1 May 2024 19:27:41 +0000 (22:27 +0300)
examples/main/main.cpp

index 5c693657c8993413fdd27829e8f0304d6446c6ca..eabbc2db382861c78c415a961f438f91c21a8b67 100644 (file)
@@ -544,7 +544,7 @@ int main(int argc, char ** argv) {
                 // if we run out of context:
                 // - 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) {
+                if (n_past + (int) embd.size() + std::max<int>(0, guidance_offset) >= n_ctx) {
                     if (params.n_predict == -2) {
                         LOG_TEE("\n\n%s: context full and n_predict == -%d => stopping\n", __func__, params.n_predict);
                         break;