"The LLM hallucinated" is a symptom description, not a diagnosis — and treating it as one bug leads to one blunt fix (usually "add a stern prompt") that works for maybe a third of cases. Hallucination is several distinct failure modes that happen to share a surface: the model stated something false with confidence. This framework classifies why a specific false statement happened, because the mitigation that works depends entirely on the cause.
Why models hallucinate at all
An LLM generates the most probable continuation of the text so far. It is optimised to be fluent and plausible, not to be correct — there is no internal "I don't actually know this" gate unless the training and prompting create one. When the context and its priors don't pin down the answer, the model still produces something, and that something is a confident guess. So the engineering question is never "how do I make it stop guessing" but "how do I make sure it has what it needs, and make its guesses rare, visible and low-consequence."
The first cut: retrieval failure vs true hallucination
In any RAG or tool-augmented system, do this before anything else. Take the failing output and inspect the context the model actually received:
- The answer was not in the context → this is a retrieval failure wearing a hallucination costume. No prompt or model swap fixes information the model never saw. Go fix retrieval — see why RAG retrieval quality drops in production.
- The answer was in the context, and the model still invented or contradicted it → a true grounding/generation problem. The framework below applies.
This single check reclassifies the majority of "hallucinations" in production RAG as retrieval bugs. Skipping it sends teams down the wrong path for weeks.
The root-cause taxonomy
| Root cause | What it looks like | Mitigation that matches |
|---|---|---|
| Missing context | Answer absent from context; model fills gap from priors | Fix retrieval; let the model abstain ("say if not in the context") |
| Conflicting context | Two retrieved chunks disagree (v1 vs v2 docs); model blends them | Metadata filter by version/date; dedupe; prefer authoritative source |
| Over-generalization | Model applies a general pattern to a case where the specifics differ | Provide the specific facts in context; constrain scope in prompt |
| Prompt ambiguity | Under-specified request; model picks an interpretation and commits | Disambiguate the task; ask clarifying question; structured input |
| Overconfidence / no abstention | Model answers when it should decline | Explicit permission to say "I don't know"; verification gate |
| Format-forced fabrication | Schema demands a field the source doesn't contain, so it's invented | Make fields nullable; allow "not stated" |
Notice that "add a better prompt" only addresses two of six rows. The others need retrieval, data hygiene, or schema changes.
Cause deep-dives
Conflicting context is the sneaky one
When retrieval returns the v1 manual and the v2 manual, both semantically relevant, the model has no reliable way to know which is current — so it merges them into a plausible hybrid that matches neither. This reads exactly like a hallucination but is a data problem: you retrieved contradictory sources. Fix it upstream with version/date metadata filters and deduplication, not with prompting.
Format-forced fabrication
A strict output schema ("return name, revenue, founding_year") applied to a source that only mentions the name will pressure the model to fill revenue and founding_year with invented values, because the format says a value is required. Make extraction fields explicitly nullable and instruct "use null / 'not stated' when the source does not contain it." Fabrication drops sharply.
No permission to abstain
If the prompt implies every question has an answer, the model will produce one. Explicitly granting "if the provided context does not contain the answer, say you don't have that information" converts a class of confident fabrications into honest declines — which are almost always the safer failure.
Mitigations, in order of leverage
- Ground it. Retrieve the right facts into the context (fix retrieval first). Ungrounded generation is the highest-hallucination configuration.
- Constrain and permit abstention. "Answer only from the context; if it's not there, say so." Cheap, high-impact.
- Verify faithfulness. Add a check — a second pass, a contextual-grounding/faithfulness score, or a classifier — that confirms each claim is supported by the retrieved passages. Managed options exist (e.g. Bedrock Guardrails contextual grounding checks).
- Cite sources. Return the passages behind each claim so an unsupported statement is visible to the user and to your evals.
- Human-in-the-loop for high stakes. For medical, legal, financial or irreversible actions, a verification step is architecture, not paranoia.
Measure faithfulness, not vibes
You cannot manage what you don't measure. Build a golden set and track faithfulness (is the answer supported by the context) separately from answer relevance and context precision/recall. Frameworks like RAGAS give repeatable numbers so you can tell whether a change actually reduced unsupported claims or just moved them around. A hallucination rate you can trend is a hallucination rate you can drive down.
Common wrong approaches
- Adding "do not hallucinate" to the prompt. The model has no reliable internal truth signal to obey it; this barely moves the needle.
- Assuming a bigger/newer model fixes it. Better models hallucinate less on average but still fabricate ungrounded facts — and do so more convincingly.
- Lowering temperature to 0 and calling it solved. Determinism ≠ correctness; a deterministic wrong answer is still wrong.
- Treating every wrong answer as the same bug. Without the taxonomy you apply the wrong fix and the failure persists.
Related resources
- Why RAG retrieval quality drops in production — because most "hallucinations" start here.
- Hybrid search vs vector search and RAG explained.
- Bedrock Knowledge Bases RAG troubleshooting for grounding on AWS.
- GenAI interview support guide and RAG & Agentic AI job support guide.
If you're chasing an intermittent hallucination in a live LLM feature and need help classifying the cause quickly, real-time proxy job support can work through the taxonomy with you on the actual traces. And reasoning about hallucination as a set of distinct, mitigable failure modes is precisely the depth that LLM interview proxy support and GenAI interview proxy support prepare you to show.
Last reviewed: September 2026.