VERIFICATIONChecked against current official documentation on 2026.08.04; hardware-specific performance is not generalized.

30-SECOND SUMMARY

What to take away

  • Context is the token window available to the model.
  • Longer context increases KV-cache memory.
  • Measure the smallest sufficient value for the workload.
MEMORY FLOW 01

How context consumes memory

Budget tokens before raising limits.

  1. 01
    PROMPT

    Instructions and text

  2. 02
    TOKENS

    Shared budget

  3. 03
    KV CACHE

    Length and concurrency

  4. 04
    LIMIT

    Smallest sufficient value

Use it this way Compare a new chat at smaller context.
SECTION 01

Budget tokens

System instructions, history, retrieved text, and the answer share one context budget. Characters do not map to tokens uniformly across languages.

SECTION 02

Account for KV cache

The runtime stores prior-token attention state in a KV cache. Longer context and more concurrent requests consume more memory even with the same model file.

SECTION 03

Inspect Ollama

Ollama documents VRAM-based defaults and warns that larger context requires more memory. Use `ollama ps` to inspect allocation and offloading.

OLLAMA_CONTEXT_LENGTH=8192 ollama serve
ollama ps
SECTION 04

Increase only as needed

Measure representative documents plus instructions and answer headroom. Consider retrieval or hierarchical summaries instead of inserting everything.

FAQ

Frequently asked questions

Does more context always improve answers?

No. It costs memory and latency, and models may not use it effectively.

Does it use RAM or VRAM?

That depends on the runtime and offloading; inspect the running process.

What if long chats slow down?

Compare a new chat and a smaller context with the same prompt.

Primary sources

Check the original documentation for version-specific details.

Ollama Context Length Ollama FAQ

READ NEXT

GGUF Quantization: Q4 vs Q5 for Local LLMsHow to Compare Local LLMs for Korean