Why is the output nonsense?
Nonsense output has four usual causes, and the symptom tells you which. Check them in the order below, because the first is the most common and the cheapest to fix.
| Symptom | Likely cause |
|---|---|
Talks to itself, writes "User:" lines, prints tags like <|im_end|>, never stops | Wrong chat template |
| Repeats one phrase, loses the thread, worse than the same model elsewhere | Over-aggressive quantization |
| Rambles, switches language, or gives the same dull answer every time | Sampler settings |
| Random characters from the first token, or only in one specific file | A broken upload |
Wrong chat template
A chat model is trained to see messages wrapped in special tokensTokenA chunk of text, usually part of a word. Models read and write in tokens.Read more that mark who is speaking. The chat templateChat templateThe exact wrapper of tags a model expects around each message.Read more adds them. If the template is wrong or missing, the model sees one long block of text and carries on writing it, playing both sides of the conversation.
The fix is to use the template that ships with the model. Ollama and LM Studio read it from the model file automatically. With llama.cpp's server, pass --jinja so it uses the template embedded in the GGUFGGUFThe single-file model format used by llama.cpp and the apps built on it.Read more.
llama-server -m model.gguf --jinjaIf you built your own Ollama Modelfile or imported a raw GGUF, the template is where it breaks. Compare yours with the one on the model card. Why does my model ramble or answer itself? shows what a template looks like.
If the model writes the next "User:" turn itself, it is the template. Nothing else causes that.
Over-aggressive quantization
Below 4-bit, models start to lose coherence, and small models lose it first. A 3B model at 2-bit often loops or contradicts itself. A 70B model at 3-bit is usually fine.
Step up one level and try again. If Q4_K_M behaves and Q2_K does not, you have your answer. Which quantization should I download? shows how far you can go for each size.
| Label | Bits per weight | 8B file | Size | Quality |
|---|---|---|---|---|
F16 / BF16 | about 16 | about 16 GB | The original. Reference quality. | |
Q8_0 | about 8.5 | about 9 GB | Indistinguishable from the original in practice. | |
Q6_K | about 6.6 | about 7 GB | Close to the original. | |
Q5_K_M | about 5.7 | about 6 GB | A small, rarely visible loss. | |
Q4_K_M | about 4.8 | about 5 GB | The common default. Most people never notice. | |
Q3_K_M | about 3.9 | about 4 GB | Noticeable on small models. Often fine on big ones. | |
Q2_K | about 3 | about 3 GB | Clearly degraded. Only to squeeze a much bigger model in. |
As of 27 Nov 2026 · Typical llama.cpp figures. They vary a little by model. llama.cpp quantize docs
A bigger quantizationQuantizationStoring each weight with fewer bits so the model takes less memory.Read more needs more memory. If you cannot fit Q4 of this model, a smaller model at Q4 will usually beat this one at Q2. See Which size of model do I need?.
Sampler settings
Samplers decide how the next token is picked from the model's guesses. A temperatureTemperatureHow much randomness goes into picking each token.Read more that is too high makes output random, too low makes it flat and repetitive. A strong repeat penalty can push the model away from words it needs, so it starts inventing odd ones.
Reset to the defaults first. Then use the settings on the model card, since many families publish recommended values and some, such as reasoning models, break with greedy decoding. Should I touch temperature and the other sliders? explains each setting.
/set parameter temperature 0.7Type this inside an ollama run session to change the temperature for that chat only. Then repeat the question that went wrong.
A broken upload
Sometimes the file itself is bad. Early uploads of a new model can have a wrong tokenizer or a missing setting, and are replaced a few days later. A download can also be cut short or corrupted.
Signs are output that is garbled from the first token, or a model that works from one uploader and not another. The fixes, in order:
- Delete and download again. On Hugging Face, compare the file's SHA256 with the one on the file page.
- Check the model page for an update or a note about fixed files, then get the newest version.
- Try the same model from a different uploader. Where do I download models? lists the ones that are careful.
- Update your runtimeRuntimeThe software that loads a model file and runs it.Read more. A model released last week may need support that landed yesterday.
Go deeperThat's enough
Context overflow looks like nonsense too
When a chat runs past the context length, some runtimes drop the oldest tokens to make room. If that cuts the system promptSystem promptStanding instructions placed before the conversation.Read more or half a message, the model loses its instructions and answers oddly. Start a new chat to test it. How much can the model keep in mind? explains the limit and Why does my agent forget things or fail tool calls? covers the agent version of the problem.
Why small models break first
A small model has less redundancy, so each weight carries more of the model's behaviour, so the rounding errors from quantization add up faster. Larger models can absorb the same rounding with little visible change. This is why the right quantization depends on model size, not only on your memory.
Thinking tokens showing up
Reasoning models write a thinking block before the answer. If your app does not know the format, you see raw tags and long internal monologue in the reply. That is the model working, not nonsense.
Update the app or turn thinking off, see What are reasoning models, and why are they slow?.