Factuality and Hallucination Detection
What You'll Learn
You'll discover how to verify that LLM-generated text is factually grounded and detect when models confidently invent false information ("hallucinate").
The Core Problem
LLMs sometimes generate text that sounds convincing but contains fabricated facts, incorrect dates, non-existent citations, or misattributed quotes. Hallucination detection aims to catch these errors before they reach users. Think of it as a fact-checker that examines every claim against reality.
Three Core Techniques
1. Claim Verification
Break generated text into individual factual claims, then verify each against trusted sources. For example, "Paris is the capital of France" is one verifiable claim.
2. Entailment Checking
Use a secondary model to determine if generated statements are entailed by (logically follow from) the source documents. If your RAG system retrieved three articles about climate, does the LLM's summary actually follow from those articles, or did it add unsupported details?
3. Source Grounding
Require the model to cite specific passages from retrieved documents. Then programmatically verify that cited text exists and actually supports the claim. This creates an audit trail: "This sentence came from Document 2, paragraph 3."
Implementation Pattern
You evaluate generated text after generation using specialized tools or LLM-as-a-judge patterns (which you've already learned). You might score each sentence on a factuality scale (0-1) or flag specific claims as "unsupported," "contradicted," or "verified."
Why It Matters
In high-stakes domains like healthcare, legal, or finance, hallucinations aren't just embarrassing—they're dangerous. Factuality detection acts as a quality gate before information reaches decision-makers.
Key Takeaway: Factuality and hallucination detection combines claim extraction, entailment verification, and source grounding to catch when LLMs confidently generate false information, protecting users from plausible-sounding errors.