AI Quality · Engineering guide
Controlling Hallucination in Production: Detection, Grounding, Testing, and Review Workflows
Hallucination is not a defect the next model release will fix — it is a persistent property of generative systems that production teams engineer around. This guide covers the four control layers that work in practice: automated detection (self-consistency sampling, semantic entropy, verifier models), retrieval grounding with its honest limits, use-case-specific test suites, and tiered human review calibrated to the cost of a wrong answer.
In this guide · 10 steps
- 01By the numbers
- 02Why hallucination is a production-engineering problem
- 03Layer 1: Detection — knowing when the model is making things up
- 04Layer 2: Grounding — RAG as mitigation, with honest limits
- 05The benchmark landscape: what each one actually measures
- 06Layer 3: Build a test suite for your use case, not the leaderboard's
- 07Confidence scoring and abstention: engineering "I don't know"
- 08Layer 4: Human review workflows for high-stakes outputs
- 09Honest objections
- 10The read
Stop waiting for a model that does not hallucinate. Production teams control hallucination the way they control latency or downtime: with layered engineering. Four layers do the work — automated detection, retrieval grounding, a test suite built for your use case, and tiered human review — each sized to what a wrong answer actually costs when it reaches a user.
The research behind that framing is now solid. A 2025 analysis from OpenAI researchers argues that hallucinations originate as ordinary statistical errors during pretraining and then persist because training and evaluation procedures reward guessing over acknowledging uncertainty — models are optimized to be good test-takers, and confident guessing improves test scores[1]. If the incentive structure of the whole field produces confident guessers, no procurement decision or model upgrade makes the problem disappear. What a platform lead can control is the system around the model. That is what this guide is about.
1. By the numbers
Share of ChatGPT responses in the HaluEval study that fabricated unverifiable information on specific topics, per the paper's human annotation[^arxiv-halueval-2023].
HaluEval (arXiv)
Best-model truthfulness versus human performance on TruthfulQA's 817 adversarial questions — and in that study, the largest models were generally the least truthful[^arxiv-truthfulqa-2021].
TruthfulQA (arXiv)
Examples in Google DeepMind's FACTS Grounding benchmark, each pairing a user request with a context document of up to 32k tokens that the long-form response must be fully grounded in[^deepmind-facts-grounding-blog][^arxiv-facts-grounding-2025].
DeepMind FACTS Grounding
Grounding score of the top-ranked model on the initial FACTS Grounding leaderboard — meaning even the best frontier model at launch failed to stay fully grounded on roughly one in six document-grounded tasks[^deepmind-facts-grounding-blog].
DeepMind FACTS Grounding
2. Why hallucination is a production-engineering problem
The common framing — "hallucination is a model property; pick a better model" — leads teams to treat it as a procurement checkbox. That framing fails on two counts. First, scale has never been a cure: the TruthfulQA authors found that larger models in their test set were *generally the least truthful*, because false answers learned from imitating human text scale right along with everything else[3]. Second, even when a model is handed the correct source document and told to use only that, frontier models still fail. FACTS Grounding — where every prompt includes the full reference document and the only job is to answer from it — scored its launch leaderboard's best model at 83.6%[4]. The failure survives perfect retrieval.
Language models are optimized to be good test-takers, and guessing when uncertain improves test performance.
The engineering consequence: hallucination control belongs in your reference architecture, not your model-selection memo. The same way you would not buy a database and skip backups because the vendor claims durability, you do not deploy a generative model and skip the control stack because the benchmark scores look good. The rest of this guide walks the four layers in the order a request flows through them: detect, ground, test, review.
3. Layer 1: Detection — knowing when the model is making things up
Detection methods all exploit the same underlying signal: a model that actually knows something produces it consistently; a model that is confabulating produces something different each time you ask. The methods differ in what they compare, what they cost, and what access they need.
Self-consistency sampling
SelfCheckGPT formalized the sampling approach: generate multiple stochastic responses to the same prompt and check whether they agree. The premise, in the authors' words, is that "if an LLM has knowledge of a given concept, sampled responses are likely to be similar and contain consistent facts," while hallucinated facts diverge and contradict one another across samples[6]. Its production appeal is that it is zero-resource and black-box: it needs no output probabilities, no external database, and no model internals — it works against any vendor API. The paper reports higher AUC-PR for sentence-level hallucination detection than gray-box baselines that do require probability access[6]. The cost is arithmetic and unavoidable: N samples means roughly N times the inference spend and added latency, which is why teams reserve it for high-stakes outputs rather than every request.
Semantic entropy
The refinement published in Nature in 2024 fixes the weakness of naive consistency checks: two samples can disagree in wording while agreeing in meaning. Semantic entropy samples multiple answers, clusters them by *meaning* using bidirectional entailment (do the answers imply each other?), and computes uncertainty over meaning-clusters rather than token sequences[7]. High entropy over meanings flags what the authors call confabulations — fluent, arbitrary, incorrect generations. Because the method needs no task-specific labeled data and generalizes across tasks it has not seen[7], it is one of the few detection signals you can deploy on day one of a new use case, before you have collected a single labeled failure.
Verifier and judge models
The third family uses a second model to check the first — either a trained classifier that labels claims against reference material, or a frontier LLM prompted as a judge. The design lesson worth stealing comes from how FACTS Grounding itself is scored: responses pass through two phases (first, disqualify answers that dodge the user's request; second, judge whether the answer is fully grounded in the document), and the final score aggregates multiple judge models to mitigate evaluation bias[5]. DeepMind's implementation uses three frontier judges from different vendors[4]. Copy both moves: a single judge model inherits that model's blind spots, and a judge that only checks grounding will happily pass an evasive non-answer.
| Method | What it compares | Needs | Marginal cost | Best fit |
|---|---|---|---|---|
| Self-consistency sampling (SelfCheckGPT)[^arxiv-selfcheckgpt-2023] | N sampled responses against each other | API access only — zero-resource, black-box | ~N× inference per checked output | High-stakes free-form generation on any vendor API |
| Semantic entropy[^nature-semantic-entropy-2024] | Meaning-clusters of sampled answers (bidirectional entailment) | Sampling plus an entailment model | N× inference plus clustering | New use cases with no labeled failure data yet |
| Embedding similarity | Output vectors against retrieved reference vectors | Embedding model + reference corpus | Low — one embedding pass | Cheap first-pass filter in RAG pipelines; similarity is not entailment, so treat as a screen, not a verdict |
| LLM-as-judge verifier | Claims against provided evidence | A second (ideally different-vendor) model; multi-judge aggregation to mitigate bias[^arxiv-facts-grounding-2025] | One or more extra model calls | Grounding checks where evidence is in-context |
| Deterministic checks | Output against schemas, allowlists, databases | Rules and reference data | Negligible | IDs, prices, citations, entities — anything checkable by lookup |
Layer the detectors
No single detector is a verdict. The pattern that holds up in production is a funnel: deterministic checks and embedding screens on every response, sampling-based uncertainty on responses that pass but touch high-risk territory, and a multi-judge grounding check on anything that will be published or acted on without a human in the loop.
4. Layer 2: Grounding — RAG as mitigation, with honest limits
Retrieval-augmented generation attacks the root cause detection can only flag: the model answering from lossy parametric memory. The original RAG paper framed it as combining parametric memory (the model) with non-parametric memory (a retrieval index), and found that RAG models "generate more specific, diverse and factual language" than parametric-only baselines[8]. For enterprise use cases where the answers live in your own corpus — policies, contracts, product documentation, tickets — grounding is the highest-leverage single mitigation, and it brings a second benefit hallucination metrics do not capture: provenance. An answer with citations into your corpus is auditable; a parametric answer is not.
Vendor guidance converges on the same grounding disciplines. Anthropic's documentation recommends explicitly permitting the model to say "I don't know" (which it says "can drastically reduce false information"), having the model extract word-for-word quotes from long documents before reasoning over them, requiring citations for each claim with a retract-if-unsupported verification pass, and restricting the model to the provided documents rather than its general knowledge[9]. These are prompt-level controls — cheap to adopt, and they compound with architectural grounding rather than replacing it.
Now the honest limits, because grounding is routinely oversold. First, grounding shifts the failure mode rather than eliminating failure: FACTS Grounding hands the model the complete correct document, and the best launch-leaderboard model still scored 83.6%[4] — models misread, ignore, or embellish context they were given. Anthropic's own guidance closes with the same caveat: the techniques reduce hallucinations but "don't eliminate them entirely"[9]. Second, RAG adds a new failure surface — retrieval. When the retriever returns the wrong passage, a stale index version, or two conflicting documents, the model produces an answer that is impeccably grounded in the wrong evidence, and every grounding-based detector will pass it. Third, the operational bill is real: index freshness, chunking strategy, access-control filtering at retrieval time, and latency all become your problem.
Grounded ≠ correct
A grounding check verifies output-against-evidence. It cannot verify evidence-against-reality. Budget separate monitoring for retrieval quality — recall on a gold set of query-to-document pairs, index freshness alerts — or your "fully grounded" dashboard will glow green while users get confident answers sourced from last year's price list.
5. The benchmark landscape: what each one actually measures
Three benchmarks dominate hallucination conversations, and they measure genuinely different things — which matters, because a vendor quoting one of them is answering one specific question, not certifying factuality in general.
TruthfulQA (2021) measures whether a model resists reproducing human misconceptions. Its 817 questions across 38 categories — health, law, finance, politics — were crafted so that "some humans would answer falsely due to a false belief or misconception"[3]. It tests the model's parametric knowledge under adversarial pressure, with no retrieval. Its headline result — best model 58% truthful against 94% human performance, with the largest models generally least truthful[3] — dates from the GPT-3 era, so treat the specific scores as historical; the design insight, that imitation training reproduces popular falsehoods, is what endures.
HaluEval (2023) flips the task: instead of asking whether the model hallucinates, it asks whether the model can *recognize* hallucinations, using a large collection of generated and human-annotated hallucinated samples built with a sampling-then-filtering pipeline. Two findings carry into production: human annotators found about 19.5% of studied ChatGPT responses fabricated unverifiable information on specific topics, and providing external knowledge or added reasoning steps measurably helped models recognize hallucinations[2] — direct evidence for the verifier-model and grounding patterns above.
FACTS Grounding (Google DeepMind, 2024–2025) is the one that most resembles enterprise RAG work: 1,719 examples (an 860-example public split and an 859-example private split to guard leaderboard integrity), each requiring a long-form response fully grounded in a provided document of up to 32k tokens, scored by the two-phase multi-judge process described earlier, with a maintained public leaderboard[5][4]. If you run document-grounded workloads, this is the score to ask vendors about — while remembering its documents and tasks are still not yours.
| Benchmark | Introduced | What it measures | Retrieval involved? | The production question it answers |
|---|---|---|---|---|
| TruthfulQA[^arxiv-truthfulqa-2021] | 2021 | Resistance to imitated human misconceptions (817 adversarial questions, 38 categories) | No — parametric knowledge only | Will the model repeat plausible falsehoods it absorbed in training? |
| HaluEval[^arxiv-halueval-2023] | 2023 | Ability to recognize hallucinated content in generated/annotated samples | Tested with and without external knowledge | Can a model serve as a hallucination detector, and what helps it? |
| FACTS Grounding[^arxiv-facts-grounding-2025][^deepmind-facts-grounding-blog] | 2024–2025 | Full groundedness of long-form answers in a provided ≤32k-token document (1,719 examples; multi-judge) | No retrieval — the correct document is given | With perfect retrieval, does the model stay inside the evidence? |
6. Layer 3: Build a test suite for your use case, not the leaderboard's
Public benchmarks screen models; they cannot certify your deployment. Your users' phrasings, your corpus's ambiguities, and your domain's failure costs are all out of distribution for TruthfulQA and FACTS alike. The teams that keep hallucination rates flat through model swaps and prompt changes all converge on the same asset: a versioned, CI-gated test suite specific to the use case.
- Scope by failure cost, not by feature. Enumerate the output types where a fabrication causes material harm — a wrong dosage, a fabricated contract clause, an invented price — and weight the suite toward those. A uniform sample of traffic under-tests exactly the outputs that matter.
- Build a gold set from your own corpus. Question-answer pairs where every answer is tied to a specific passage in your documents. These test the happy path: correct retrieval, correct grounding, correct citation.
- Build an adversarial set of unanswerable and premise-flawed questions. Questions your corpus genuinely cannot answer, questions with false premises baked in, and near-miss entities (the discontinued SKU, the similarly named policy). The correct behavior is abstention or correction — these cases test the abstention machinery in Layer 4's sense, and they are the cases public benchmarks least resemble.
- Turn every production incident into a regression case. A hallucination that reached a user is the most valuable test input you own. Route incident reports and reviewer corrections (Layer 4) back into the suite automatically.
- Score with factuality metrics, not surface overlap. Grounding/entailment rate against the gold passage, citation validity (does the cited passage exist and support the claim), and abstention correctness on the adversarial set. N-gram overlap metrics like BLEU/ROUGE reward fluent paraphrase, which is precisely what a good hallucination looks like.
- Gate changes in CI. Model version bumps, prompt edits, retrieval-index rebuilds, and chunking changes all run the suite; thresholds are set per risk tier, and a regression blocks the deploy the same way a failing unit test does.
The unanswerable questions are the suite's crown jewels
Anyone can pass questions the corpus answers. The behavior that separates a production-safe deployment from a demo is what happens when the corpus does not contain the answer — and that behavior is invisible unless you test for it deliberately. If your suite has no questions whose correct answer is "I don't know," you are not testing hallucination; you are testing recall.
7. Confidence scoring and abstention: engineering "I don't know"
Every detection layer ultimately feeds a decision: answer, abstain, or escalate. Getting that decision right requires confidence signals you can trust, and the base signals are untrustworthy by default. The foundational calibration result is that modern deep networks — unlike their shallower predecessors — are poorly calibrated: their raw confidence scores do not match their actual correctness rates, though simple post-hoc fixes like temperature scaling (a single-parameter variant of Platt scaling) are "surprisingly effective" at repairing calibration[10]. For LLMs the situation is harder still, because token-level probabilities measure confidence in the *next word*, not in the truth of the claim — which is exactly why answer-level signals like semantic entropy, which measure uncertainty over meanings rather than tokens[7], exist.
The engineering pattern: pick a confidence signal (semantic entropy, sample agreement, judge score, or a calibrated combination), validate its calibration on *your* gold and adversarial sets, then set abstention thresholds per risk tier based on the cost asymmetry between a wrong answer and a non-answer. Below threshold, the system does not simply refuse — it routes: to a retrieval retry, to a safe templated response, or to a human queue. And track two metrics forever: abstention precision (when it said "I don't know," was the answer genuinely unknowable or wrong?) and abstention recall (of the answers that would have been wrong, how many did it catch?).
One organizational move matters as much as the math. The Kalai et al. analysis locates the root cause in scoreboards that penalize expressed uncertainty[1] — and most internal AI dashboards repeat the mistake by tracking "deflection rate" or "answer rate" as a success metric. If your team is graded on answer rate, your system will be tuned to guess. Put abstention correctness on the scorecard next to answer quality, or the incentive that produces hallucination at the field level will reproduce itself inside your org.
8. Layer 4: Human review workflows for high-stakes outputs
Human review is the control of last resort — the most reliable and the most expensive — so the entire design question is *allocation*: which outputs earn human eyes, whose eyes, and how you keep the process honest at volume. Universal manual review does not scale and, worse, decays into rubber-stamping; the workable pattern is tiered review driven by the signals from Layers 1–3.
Tier 0 — Auto-block
Deterministic failures: invalid citations, schema violations, entities that fail database lookup, policy-restricted topics. Never reaches a user or a reviewer; returns a safe fallback and logs the event.
Tier 1 — Auto-publish + sampled audit
Low-stakes outputs that pass all automated checks. A random sample (weighted toward novel query types) goes to reviewers weekly; the sample rate is a dial you tighten when audit findings rise.
Tier 2 — Detector-gated review
Outputs flagged by confidence thresholds, consistency divergence, or judge disagreement. Held from delivery (or delivered with visible caveats, per product) until a trained reviewer clears them.
Tier 3 — Mandatory expert review
Categories where failure cost is severe regardless of detector confidence — clinical, legal, financial-disclosure, contractual. Domain-expert review is a release gate, not a spot check; detectors only order the queue.
Three design details determine whether this works or becomes theater. Match reviewer expertise to tier — a generalist can audit Tier 1 summaries, but Tier 3 clinical or contractual outputs need reviewers with the domain license or authority to say no, with the reviewer's scope explicitly defined (factual accuracy, grounding, compliance — not style). Instrument the reviewers, not just the model: log every decision with timestamps and the model output as seen, measure inter-reviewer disagreement, and periodically seed the queue with known-bad outputs; a reviewer stream that approaches a 100% approval rate is not evidence of a good model, it is evidence of a rubber stamp. Close the loop: every reviewer correction is a labeled example that flows back into the test suite (Layer 3) and into threshold tuning (Layers 1–2), which is how the review budget shrinks over time instead of growing with traffic.
9. Honest objections
"The detection overhead is unaffordable." Partially true. Sampling-based detection multiplies inference cost roughly by the sample count, and multi-judge verification adds calls on top. That is why the funnel matters: deterministic and embedding checks are near-free and run on everything; the expensive detectors run only where the failure cost clears the bar. If no output in your product justifies a 5× inference premium, that is itself a finding — it means your use case is low-stakes enough for Tier 1 treatment, and you should spend the budget on the test suite instead.
"Abstention ruins the product experience." It can, if "I don't know" is a dead end. But the alternative — confident wrong answers — ruins trust, which is harder to rebuild than engagement. The design answer is that abstention is a routing event, not a refusal: retry with reformulated retrieval, fall back to search results, or hand off to a human channel. And the vendor guidance is unambiguous that permitting uncertainty is one of the cheapest effective mitigations available[9].
"Models are improving fast — why build all this scaffolding?" Model quality is genuinely rising, and some of this stack gets cheaper as it does — smaller review queues, higher thresholds. But the two structural findings argue against waiting: benchmark incentives still reward confident guessing over calibrated uncertainty[1], and even given the complete correct document, launch-leaderboard frontier models fell short of full grounding on a meaningful fraction of FACTS tasks[4]. The scaffolding is also what *tells you* when a new model is safe to swap in — without the Layer 3 suite, "the new model hallucinates less" is a vibe, not a measurement.
"Human review just becomes a rubber stamp." Unmanaged, yes — that is the default failure mode of any high-volume approval queue. The mitigations are in the workflow design above: seeded known-bad items, disagreement metrics, scoped review roles, and sample rates that respond to audit findings. A review process you do not measure is a review process you do not have.
10. The read
Treat hallucination control as a stack-selection criterion, on par with security and cost. Concretely: in procurement, ask vendors for document-grounding evidence (FACTS-style scores and citation support in the API), for access to uncertainty signals, and for how their guidance handles abstention. In architecture, budget the four layers from day one — cheap detectors everywhere, grounding wherever your corpus holds the answers, a use-case test suite as the CI gate, and tiered review sized by failure cost. In governance, put abstention correctness on the same dashboard as answer quality, so your internal incentives stop reproducing the field's. Teams that do this ship generative features into regulated and high-stakes contexts; teams that wait for the model that never hallucinates are still waiting.
How to apply this
- Classify your output types by failure cost and assign each a review tier (auto-block / sampled audit / detector-gated / mandatory expert).
- Deploy the free detectors first: schema validation, entity and citation lookups, embedding screens against retrieved sources.
- Add a sampling-based uncertainty signal (self-consistency or semantic entropy) on high-stakes outputs; it needs no labeled data or model internals.
- Use multi-judge, two-phase verification for grounding checks — never a single judge, and always screen for evasive non-answers before scoring groundedness.
- Ground answers in your own corpus wherever it holds the truth, and adopt the prompt-level disciplines: permission to say "I don't know," quote extraction, cite-and-retract verification.
- Monitor retrieval quality separately from grounding quality — a grounded answer to the wrong evidence passes every grounding check.
- Build the gold set and the unanswerable/adversarial set for your use case; score entailment, citation validity, and abstention correctness — not BLEU/ROUGE.
- Gate every model, prompt, and index change on the test suite in CI, with per-tier thresholds.
- Calibrate confidence signals on your own data before trusting thresholds; track abstention precision and recall in production.
- Instrument human review: log decisions, measure disagreement, seed known-bad outputs, and feed corrections back into the test suite.
- Remove "answer rate" as a standalone success metric anywhere it would penalize honest abstention.
- Turn every hallucination that reaches a user into a permanent regression test within a week of the incident.
Sources
Every quantitative or attributed claim above is linked to a primary source. Last verified at publication.
- [1]Why Language Models HallucinatearXiv (Kalai, Nachum, Vempala & Zhang) · · accessed
- [2]HaluEval: A Large-Scale Hallucination Evaluation Benchmark for Large Language ModelsarXiv (Li, Cheng, Zhao, Nie & Wen) · · accessed
- [3]TruthfulQA: Measuring How Models Mimic Human FalsehoodsarXiv (Lin, Hilton & Evans) · · accessed
- [4]FACTS Grounding: A new benchmark for evaluating the factuality of large language modelsGoogle DeepMind · accessed
- [5]The FACTS Grounding Leaderboard: Benchmarking LLMs' Ability to Ground Responses to Long-Form InputarXiv (Jacovi et al., Google DeepMind) · · accessed
- [6]SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language ModelsarXiv (Manakul, Liusie & Gales) · · accessed
- [7]Detecting hallucinations in large language models using semantic entropyNature (Farquhar, Kossen, Kuhn & Gal) · · accessed
- [8]Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksarXiv (Lewis et al.) · · accessed
- [9]Reduce hallucinationsAnthropic · accessed
- [10]On Calibration of Modern Neural NetworksarXiv (Guo, Pleiss, Sun & Weinberger) · · accessed