Anatomy of Hallucination
Not all hallucinations are the same. Understanding the taxonomy (intrinsic vs. extrinsic, factual vs. reasoning vs. citation) is the prerequisite for choosing the right prevention technique for each type.
The First Division: Intrinsic vs. Extrinsic
The most important structural distinction in hallucination research is between intrinsic and extrinsic hallucination. The difference determines where the fix lives:
| Type | Definition | Example | Primary Fix Layer |
|---|---|---|---|
| Intrinsic | Output contradicts information that was present in the context window | The document says the contract expires in 2027; the model summarizes it as 2029 | Prompting, grounding, retrieval faithfulness |
| Extrinsic | Output adds information not present in the context and cannot be verified from it | The model adds a clause to a contract summary that does not appear in the original document | RAG design, output constraints, monitoring |
Intrinsic hallucination is, counterintuitively, easier to detect: you can check the output against the source document. Extrinsic hallucination is harder because the fabricated information may look plausible and there is nothing in the input to compare it against.
The Five Types of Hallucination
Type 1: Factual Hallucination
The model asserts something that is factually wrong. This is the most commonly discussed type and the one most people think of when they hear "hallucination."
After (correct): "The World Health Organization was founded in 1948 and is headquartered in Geneva, Switzerland."
Both sound equally authoritative. Only the second is accurate.
Factual hallucination is especially common in queries about specific dates, numbers, names, and organizational details, exactly the details that feel most checkable but are, in practice, rarely verified before use.
Type 2: Reasoning Hallucination
The model produces a logically invalid conclusion from premises that may themselves be correct. The steps look reasonable; the conclusion does not follow.
After (correct): "Grandfathering under this regulation applies only to performance obligations, not liability caps. A signed date before the effective date does not automatically exempt this clause."
The reasoning in the first example sounds like legal analysis. It contains a subtle error that a non-expert would not catch.
Reasoning hallucination is hardest to catch because it requires domain expertise to identify. It is most dangerous in legal, medical, and financial contexts where the stakes of wrong reasoning are highest.
Type 3: Citation Hallucination
The model invents references: paper titles, author names, journal names, URLs, court cases, regulatory citations. The format is correct; the content does not exist.
After (correct approach): "I do not have a citation for this specific claim. You should verify this in the primary literature before relying on it."
The fake citation will pass a casual review. It will fail the moment someone tries to locate the paper.
Citation hallucination is particularly insidious in academic, legal, and regulatory contexts where citations are expected to be verifiable. Teams have encountered fabricated court case citations, invented regulatory guidance, and non-existent product documentation.
Type 4: Code Hallucination
The model generates syntactically valid code that calls APIs incorrectly, references removed methods, uses wrong parameters, or makes incorrect assumptions about library behavior.
response = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[...],
stream_mode="continuous" # Does not exist
)
After (correct):
with client.messages.stream(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[...]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
The hallucinated parameter name looks like it belongs. It throws a TypeError at runtime.
Code hallucination is especially common at API version boundaries, when libraries have recently updated their interfaces, or when the model is working with a less-common library that appears infrequently in training data.
Type 5: Entity Hallucination
The model invents named entities: people, organizations, products, events, dates, or places that do not exist or did not occur as described.
After (correct approach): Verify whether this report, these authors, and this framework exist before including the reference in any published document.
The named entities are plausible. They may or may not be real. Only verification will tell you.
Why Taxonomy Matters for Prevention
Different hallucination types respond to different interventions. Matching the fix to the type is the core skill in hallucination engineering:
| Type | Best Prevention Approach | Best Detection Approach |
|---|---|---|
| Factual | RAG + grounding prompts | Cross-reference against source |
| Reasoning | Chain-of-thought + self-critique | Expert review, LLM-as-judge |
| Citation | Explicit "do not invent citations" instruction; cite-from-context only | URL/DOI existence check |
| Code | RAG over current API docs; runnable test step | Static analysis + execution |
| Entity | Named entity constraints; entity verification tool call | Named entity recognition + lookup |
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX