1:1 mentoring with Big Tech AI engineers
System Design

Hallucination Detection

Detect and prevent LLM hallucinations: factuality checking, grounding verification, and off-brand content filtering.

Last updated

Core25 min readFirst readYour First Agentic System

After this section you can

  • Classify a hallucination as factual, citation, reasoning, or entity, and name the detection layer that catches each type
  • Compute a detector’s daily review load from base rate, precision, and recall — flagged cases, false alarms, and leaked hallucinations — and defend the operating point in an interview
  • Build a two-layer grounding + consistency checker in stdlib Python, and state which production components (NLI cross-encoder, NER) replace the toy checks
  • Run a weekly calibration loop: sample and human-label 200 cases, recompute per-layer precision/recall, and retune thresholds after base-rate shifts
SD-10

Hallucination & Off-Brand Detection

Detect fabricated facts, fake citations, and brand-policy violations before they reach users.

Types of Hallucination

HALLUCINATION TAXONOMY
FACTUAL HALLUCINATION HIGH RISK
Model states incorrect facts with high confidence
Example: "The Eiffel Tower is 500m tall" (actual: 330m)
Risk: Users trust authoritative tone
CITATION HALLUCINATION CRITICAL
Model invents fake sources, URLs, or paper titles
Example: Cites "Smith et al. 2023, Nature" that doesn’t exist
Risk: Critical in legal/medical/academic contexts
REASONING HALLUCINATION SUBTLE
Logical steps seem plausible but contain errors
Example: Correct premises but invalid conclusion
Risk: Hardest to detect — requires domain expertise
ENTITY HALLUCINATION HIGH RISK
Wrong names, numbers, dates, or identifiers
Example: Confuses CEO names, swaps product versions
Risk: High in customer-facing applications

Related

More in System Design

Get full access to all 74+ sections with code examples, diagrams, and interactive animations.

Unlock Premium