Hallucination detection: 3 methods that work in production
Hallucination detection with grounding checks, consistency sampling, and semantic entropy: what each catches, what it costs, and why models hallucinate.
- Published
- Updated
- Reading time
- 10 min read
In short
- A hallucination is output that its sources, or the facts, do not support. Most hallucination detection methods measure the first kind, which is called faithfulness.
- Models hallucinate partly because training and benchmarks reward a confident guess over "I don't know". Grounding, quoting sources, and permission to abstain lower the rate before any check runs.
- A grounding check compares each claim in an answer with the retrieved context and is the default for retrieval-based systems. Sampling methods need no source documents, and they multiply your cost.
- An LLM judge is a model with biases of its own. Calibrate it against human labels before you trust its score.
Hallucination detection is an automated check that estimates whether a model's answer is supported. Three methods are practical today. A grounding check compares the answer with source text. Consistency sampling compares several answers with each other. Semantic entropy measures how much those answers disagree in meaning.
None of them proves an answer is true. Each gives you a score that tracks one kind of error, cheaply enough to run on real traffic.
What counts as a hallucination
A hallucination is output that is not supported by the model's sources or by fact. Those are two different standards, and the difference decides what you can detect.
Faithfulness asks whether the answer is supported by the context the model was given. Factuality asks whether the answer is true in the world. Faithfulness is checkable, because you hold the context. Factuality needs an outside source of truth.
A 2023 survey by Huang and colleagues splits both further. Factuality errors are contradictions of known facts or fabrications that cannot be verified. Faithfulness errors ignore the instruction, contradict the provided context, or contradict themselves. An earlier split from Ji and colleagues calls output that conflicts with the source intrinsic, and output the source cannot verify extrinsic.
| Type | Example | Checked against | Detection that fits |
|---|---|---|---|
| Factual contradiction | A law dated 2019 that passed in 2021 | An outside source of truth | Retrieval plus a grounding check |
| Factual fabrication | A citation to a paper that does not exist | An outside source of truth | Look up citations; sampling methods |
| Context inconsistency (intrinsic) | A 60-day refund window when the document says 30 | The context you supplied | Grounding check |
| Unsupported addition (extrinsic) | A fee the document never mentions | The context you supplied | Grounding check |
| Instruction inconsistency | An English answer to a request for French | The instruction | A code check or a judge |
Most tools measure faithfulness. Vectara's public hallucination leaderboard says so directly: it scores whether a summary is consistent with its source document, not whether the summary is correct in general.
That has a consequence. A perfectly faithful answer can be false if the retrieved document is wrong. A grounding check will pass it.
Why LLMs hallucinate
LLMs hallucinate because they are trained to produce plausible text, and because the way they are trained and graded rewards a confident guess over an admission of uncertainty. A 2025 paper by Kalai and colleagues argues that both causes are statistical, which is why a better model lowers the rate without removing it.
The paper, Why Language Models Hallucinate by Kalai and colleagues, makes two arguments.
The first is about pretraining. The paper's lower bound on hallucination is the share of facts that appear only once in the training data: if 20 percent of birthday facts appear exactly once, expect base models to hallucinate on at least 20 percent of birthdays.
The second is about grading. Most widely used benchmarks award one point for a correct answer and nothing for "I don't know". Under that scheme, guessing when unsure maximizes the expected score, so models tuned on those benchmarks learn to guess. The authors propose scoring that penalizes a wrong answer more than a blank, with the confidence target stated in the instructions.
Both arguments map onto the hallucination detection methods below. A guess about a rarely seen fact tends to change between samples, which sampling and semantic entropy look for. An error made while reading the context is what a grounding check looks for. And if nothing in your own evaluation set rewards "I don't know", nothing in your tuning will produce it.
Method 1: check each claim against the context
A grounding check splits the answer into individual claims and tests whether the retrieved context supports each one. The score is the supported share.
Ragas defines its faithfulness metric this way: the number of claims the context supports, divided by the total number of claims. TruLens calls the same idea groundedness and makes it one leg of its RAG triad.
You have three ways to run it. Ask a second model to judge each claim. Use a small classifier built for the job, such as Vectara's HHEM. Or call a managed check, such as the contextual grounding check in Amazon Bedrock Guardrails.
Use this method for any system that answers from retrieved documents, and for summarization. It costs one extra model call or one classifier pass per answer. Its blind spot is the context itself.
Method 2: sample several answers and compare them
Consistency sampling asks the model the same question several times and treats disagreement as a warning. A fact the model knows tends to appear in every sample. A fact it invented tends to change from one sample to the next.
SelfCheckGPT, published in 2023, is the reference version. It scores each sentence of an answer by how well the other samples agree with it, and it needs no external database.
Use this form of hallucination detection when there is no source text to check against, such as a model answering from its own training. The cost is the catch. Five samples means five times the output tokens for every answer you check.
Method 3: measure uncertainty over meanings
Semantic entropy samples several answers, groups them by meaning, and measures how spread out the groups are. Many small groups mean the model is guessing.
The method comes from a 2024 paper in Nature by Farquhar and colleagues. Its advance over plain consistency sampling is the grouping step. "Paris" and "It's Paris, the capital of France" land in one group, so rewording does not count as disagreement.
The authors are specific about its scope. It detects confabulations, meaning answers that are arbitrary and wrong. A model that gives the same wrong answer every time shows low entropy and passes.
| Method | Needs source text | Extra cost per answer | Catches | Blind to |
|---|---|---|---|---|
| Grounding check | Yes | One judge call or classifier pass | Claims the context does not support | Errors in the context itself |
| Consistency sampling | No | Several extra generations | Details that change between samples | Errors the model repeats every time |
| Semantic entropy | No | Several generations plus a grouping step | Arbitrary, made-up answers | Consistent errors |
Start hallucination detection with the grounding check if you have retrieved context. It is the cheapest of the three and the easiest to explain to the person who asks why an answer was flagged.
How hallucination rates are measured
Published hallucination rates come from benchmarks that fix one task and one definition. Vectara's leaderboard measures how often a model adds unsupported facts when summarizing a document. OpenAI's SimpleQA measures whether short factual answers are correct. Neither number predicts the rate on your prompts, your documents, and your users.
Vectara's leaderboard has each model summarize over 7,700 articles using only their facts, then scores the summaries with HHEM-2.3, its commercial evaluation model. It reports a hallucination rate and an answer rate for refusals. Its own caveats say it does not measure every way a model can hallucinate, and that extractive summaries score well by design.
SimpleQA contains 4,326 short, fact-seeking questions. A grader marks each answer correct, incorrect, or not attempted, which separates a wrong answer from a refusal.
| Benchmark | Task | What counts as a hallucination | Why your rate will differ |
|---|---|---|---|
| Vectara hallucination leaderboard | Summarize a document | A claim the document does not support | Your documents, lengths, and instructions differ, and extractive answers score well |
| SimpleQA | Answer a short factual question from memory | A wrong answer, counted apart from "not attempted" | Your system probably retrieves, and your users do not ask trivia |
Use public numbers to shortlist models, then measure hallucination detection scores on a few hundred of your own queries with labeled answers. Report the abstention rate next to the hallucination rate, because a model that refuses more will look like it hallucinates less. LLM evaluation covers how to build that set.
How far to trust an LLM judge
Trust an LLM judge only as far as you have measured it. A judge is a model, and it makes the same kinds of mistakes as the model it grades.
The research is consistent on this. A 2023 study by Zheng and colleagues found that a strong judge agreed with human preferences more than 80 percent of the time, and it also named three biases: favoring an answer by its position, favoring longer answers, and favoring the judge's own output. Wang and colleagues showed that reordering the candidates could change which one a judge ranked first. A 2024 paper by Panickssery and colleagues found that models recognize their own writing and rate it higher.
Five steps make a judge usable:
- Ask a yes-or-no question about one claim at a time. Avoid scores from 1 to 10.
- Pick a judge from a different model family than the generator.
- Label a couple of hundred examples by hand and measure how often the judge agrees with you.
- Repeat that measurement whenever the judge model or its prompt changes.
- Randomize the order of anything the judge compares.
Step 3 is the one that gets skipped. Without it you have a number and no idea what it means. LLM as a judge covers calibration, agreement measures, and each bias in more depth.
Reducing hallucinations vs detecting them
Reduce first, then detect what is left. Grounding the model in retrieved text, asking it to quote its sources, and allowing it to say it does not know all lower the rate before any check runs. Hallucination detection then catches the remainder. Lowering the temperature does not belong on that list.
Anthropic's guide to reducing hallucinations gives the core techniques, and they apply to any model:
| Technique | What it lowers | What it costs |
|---|---|---|
| Give explicit permission to say "I don't know" | Guessing on questions the model cannot answer | Some answerable questions go unanswered |
| Extract word-for-word quotes before answering, for long documents | Answers that drift from the text | More output tokens and latency |
| Require a supporting quote for each claim, and retract claims without one | Unsupported additions | A longer answer, or a second pass |
| Restrict the answer to the provided documents | Claims drawn from the model's general knowledge | Nothing useful when the documents miss the topic |
The guide says these techniques reduce hallucinations without eliminating them, which is why detection still runs after them.
Temperature is the common false fix. At temperature 0 the model takes its most likely token at every step. That makes the output repeatable, not better informed: a model that does not know a fact returns the same wrong answer every time. It also removes the variation that sampling-based detection depends on. Vectara's leaderboard rates were measured at temperature 0.
Where to run detection
Run hallucination detection in three places, and let each do a different job.
Offline, run it in CI against a fixed test set. A drop in the score blocks a prompt or model change before release.
Online, run it asynchronously on a sample of live traffic. Attach each score to the request's trace so you can chart quality by prompt version, model, and input size. The observability article covers the trace, and the context rot article explains why input size belongs on that chart.
Inline, run it as a blocking check only where a wrong answer is expensive, such as medical, legal, or financial output. It adds latency to every response, which the guardrails article weighs in more detail.
Frequently asked questions
What are AI hallucinations?
AI hallucinations are model outputs that are not supported by their sources or by fact, delivered as fluently as correct answers. Examples include invented citations, figures that contradict the provided document, and claims a summary adds on its own. Faithfulness hallucinations conflict with the given context. Factuality hallucinations conflict with the real world.
Why do LLMs hallucinate?
LLMs hallucinate because they generate plausible text, not verified facts, and because training and benchmarks reward a confident guess over "I don't know". A 2025 paper by Kalai and colleagues ties the rate to how often a fact appears in training data and shows that common 0-or-1 grading makes guessing the best strategy for a model that is unsure.
Can AI hallucinations be eliminated?
No current technique eliminates them. Grounding in retrieved documents, asking for supporting quotes, and allowing the model to abstain lower the rate without removing it. Plan for a residual rate: measure it on your own traffic, detect what you can, and send high-stakes answers to human review.
How do you detect hallucinations in LLM output?
Use a grounding check when you have source text: split the answer into claims and test each against the retrieved context. Without source text, sample several answers and flag disagreement, or use semantic entropy. Run checks in CI, on sampled live traffic, and inline only where a wrong answer is expensive.
Does setting temperature to 0 stop hallucinations?
No. Temperature 0 makes the model pick its most likely token at every step, which makes answers repeatable but not more accurate. A model that does not know a fact gives the same wrong answer each time, and sampling-based hallucination detection loses the variation it relies on.
What is semantic entropy?
Semantic entropy is a hallucination detection method from a 2024 Nature paper by Farquhar and colleagues. It samples several answers to the same question, groups the answers that mean the same thing, and measures how spread out the groups are. High entropy signals an arbitrary, made-up answer. It cannot catch an error the model repeats consistently.
Sources
- 01Why Language Models HallucinatearXiv:2509.04664
- 02A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open QuestionsarXiv:2311.05232
- 03Survey of Hallucination in Natural Language GenerationarXiv:2202.03629
- 04FaithfulnessRagas docs
- 05Ragas: Automated Evaluation of Retrieval Augmented GenerationarXiv:2309.15217
- 06The RAG triadTruLens docs
- 07Hallucination leaderboardGitHub, Vectara
- 08Measuring short-form factuality in large language modelsarXiv:2411.04368
- 09SelfCheckGPT: Zero-Resource Black-Box Hallucination Detection for Generative Large Language ModelsarXiv:2303.08896
- 10Detecting hallucinations in large language models using semantic entropyNature, 2024
- 11Reduce hallucinationsClaude API docs
- 12Judging LLM-as-a-Judge with MT-Bench and Chatbot ArenaarXiv:2306.05685
- 13Large Language Models are not Fair EvaluatorsarXiv:2305.17926
- 14LLM Evaluators Recognize and Favor Their Own GenerationsarXiv:2404.13076