Skip to content

Commit 619c1a2

Browse files
l3utterflynopperl
authored andcommitted
main : fix off by one error for context shift (ggml-org#6921)
1 parent 1d51ce4 commit 619c1a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ int main(int argc, char ** argv) {
544544
// if we run out of context:
545545
// - take the n_keep first tokens from the original prompt (via n_past)
546546
// - take half of the last (n_ctx - n_keep) tokens and recompute the logits in batches
547-
if (n_past + (int) embd.size() + std::max<int>(0, guidance_offset) > n_ctx) {
547+
if (n_past + (int) embd.size() + std::max<int>(0, guidance_offset) >= n_ctx) {
548548
if (params.n_predict == -2) {
549549
LOG_TEE("\n\n%s: context full and n_predict == -%d => stopping\n", __func__, params.n_predict);
550550
break;

0 commit comments

Comments
 (0)