Skip to content
English

Switch theme

// Error · Run models on your own machine

Ollama truncates long documents and the model “forgets” earlier text

Ollama’s default context length is much smaller than many models support (the default changes between versions). When input exceeds it, earlier content is dropped.

verified 2026-10-101 official sources

Scenario: Run models on your own machine →

🖥️Self-hosted computeSelf-hosted compute: decide → size → build → run, with calculators→

Symptoms

  • Answers about a long document only cover its last part
  • An agent forgets earlier instructions after several turns

Common causes

  • The context length (num_ctx) is still the default

How to fix

  1. Temporarily: in an ollama run session type /set parameter num_ctx 16384
  2. Globally: set the OLLAMA_CONTEXT_LENGTH environment variable before starting the server (newer versions; see the official FAQ)
  3. Via the API: pass num_ctx in the request options
  4. Or write a Modelfile with PARAMETER num_ctx 16384 and ollama create a new model
  5. A larger context uses more memory; size it to your hardware

Official references

Compiled from official documentation and public discussions on 2026-10-10; not yet reproduced in our own environment. Follow the official docs if they differ.

Data updated: Problems & errors