[Official FAQ] Share your experience or follow-up questions below.
This is a very common surprise. Often the model is not "bad": the context window is smaller than you think, so older text is silently truncated.
Ollama has historically used a fairly small default context (a few thousand tokens, and the default depends on the version). If you paste a long document or have a long chat, the beginning may be dropped without any error.
How to fix it
- Check your version's documentation for the current default and for how to change it.
- Per model, create a Modelfile:
FROM llama3.1(or your model)
PARAMETER num_ctx 8192
then runollama create mymodel -f Modelfile. - In the interactive CLI you can use
/set parameter num_ctx 8192. - When calling the API, you can pass
num_ctxin theoptionsfield. Note that the OpenAI-compatible endpoint may not accept every Ollama-specific option, so the Modelfile approach is more reliable there. - Newer versions may also offer a server-wide setting, so check the docs for your version.
Remember the trade-offs: a bigger context uses more memory. If it no longer fits in VRAM, part of the model may move to CPU and generation will slow down. You can check with ollama ps.
Also make sure the model itself supports the length you set. Going beyond its trained limit can hurt quality.
If your problem persists, post your Ollama version, the model name, and roughly how long your input is.
