Model forgets the beginning or ignores long texts (context length too small)
In long chats or pasted documents, the model loses the beginning, ignores instructions, or replies blank because the context is set too small.
The message
CONTEXT 4096 (ollama ps) / num_ctx 2048
Affects: Ollama, Open WebUI, LM Studio, llama.cpp, AnythingLLM
Why is this happening?
Context length determines how much text the model sees at once. By default, Ollama uses only 4096 tokens when you have less than 24 GB of VRAM and silently cuts off longer inputs. In Open WebUI, num_ctx is set to 2048 after enabling it and then overrides the Ollama setting.
How to fix it
- Check the current length in Ollama with
ollama ps(CONTEXT column). - Ollama app: Open the settings and raise the context length slider, for example to 16k or 32k.
- Without the app setting: Set the environment variable
OLLAMA_CONTEXT_LENGTH(for example16384) and restart Ollama. For a single session in the terminal,/set parameter num_ctx 16384is enough. - Open WebUI: Leave
num_ctxempty under Chat Controls → Advanced Parameters so the Ollama value applies, or enter a larger value on purpose, such as 8192. For a model permanently, do this in Workspace → Models. - LM Studio: Set a higher Context Length when loading the model. llama.cpp: Start with
-c 16384(default 0 uses the value from the model). - Keep an eye on memory: More context needs more VRAM. If
ollama psthen shows a CPU/GPU split, lower it again a bit.
Better not: Don’t set the context to the model’s maximum across the board (for example 128k): That will exceed the memory on normal gaming graphics cards and make everything slow.
Set up from scratch again
If it still doesn’t work after that, a fresh setup step by step often helps:
- Your own ChatGPT with Ollama and Open WebUI
Run a language model locally on Windows - with the Ollama app, suitable models for 8 to 24 GB, context length, command line, and Open WebUI… - Chat with your own documents (AnythingLLM)
Set up AnythingLLM Desktop on Windows, load PDFs into a workspace, and ask questions locally — with sources and privacy. - LM Studio: Your First Local Chat
Install LM Studio on Windows, load a suitable language model, and chat offline, even with your own documents.
Terms for this
Similar errors
- Confusing answers, endless loops, or tags like <|im_end|> (wrong chat template)
- Ollama: model "…" not found, try pulling it first (model missing on this server)
- GGUF: unknown model architecture (program too old for the model)
- Very slow responses because the model does not fit in VRAM
- AMD graphics card not being used (ROCm or Vulkan)
Sources
- https://docs.ollama.com/context-length
- https://docs.ollama.com/faq
- https://docs.openwebui.com/getting-started/quick-start/connect-a-provider/starting-with-ollama.md
- https://lmstudio.ai/docs/app/advanced/per-model
- https://raw.githubusercontent.com/ggml-org/llama.cpp/master/tools/server/README.md
Checked on Oct 21, 2026. Didn't help? Ask in the forum and name the graphics card, program, and the full message.