Why LLMs Hallucinate
On this page
A lawyer files a brief with case citations that an assistant produced. The cases sound right, have plausible names and years, and do not exist. A support bot promises a refund timeline that is in no policy. In both, the model wasn't broken or malicious; it did exactly what it was trained to do. To reduce hallucinations (and to answer the most common AI engineering interview question about them), you first need to see why fluent text and true text are different things to a language model.
How it works
"Hallucination" means unsupported output
A hallucination is output that sounds confident but is not supported by facts or by the sources the model was given. Two kinds are worth separating:
- Ungrounded (factual) errors: wrong facts from the model's own memory, like a made-up citation.
- Unfaithful answers: the model was given the right document but added, changed or contradicted it.

Why it happens

- The training objective. Pretraining rewards predicting likely next tokens. A sentence like "the paper was published in 2019 by Smith et al." is a very likely shape of text even when no such paper exists. Nothing in that objective checks truth, and abstaining ("I don't know") is rare in training text. Preference tuning can make it worse when raters reward confident, complete-looking answers.
- Knowledge gaps. Rare facts were seen too few times to be stored reliably; anything after the training cutoff was never seen; your company's private data was never there. The model fills the gap with the most plausible pattern.
- Sampling. At each step a token is drawn from a distribution. One unlucky lower-probability choice early on ("in 2017" instead of "in 2019") is then defended consistently by every later token, because the model conditions on its own output.
- Context problems. The right document was not retrieved, a wrong one was, the relevant line sat in the middle of a very long prompt and was ignored, or the instructions pushed the model to answer no matter what.
Checking claims against a source
The most useful way to think about hallucination in applications is claim by claim: split the answer into claims and check each against the provided sources.

Trade-offs and costs
Hallucination can be reduced a lot but not removed, and every fix has a price:
- Grounding with retrieval fixes knowledge gaps but adds retrieval failures of its own and more tokens per call.
- Allowing "I don't know" lowers wrong answers but also lowers the answer rate; you trade coverage for precision.
- Verification passes (a second model call checking claims) cost latency and money.
- Lower temperature removes sampling noise but not wrong knowledge; a deterministic model can be deterministically wrong.
- Bigger, newer models hallucinate less on common facts, but no model is immune on rare or private facts.
In production
- Measure it. Track a faithfulness score (share of claims supported by sources) on a test set and on sampled live traffic. LLM-as-judge or a natural-language-inference model can score claims at scale.
- Design the UX for it. Show citations, link to sources, and let users report wrong answers.
- Risk-based controls. For legal, medical or financial outputs, require citations, block answers without support, and keep a human in the loop.
- Failure modes: confident made-up references, numbers and IDs; wrong answers that cite a real but irrelevant source; drift after a model upgrade. Practical fixes are in How Would You Reduce Hallucinations?
When to reach for it
Any time an LLM states facts users will act on: support, search, analytics summaries, code that calls real APIs (invented function names are hallucinations too), and agents that take actions based on what the model believes.
Example
A support bot answers "How long until my refund arrives?" The policy page says nothing about timing. The model, asked to "always give a complete answer", writes "3–5 business days", a common phrase in refund policies across the web. Three changes fix it: the system prompt allows "the policy doesn't say; here is how to contact billing"; retrieval adds the billing FAQ that does contain the timing; and a grounding check flags any sentence without a supporting passage before the answer is shown.
Common mistakes
- Treating hallucination as a bug to "turn off" with one setting, such as temperature 0.
- Assuming RAG solves it. The model can still ignore or embellish the retrieved text.
- Measuring only "answer looks good" instead of checking each claim against sources.
- Prompts that demand an answer and give no permission to say "I don't know".
- Trusting model-written citations without checking they exist and say what's claimed.
Say this in the interview
"LLMs are trained to produce likely text, not verified text, so when knowledge is missing they fill the gap with something plausible. Causes are the objective itself, knowledge gaps such as cutoff or private data, sampling, and bad or ignored context. I'd ground answers with retrieval, allow abstaining, require citations, verify claims against sources, and measure faithfulness on a test set and live samples, since it can be reduced but not eliminated."
Interview questions on this
- Why does a model invent citations? Citations have a very regular format; the model reproduces the format even when it has no real reference.
- Does temperature 0 stop hallucinations? No. It removes sampling randomness but not wrong or missing knowledge.
- How do you measure hallucination rate? Split answers into claims, check each against sources (human or LLM judge), and report the share of unsupported claims.
- Why can RAG still hallucinate? Retrieval may miss, return wrong passages, or the model may blend its own memory with the context.
- What's the difference between faithfulness and factuality? Faithfulness: consistent with the given sources. Factuality: true in the world. A faithful answer to a wrong source is still wrong.
Used in
- AI Engineering: How Would You Reduce Hallucinations? (practical question); RAG End to End; Evaluating a RAG System; Evals and LLM-as-Judge; How a Chat Model Is Made.
- AI System Design: RAG and grounding; Design Perplexity; Design a Customer Support Agent.