summaryrefslogtreecommitdiffstats
path: root/llm.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-08-21 19:23:10 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-08-21 19:23:10 +0800
commit3fba5649b1f8bd86c689ff8b4c6330c776220284 (patch)
tree94bd26c67a96d6c1bde1049a3b9a7132a3826c82 /llm.c
parente2907df7bfc85869d814acfd213254fd0e95a9bc (diff)
downloadlex-3fba5649b1f8bd86c689ff8b4c6330c776220284.tar.gz
Bug fix: repeated prompt must not be ignored.
Diffstat (limited to 'llm.c')
-rw-r--r--llm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/llm.c b/llm.c
index e979929..784df27 100644
--- a/llm.c
+++ b/llm.c
@@ -257,6 +257,14 @@ void llm_run(struct llm_ctx *llm, const char *user_prompt, FILE *out)
syslog(LOG_WARNING, "cached prefix is shorter than the system prompt");
}
+ /* Force at least one real decode every request. If n_common hit
+ * n_new_tokens, decode gets skipped entirely, so ctx keeps the
+ * stale logits from the previous request's EOG -- sampling them
+ * again just reproduces EOG immediately (empty response on an
+ * exact repeat). */
+ if (n_common == n_new_tokens)
+ n_common--;
+
/* Drop everything in the cache past the common prefix. */
llama_memory_seq_rm(llama_get_memory(llm->ctx),
0, /* sequence id: 0 - we only use one sequence */