Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

A hallucination is fluent, confident, and wrong, which is why it survives review. Here are the five detection methods teams actually use, what each one measures, and the failure each one cannot see.

Samyak Goyal
Author

Saurabh Prakash
Reviewer
Last Updated on: August 27, 2026
The hard part is not that models get things wrong. It is that a fabricated answer is written in exactly the same register as a correct one, so nothing about the text itself tells a reviewer which is which.
Every detection method below exists to supply the signal the text does not carry on its own. They differ in what evidence they use, what they cost, and which failures they are structurally blind to.
TL;DR
A hallucination is model output that is not supported by the model's inputs or by any source it had access to, regardless of whether it happens to be true. The defining property is the missing support, not the falsehood.
That distinction decides which fix applies. An answer that faithfully repeats a wrong document is a data problem, and no amount of generation-side detection will catch it. An answer the model composed with nothing behind it is a generation problem, and that is what the methods below are built for.
The research literature narrows the term further. In Detecting hallucinations in large language models using semantic entropy, published in Nature, Farquhar, Kossen, Kuhn and Gal target a subset they call confabulations, which they define as "arbitrary and incorrect generations". The word does useful work: it separates output that varies randomly between runs from output that is consistently wrong because the model learned something false.
Four properties make this harder than ordinary output validation, and each one rules out an obvious approach.
Five approaches account for most production deployments. They are not alternatives so much as layers with different costs.
| Method | Evidence it uses | Cost per output | Needs a reference? |
|---|---|---|---|
| Deterministic checks | Schema, required fields, formats, forbidden claims, citation resolves to a real document. | Negligible | No |
| Groundedness scoring | The retrieved context. Scores whether each claim is entailed by the documents supplied. | Low to moderate | No, but needs retrieval |
| Semantic entropy | Disagreement in meaning across several samples of the same prompt. | High, several generations | No |
| LLM-as-a-judge | A second model's verdict against a rubric, reference, or context. | Moderate, one call | Optional |
| Fine-tuned detector | A trained classifier's judgment of whether a claim is supported. | Low | No, at inference |
The ordering matters more than the choice. Deterministic checks are free and catch the failures that break downstream code, so they belong first regardless of what else you run. Our guide to LLM evaluation covers assembling the datasets these methods score against.
Groundedness is the degree to which a generated answer is supported by the source material supplied to the model. A grounded answer can be traced back to the retrieved documents; an ungrounded one cannot, whether or not it is true.
It is the most useful metric available for retrieval systems, because it converts an unanswerable question into an answerable one. Instead of asking whether a claim is true of the world, which needs omniscience, it asks whether the claim follows from the passages you handed over, which needs only the passages.
Scoring usually decomposes the answer into individual claims and checks each against the context, using an entailment model or a judge prompt. Three details decide whether the score means anything:
Groundedness says nothing about answers with no retrieval behind them, which is its structural limit rather than a tuning problem. For the retrieval half of the same system, our guide to RAG testing covers evaluating what the retriever returned before the generator ever sees it.
Sample the same prompt several times, group the answers by what they mean rather than how they are worded, and measure how spread out those meaning groups are. Wide spread indicates the model is not constrained by anything, which is the condition under which it fabricates.
The Nature paper describes the mechanism as computing "uncertainty at the level of meaning rather than specific sequences of words", which is what separates it from ordinary token-probability confidence. Two answers can share almost no vocabulary and mean the same thing, and a word-level measure treats that as disagreement when it is agreement.
prompt: "Which year did the Mariner 4 flyby return its first images?"
sample 1 -> "1965" |
sample 2 -> "In 1965." | one meaning cluster -> low entropy -> trust
sample 3 -> "Nineteen 65" |
prompt: "Which paper first proposed the Zhang-Liu consistency bound?"
sample 1 -> "Zhang et al., 2016" |
sample 2 -> "Liu and Chen, 2019" | three clusters -> high entropy -> flag
sample 3 -> "A 2021 NeurIPS paper" |The property that makes it deployable is independence from your task. The authors report that the method "works across datasets and tasks without a priori knowledge of the task, requires no task-specific data and robustly generalizes to new tasks not seen before", so it needs no labelled examples and no reference answers.
The cost is the obvious limit. Several generations per checked output is affordable on a sampled slice or an offline evaluation set, and rarely affordable on every production response, which is why it tends to sit behind the cheaper layers rather than in front of them.
Note: TestMu AI's Agent Testing evaluates AI agents and chatbots against defined expectations rather than exact string matches, so an unsupported answer is caught by the check that was meant to catch it. Try TestMu AI free!
Every method is blind to something by construction, and knowing which blindness you are buying is the whole of the design decision.
| Method | What it cannot see | Pair it with |
|---|---|---|
| Deterministic checks | Anything semantic. A perfectly formatted answer that is entirely invented passes every one of them. | Groundedness or a judge |
| Groundedness scoring | Claims with no retrieval behind them, and cases where the retrieved document is itself wrong. | Source quality checks |
| Semantic entropy | Confident, consistent errors. A model reliably wrong every time shows low entropy and looks trustworthy. | Groundedness or a reference set |
| LLM-as-a-judge | Its own blind spots. A judge sharing a family with the generator tends to share its mistakes and its preferences. | A different model family |
| Fine-tuned detector | Failure modes outside its training distribution, including ones your product introduced last month. | Periodic retraining |
The row worth staring at is semantic entropy against consistent errors. Sampling methods measure whether the model is sure, not whether it is right, and a model can be reliably, confidently, repeatedly wrong. That is precisely the failure a groundedness check catches and a consistency check cannot.
The judge row has a similar trap. Our guide to LLM-as-a-judge covers the bias and reliability work that has to happen before a judge's verdict is worth gating on.
Cheapest first, and route by risk rather than applying one policy to every response.
Step five is the one teams omit, and it is the same discipline that applies to any check you intend to trust. Our write-up on prompt evaluation covers baselining a check so a change to it cannot silently degrade what it catches.
Take the single highest-risk answer your product generates and write down what evidence would have to exist for that answer to be trustworthy. If the honest answer is a retrieved passage, you need groundedness. If it is that the model should be sure, you need sampling. If it is both, you have just designed your detection layer.
The one thing not to carry away is that any single method covers you. Sampling misses the confidently wrong, groundedness misses what was never retrieved, and judges inherit the failings of whatever model you picked. Coverage comes from layering methods whose blind spots do not overlap.
For running these checks against conversational systems rather than static outputs, TestMu AI's Agent Testing evaluates agent and chatbot behaviour against expectations you define, and the getting started with Agent Testing documentation covers defining those expectations for a first agent. Our guide to LLM testing covers the wider application layer these detectors sit inside.
Author
Samyak Goyal is a Senior Member of Technical Staff at TestMu AI engineering Kane CLI, the command-line tool that runs browser automation from the terminal, where a flow described in natural language executes in a real Chrome browser and returns pass or fail with shareable proof. He is a backend engineer with 4+ years of experience, previously an SDE at Innovaccer, where he built APIs, introduced Kafka, and cut deployment from weeks to hours. Samyak also builds multi-agent systems, skill-orchestration frameworks, and a personal copilot that indexes 200+ microservice repositories.
Reviewer
Saurabh Prakash is an Engineering Manager at TestMu AI (formerly LambdaTest), where he leads engineering on agentic AI development and scalable system architecture for the quality engineering platform. He has also contributed to Test at Scale, the company's open-source test intelligence platform. He brings over 9 years of experience across Node.js, Java, Spring, MVC, data structures, algorithms, and scalable system design, with earlier roles as SDE 2 at Zomato, Senior Software Engineer at LogicHub, and Software Development Engineer at Directi. Saurabh holds a B.Tech in Computer Science and Engineering from Delhi Technological University.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance