Skip to content

Model forgets earlier messages or long documents

Symptom

Long prompts are partly ignored; the model acts as if the beginning of the chat never happened.

Likely causes

  • Default context size is small (common in Ollama)
  • Silent truncation or context shifting
  • Parallel slots divide the context

How to fix it

  1. Set the context explicitly (num_ctx in Ollama, -c in llama.cpp).
  2. In llama-server, remember -c is split across -np slots.
  3. Count tokens to confirm the prompt fits.
  4. Use RAG or summarization instead of stuffing everything in.
bash
# Modelfile
FROM llama3.1:8b
PARAMETER num_ctx 16384

Still stuck? Check the lessons or measure first with the benchmark lab.