Table of Contents
Quick Answer
An AI hallucination is output that looks factual but is invented — wrong citations, fake quotes, nonexistent case law, or impossible code.
- Occurs in ~3-30% of LLM outputs depending on task
- Worst in open-ended factual questions
- Reduced — not eliminated — by RAG and fine-tuning
What Does Hallucination Mean?
LLMs do not "know" facts the way a database does. They predict likely next tokens based on patterns. When the most likely token happens to be wrong, the model confidently fabricates. Stanford HAI's AI Index (2024) notes hallucination is the top barrier to enterprise adoption.
How It Works
There are two common causes:
- Knowledge gaps: the model was never trained on the true fact, so it fills in with something plausible
- Compression errors: training data is summarized in weights, and details blur together
There is no "I do not know" neuron. The model must output something, so it outputs the most statistically plausible token, true or not.
Examples
- A lawyer cited six AI-generated fake court cases (Mata v. Avianca, 2023)
- Chatbot invents a non-existent Python function pandas.read_xyz()
- Summary of a meeting includes a decision that was never made
- AI recommends a book that does not exist — correct author, fake title
- Model states a company's revenue that is off by 10x
Hallucination vs Error
- Error: arithmetic mistake, typo, parsing failure
- Hallucination: fabricated entity or relationship that sounds real
Both are wrong — hallucinations are scarier because they are confident and specific.
When Hallucination Is Most Dangerous
- Legal, medical, or financial advice
- News summarization
- Coding libraries or APIs
- Historical facts and citations
- Product specifications
FAQs
Can temperature 0 fix hallucinations? It reduces randomness but not factual errors.
Does RAG eliminate hallucinations? It reduces them substantially — the model grounds in retrieved docs. But it can still misquote them.
Which models hallucinate least? Frontier models (GPT-5, Claude Sonnet 4.5) outperform open models on TruthfulQA, but none are zero.
Can I detect hallucinations automatically? Partially — self-consistency checks and fact-verification pipelines help.
Are code hallucinations dangerous? Yes — "slopsquatting" attacks exploit hallucinated package names.
Does fine-tuning help? Mildly — it teaches style more than facts.
What should users do? Verify every factual claim from AI with a primary source.
Conclusion
Hallucination is not a bug — it is inherent to how LLMs work. Design products with verification, citations, and human review. More safety guides at Misar Blog↗.