Lesson 336·M27 AI Observability & Evaluation
Hallucination Detection
OpenLearning Objectives
By the end of this lesson you should be able to:
- Explain the hallucination: the fluent untruth (L336)
- Explain the signals: the uncertainty, the contradictions (L336)
- Explain the guard: the checks, the citations, the fallback (L336)
- Explain the detection: the NLI and the LLM-judge (L336)
- Explain the AI shape: the RAG's untruth watch (L336)
One-Line Definition
The hallucination detection spots the ungrounded claims in the production output (L336) — the hallucination (the fluent untruth: the confident claim with no basis, L336), the signals (the uncertainty L139, the contradictions, the missing citations L192, L336), and the guard (the checks: the NLI L336 and the LLM-judge L343, the citations L192, and the fallback L336) — the RAG's (L280) untruth watch (L336).
The one-sentence interview answer: "The hallucination detection spots the ungrounded claims (L336). The hallucination (L336): the fluent untruth (L336) — the confident claim (L336) with no basis in the retrieved context (L189) or the model's knowledge (L336) — the model (L278) generates what sounds right (L336). The signals (L336): the uncertainty (L139) — the low probability (L336); the contradictions (L336) — the answer vs the context (L189); the missing citations (L192) — the ungrounded claims (L336) lack the sources (L192). The detection (L336): the NLI (L336) — the natural language inference: does the answer follow from the context (L337); and the LLM-judge (L343) — the second model (L343) scoring the groundedness (L337). The guard (L336): the citations (L192) — the grounded answers (L280) cite the sources (L192); the check (L336) — the low-groundedness (L337) flagged (L336); and the fallback (L336) — the flagged answer (L336) refused or corrected (L336). The AI shape (L173): the RAG (L280) — the ungrounded claim (L336) in the answer (L336) — the detection (L336) and the guard (L336) — the fluent untruth (L336), caught (L336)."
Mental Model
Think of the hallucination detection as the fact-checker at the newsroom. The reporter (the model, L278) writes the story (the answer, L328) — fluent (L336) but sometimes invented (L336): the sources (the retrieved context, L189) checked (L336). The fact-checker (the detector, L336): the source check (the citations, L192) — the un-cited claims (L336) flagged (L336); the contradiction check (the NLI, L337) — the story vs the sources (L336); and the editor's review (the LLM-judge, L343) — the second opinion (L343). The flagged stories (L336) — the low-groundedness (L337) — are withheld (the fallback, L336): the correction (L336) or the refusal (L336). The newsroom works because the sources are cited, the claims are checked, and the flagged stories don't print (L336).
the fact-checker (the detector, L336)
┌────────────────────────────────────────────────────────┐
│ the sources (the context, L189) · the citations │
│ (L192) │
│ the checks (L336): the NLI (L337), the judge (L343) │
│ the withheld (the fallback, L336) — the correction, │
│ the refusal (L336) │
└────────────────────────────────────────────────────────┘
The mental model is the fact-checker: the sources, the checks, and the withheld (L336).
Visual Flow — One Detected Hallucination
the answer (L328)
│ the fluent claim (L336)
▼
┌────────────────────── THE SIGNALS (L336) ──────────────────────────┐
│ the missing citation (L192) · the low probability (L139) │
│ the contradiction vs the context (L189, L337) │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌────────────────────── THE DETECTION (L336) ────────────────────────┐
│ the NLI (L337): the answer follows from the context? (L336) │
│ the LLM-judge (L343): the groundedness score (L337) │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌────────────────────── THE GUARD (L336) ────────────────────────────┐
│ the grounded (L337) → the answer with the citations (L192) │
│ the ungrounded (L336) → the fallback (L336): the correction, │
│ the refusal (L336) │
└──────────────────────────────────────────────────────────────────┘
The flow is the detection: signals → detection → guard (L336).
How It Works — The Watch, Part by Part
- The hallucination (L336). The fluent untruth (L336): the confident claim (L336) with no basis (L336).
- The signals (L336). The uncertainty (L139), the contradictions (L337), the missing citations (L192).
- The detection (L336). The NLI (L337) — the natural language inference; the LLM-judge (L343) — the second model (L343) scoring the groundedness (L337).
- The guard (L336). The citations (L192), the check (L336), and the fallback (L336) — the correction (L336) or the refusal (L336).
Note
The detection is the production's groundedness check (L336). The senior answer distinguishes the eval (L341) from the detection (L336): the eval (L341) measures the system's quality (L341) on the golden set (L342); the detection (L336) checks the individual output (L328) in production (L307) — the NLI (L337) or the judge (L343) per answer (L336), the low-groundedness (L337) flagged (L336) and the fallback (L336) applied (L336).
Real Project Usage
- A RAG platform (L280). The grounded answers (L337) with the citations (L192) — the ungrounded (L336) flagged (L336).
- A chat product (L162). The detection (L336) on the free-form answers (L328) — the fallback (L336) for the ungrounded (L336).
- A medical or legal copilot (L371). The high-stakes (L371) — the detection (L336) mandatory (L336), the refusal (L336) the default (L336).
- A search summarizer (L336). The summaries (L336) checked against the sources (L189) — the NLI (L337).
- Anything RAG (L280). The untruth watch (L336) — the fluent claim (L336), caught (L336).
The through-line: the watch is the untruth's — the signals, the detection, and the guard (L336).
Interview Explanation
Say it in four moves:
- The hallucination. "The fluent untruth — the confident claim with no basis (L336)."
- The signals. "The uncertainty (L139), the contradictions (L337), the missing citations (L192)."
- The detection. "The NLI (L337) and the LLM-judge (L343)."
- The guard. "The citations (L192), the check (L336), the fallback (L336)."
Senior-Level Insights
- The hallucination is the fluency's trap (L336). The model (L278) generates what sounds right (L336) — the fluent untruth (L336) is the risk (L336).
- The grounding is the RAG's fix (L280). The grounded answer (L337) — the retrieval's (L189) context (L280) — the hallucination (L336) reduced (L336).
- The citations are the evidence (L192). The cited answer (L192) — the user (L162) verifies (L192) — the un-cited claim (L336) flagged (L336).
- The judge is the scalable check (L343). The LLM-judge (L343) — the groundedness (L337) scored (L343) at the scale (L343) — the human review (L341) sampled (L341).
- The fallback is the trust (L336). The flagged answer (L336) refused (L336) — the product's (L173) honesty (L336).
Common Mistakes
- The fluency trusted (L336). The confident answer (L336) taken at face value (L336) — the fluent untruth (L336) ships (L336).
- The detection missing (L336). The ungrounded (L336) unflagged (L336) — the RAG (L280) answers from the air (L336).
- The citations absent (L192). The answer (L328) without the sources (L192) — the verification (L192) impossible (L336).
- The fallback missing (L336). The flagged answer (L336) still delivered (L336) — the trust (L336) broken (L336).
- The judge un-validated (L343). The judge's (L343) bias (L343) unchecked (L343) — the L343 validation (L343) is the judge's (L336).
Best Practices
- Ground the answers (L280) — the retrieval's (L189) context (L280).
- Cite the sources (L192) — the evidence (L192) in the answer (L336).
- Check the groundedness (L337) — the NLI (L337) and the judge (L343).
- Fallback on the low (L336) — the correction (L336) or the refusal (L336).
- Validate the judge (L343) — the agreement with the humans (L341).
Interview Questions
Q: Walk me through the hallucination detection.
A: Spotting the ungrounded claims (L336). The hallucination — the fluent untruth (L336). The signals — the uncertainty (L139), the contradictions (L337), the missing citations (L192). The detection — the NLI (L337) and the LLM-judge (L343). And the guard — the citations (L192), the check (L336), the fallback (L336).
Q: Why do models hallucinate?
A: The generation (L336): the model (L278) predicts the next token (L336) — what sounds right (L336) — not what's true (L336). The fluency (L336) and the confidence (L336) don't imply the grounding (L337). The RAG (L280) reduces it (L336): the grounded answer (L337) from the retrieved context (L189).
Q: How do you detect it in production?
A: Per answer (L336): the NLI (L337) — does the answer follow from the context (L189); and the LLM-judge (L343) — the groundedness (L337) scored (L343). The signals (L336) — the missing citations (L192), the contradictions (L337) — plus the checks (L336), and the low-groundedness (L337) flagged (L336).
Q: What do you do with the flagged answers?
A: The fallback (L336): the correction (L336) — the grounded re-answer (L280); or the refusal (L336) — the honest "I don't have the source" (L336). The high-stakes (L371) — the medical and the legal (L371) — refuse by default (L336).
Follow-Up Questions
- What's the hallucination (L336)?
- Why do models hallucinate (L336)?
- How do you detect it (L336)?
- What do you do with the flagged (L336)?
- What's the NLI (L337)?
Comparison Table — The Eval vs the Detection
| The eval (L341) | The detection (L336) | |
|---|---|---|
| The scope (L336) | the golden set (L342) | the individual output (L328) |
| The timing (L336) | the schedule, the CI (L296) | the production (L307), per answer (L336) |
| The use (L336) | the quality (L341) | the guard (L336), the fallback (L336) |
The senior read: the eval measures; the detection guards — the two groundedness checks (L336).
Code Example — The Watch, Applied
// The hallucination detection (L336) — the production guard (L336).
// 1 · THE GROUNDED ANSWER (L280) — the citations (L192).
async function groundedAnswer(query) {
const chunks = await retrieve(query); // the retrieval (L189)
const answer = await model.invoke({ query, context: chunks });
return { answer, chunks }; // the evidence (L192)
}
// 2 · THE DETECTION (L336) — the groundedness check (L337).
async function checkGroundedness(answer, chunks) {
// THE NLI (L337): does the answer follow from the context?
const nli = await nliScore(answer, chunks); // L337
// THE LLM-JUDGE (L343): the groundedness score (L337).
const judged = await judge.groundedness({ answer, chunks }); // L343
// THE SIGNALS (L336): the citations' coverage (L192).
const cited = chunks.some((c) => answer.includes(c.citationId)); // L192
return { score: (nli + judged.score) / 2, cited, grounded: judged.score >= 0.85 };
}
// 3 · THE GUARD (L336) — the fallback (L336).
async function guarded(query) {
const { answer, chunks } = await groundedAnswer(query);
const check = await checkGroundedness(answer, chunks);
if (!check.grounded || !check.cited) {
return { fallback: 'refusal', message: 'I could not verify this from the sources.' }; // L336
}
return { answer, citations: chunks.map((c) => c.source) }; // L192
}
What the reader must SEE — the watch, applied:
retrieve + context → the grounding (L280, L189)
nliScore + judge → the detection (L337, L343)
citations coverage → the evidence (L192)
grounded < 0.85 → refusal → the fallback (L336)
The fluent claim checked, the ungrounded refused (L336).
Tip
The pair that defines the watch: the retrieved context (the grounding, L189) and the groundedness score (the check, L337). Ground with the retrieval, check with the judge, cite the sources, refuse the low — the fluent untruth, caught (L336).
Performance Notes
- The check is the answer's latency (L336). The NLI (L337) and the judge (L343) — the seconds (L336) per answer (L336) — the sampling (L341) for the interactive (L162).
- The judge is the cost (L343). The second model (L343) — the tokens (L332) — the sampling (L341) bounds it (L336).
- The citations are the zero-cost evidence (L192). The retrieval's (L189) sources (L192) — no extra cost (L336).
- The fallback is the trust's cost (L336). The refusal (L336) — the missed answers (L336) for the honesty (L336).
Debugging Scenarios
| Symptom | First check (L336) | The lever |
|---|---|---|
| The answer is ungrounded | The detection (L336) | The NLI (L337), the judge (L343) |
| The citations are missing | The answer (L192) | The citation rendering (L192) |
| The judge is biased | The validation (L343) | The human agreement (L341) |
| The flagged answers ship | The fallback (L336) | The refusal (L336) |
| The hallucinations persist | The RAG (L280) | The retrieval (L189), the chunking (L178) |
Quick Revision Notes
- The hallucination detection = the untruth's watch (L336): the hallucination, the signals, the detection, the guard.
- The hallucination: the fluent untruth (L336).
- The signals: the uncertainty (L139), the contradictions (L337), the missing citations (L192).
- The detection: the NLI (L337) and the LLM-judge (L343).
- The guard: the citations (L192), the check (L336), the fallback (L336).
Cheat Sheet
HALLUCINATION DETECTION = spotting the ungrounded claims
THE HALLUCINATION (L336)
the fluent untruth (L336) — the confident claim (L336)
with no basis (L336) — what sounds right (L336)
THE SIGNALS (L336)
the uncertainty (L139) · the contradictions (L337)
the missing citations (L192)
THE DETECTION (L336)
the NLI (L337) — the answer follows from the context? (L336)
the LLM-judge (L343) — the groundedness score (L337)
per answer (L336) — the production (L307) check (L336)
THE GUARD (L336)
the citations (L192) — the evidence (L192)
the check (L336) — the low-groundedness (L337) flagged (L336)
the fallback (L336) — the correction (L336) or the refusal (L336)
INTERVIEW, 4 MOVES
1 hallucination "the fluent untruth (L336)"
2 signals "the uncertainty, the contradictions, the citations (L336)"
3 detection "the NLI and the judge (L337, L343)"
4 guard "the citations, the check, the fallback (L336)"Key Takeaways
Recap
- The hallucination detection spots the ungrounded claims in the production output (L336): the hallucination (L336), the signals (L336), the detection (L336), and the guard (L336)
- The hallucination (L336): the fluent untruth (L336) — the confident claim (L336) with no basis (L336)
- The signals (L336): the uncertainty (L139), the contradictions (L337), and the missing citations (L192)
- The detection (L336): the NLI (L337) — the natural language inference (L336) — and the LLM-judge (L343) — the groundedness (L337) scored (L343) — per answer (L336) in the production (L307)
- The guard (L336): the citations (L192), the check (L336), and the fallback (L336) — the correction (L336) or the refusal (L336)
- The AI shape (L336): the RAG (L280) — the ungrounded claim (L336) in the answer (L336) — the detection (L336) and the guard (L336) — the fluent untruth (L336), caught (L336)
Check your understanding
Answer each one out loud. Then rate yourself honestly.
0/8What's the hallucination (L336)?
Why do models hallucinate (L336)?
How do you detect it (L336)?
What do you do with the flagged (L336)?
What's the NLI (L337)?
What's the judge (L343)?
What's the citation (L192)?
What is the untruth's watch (L336)?
A Closing Note — The Fact-Checker, Staffed
You now hold the watch: the signals, the detection, and the guard — with the sources cited and the ungrounded withheld. The newsroom checks the stories — and the fluent untruth doesn't print (L336).
Next: does the answer follow from the retrieved evidence? — Groundedness Evaluation (L337).