Detecting Hallucinations in RAG
You'll learn how to identify when your RAG system generates answers that aren't actually supported by the retrieved documents.
What Are RAG Hallucinations?
Even with retrieval-augmented generation, LLMs can still "hallucinate"—confidently stating facts that don't appear in the retrieved context. In RAG, this happens when the model:
- Invents details not present in source documents
- Mixes information from its training data with retrieved context
- Makes logical leaps beyond what's explicitly stated
- Fabricates citations or quotes
Think of it like a student writing an essay: they might paraphrase correctly from sources (good) or make up "facts" that sound plausible but aren't in the reading material (hallucination).
How to Detect Hallucinations
The core detection strategy is claim verification: systematically compare what the model outputs against what the retrieved documents actually say.
Manual Spot-Checking
Review model outputs alongside retrieved chunks. Ask: "Can I find this specific claim in the source documents?"
Automated Verification
Use an LLM as a judge:
- Extract individual claims from the generated answer
- For each claim, check if it's entailed by the retrieved context
- Score outputs on "groundedness" or "faithfulness"
Red Flags to Watch
- Highly specific numbers or dates not in context
- Names or technical terms absent from retrieved docs
- Definitive statements when sources are vague
- Information that contradicts retrieved context
Key Takeaway: Detecting hallucinations in RAG means systematically verifying that every claim in the generated answer is directly supported by the retrieved documents—treating source documents as the single source of truth for that response.