Hallucination
When an LLM generates plausible sounding text that is factually wrong or invented.
Last updated: October 17, 2026
What Is Hallucination?
A hallucination is content the model produces that sounds plausible but has no basis in fact or in the context you provided. The model still uses its statistical pattern matching, but the pattern produced something false. Surveys separate two kinds (Huang et al., 2023). Factuality hallucination is a mismatch with verifiable real world facts, such as an invented paper or URL. Faithfulness hallucination is a departure from the input, such as a summary that adds a claim the source document does not contain. Earlier work (Ji et al.) used intrinsic hallucination for output that contradicts the source and extrinsic for output that cannot be verified from it.
Kalai et al. (2025) argue that models hallucinate because training and evaluation procedures reward guessing over acknowledging uncertainty. A fluent answer is therefore not evidence of knowledge, and a prompt that demands confidence makes things worse. Mitigations work in layers: ground answers in retrieved text or tool results, allow and test for the answer "I do not know", require citations you can check automatically, and add evals whose answers are absent from the context. None of this brings the rate to zero, so design the product to tolerate residual errors.
Code Example
source = "Refunds are available within 30 days of delivery for unopened items."
def quote_is_supported(quote: str, source: str) -> bool:
return quote.lower() in source.lower()
print(quote_is_supported("within 30 days of delivery", source)) # True
print(quote_is_supported("within 90 days of delivery", source)) # FalseA cheap automated check: does a quoted passage actually appear in the source? It catches invented quotes, not wrong reasoning, so pair it with evals.
When Should You Use Hallucination?
Always assume your model can hallucinate, and decide per feature what a wrong answer costs. Brainstorming needs little protection. Legal, medical, financial and refund answers need grounding (RAG), machine checked citations, an explicit refusal path and human review.
Common Questions
Can RAG eliminate hallucinations?
No. RAG reduces them by giving the model real text to work from, but the model can still misread a passage, ignore it, or answer from memory when retrieval returns nothing relevant. The Huang et al. survey discusses these limits. Measure the rate with an eval set built from your own questions.
Sources
Related Terms
Is your agent hallucinating in production?
It's a fixable problem. Tell me what you're seeing and the workload, and I'll point at the most likely root cause and the right grounding pattern.