PRACTICAL GUIDE / llm hallucination detection

LLM Hallucination Detection: Methods, Metrics, and Tools

LLM hallucination detection using judges, NLI, semantic entropy, retrieval-grounded verification, calibrated metrics, and practical tools.

By The Testing AcademyUpdated July 17, 20269 min read
All field guides
In this guide14 sections
  1. Define Hallucination Against a Truth Standard
  2. Faithfulness and Groundedness Mean the Same Construct
  3. Map the Hallucination Detection Pipeline
  4. Method 1: LLM-as-a-Judge
  5. Method 2: NLI and Entailment Grounding Checks
  6. Method 3: Semantic Entropy
  7. Method 4: Retrieval-Grounded Claim Verification
  8. Tools for LLM Hallucination Detection
  9. Build a Practical Detection Dataset
  10. Implement a Layered Detection Pipeline
  11. Calibrate Metrics and Release Thresholds
  12. Hallucination Detection Review Checklist
  13. Frequently Asked Questions
  14. What is an LLM hallucination?
  15. Are faithfulness and groundedness different metrics?
  16. Can an LLM reliably detect another LLM's hallucinations?
  17. What is semantic entropy in hallucination detection?
  18. Which tools support LLM hallucination evaluation?
  19. What should block a release?
  20. Make Unsupported Claims Inspectable

What you will learn

  • Define Hallucination Against a Truth Standard
  • Faithfulness and Groundedness Mean the Same Construct
  • Map the Hallucination Detection Pipeline
  • Method 1: LLM-as-a-Judge

LLM hallucination detection finds claims that lack evidence required by the application. A creative assistant may invent fiction, while a support bot must not invent a refund rule. A RAG answer can be true in the wider world and still be unfaithful to supplied context.

Detection is not one magic score. Capture the answer and evidence, extract claims, apply complementary checks, calibrate with human labels, and gate meaningful failures.

For a focused implementation of the core RAG construct, read how to evaluate faithfulness and groundedness. This article builds the broader detection system around it.

Define Hallucination Against a Truth Standard

Define which evidence may support an answer:

  • Provided context: Every factual claim must be entailed by the retrieved chunks.
  • Reference answer: The output must agree with a curated expected answer while allowing valid paraphrases.
  • Authoritative source: Claims must be verifiable against a trusted, versioned knowledge base or tool result.
  • World knowledge: Claims may require external verification, which is harder to make complete and current.
  • System state: Claims about bookings, balances, permissions, or actions must match the system of record.

Do not mix standards silently. Context faithfulness cannot prove the context is correct. A reference can penalize valid alternatives, and search can miss or retrieve stale evidence. Record the standard per case.

Failures include unsupported additions, contradictions, fabricated citations, wrong attribution, entities, numbers, dates, and overstated evidence. For agents, verify downstream actions too.

Faithfulness and Groundedness Mean the Same Construct

Faithfulness and groundedness are naming differences, not separate dimensions. RAGAS and DeepEval use faithfulness; TruLens and Azure use groundedness. Both ask whether output claims are supported by context.

Keep related metrics separate:

MetricQuestion it answersWhat it does not prove
Faithfulness or groundednessAre output claims supported by provided context?That the context is complete or correct
Context precisionAre the most useful retrieved items ranked without excessive noise?That all necessary evidence was retrieved
Context recallDid retrieval include the evidence needed for the expected answer?That the model used the evidence faithfully
Answer relevancyDoes the response address the user's question?That its claims are supported

An answer can be relevant and unfaithful, or faithful to irrelevant context. Diagnose retrieval and generation separately.

Map the Hallucination Detection Pipeline

The pipeline below makes evidence provenance visible. Every verdict should link back to the exact claim, evidence span, evaluator, and version that produced it.

Animated field map

LLM Hallucination Detection Field Map

A layered pipeline for turning an LLM output into reviewable claim-level evidence.

  1. 01 / capture run

    Capture Run

    Store input, output, context, tools, and versions.

  2. 02 / extract claims

    Extract Claims

    Split factual assertions into atomic units.

  3. 03 / find evidence

    Find Evidence

    Attach source spans and controlling state.

  4. 04 / layered verdict

    Layered Verdict

    Combine rules, NLI, judges, and uncertainty.

  5. 05 / risk decision

    Risk Decision

    Gate, review, or monitor by severity.

Method 1: LLM-as-a-Judge

An LLM judge can extract claims, compare evidence, classify support, and explain its verdict. Require structured claim, status, evidence ID, contradiction reason, and confidence. Include the evidence so the judge does not rely on hidden knowledge.

Calibrate the rubric, model, and prompt on blinded human labels. Measure false passes and failures for negation, numbers, dates, partial support, tables, and conflicts. Recalibrate after changes.

Use multiple judges only when disagreement has a defined action. Route severe claims and disagreements to a domain reviewer.

Method 2: NLI and Entailment Grounding Checks

NLI models classify whether evidence entails, contradicts, or is neutral toward a claim. Their narrow claim-level task can suit high-volume screening.

Long context may need chunking, and claims can span chunks. Neutral often means unsupported, not false. Domain terms, numbers, and tables can reduce reliability. Calibrate thresholds and preserve support and contradiction evidence.

Use deterministic checks for identifiers, citations, dates, amounts, schemas, and permissions. A refund claim should be verified in the authorized order system.

Method 3: Semantic Entropy

Semantic entropy samples answers, groups equivalent meanings, and measures probability across those groups. Meaningfully different answers indicate more uncertainty than varied wording with one meaning.

Use it to route unstable cases for review, not as proof of falsehood. A model can be consistently wrong, and some questions allow several answers.

Record model, prompt, sampling, sample count, clustering, and threshold. Apply repeated generation to uncertain or high-risk slices to control cost.

Method 4: Retrieval-Grounded Claim Verification

Retrieval-grounded verification splits an answer into claims, finds evidence, and assigns supported, contradicted, or insufficient-evidence status. It shows exactly what failed.

A practical verifier should:

  1. Capture the exact chunks that the generator received.
  2. Split compound statements so one supported clause cannot hide one unsupported clause.
  3. Link each claim to evidence spans and source identifiers.
  4. Check direct contradiction before accepting broad topical similarity.
  5. distinguish insufficient evidence from proven falsehood.
  6. Aggregate claim results with severity-aware rules.

Evaluate retrieval too. Missing sources indicate context-recall work; present but ignored evidence points to the generator, prompt, ordering, or answer policy.

Tools for LLM Hallucination Detection

ToolUseful roleEvidence to preserveHonest limitation
DeepEvalFaithfulness and custom LLM evaluation in test workflowsTest case, retrieval context, score, reason, model and thresholdMany semantic metrics depend on a judge and require calibration
RAGASRAG metrics including faithfulness, context precision, context recall, and answer relevancyDataset schema, metric config, evaluator, per-case resultAn aggregate metric can hide critical slices
promptfooDeclarative prompt and model comparisons, assertions, and CI evaluationConfig, provider versions, outputs, assertion resultsConfiguration does not create a valid truth standard by itself
TruLensGroundedness plus context and answer relevance with application tracesTrace, selectors, context, feedback implementation, resultFeedback quality depends on selected evidence and evaluator
LangSmith evalsDataset experiments, evaluators, traces, and comparisonDataset version, experiment, trace, evaluatorHosted workflow and tracing choices must fit privacy requirements
OpenAI EvalsEvaluation definitions, datasets, graders, and repeatable runsEval definition, sample, grader, result, modelA generic grader must still be adapted to application risk

Choose by application language, trace format, CI, and privacy. See the DeepEval tutorial, RAGAS guide, and promptfoo tutorial.

Build a Practical Detection Dataset

Use critical questions, redacted failures, expert examples, and reviewed synthetic edges. Include support, contradiction, unanswerable, stale, conflicting, distractor, numeric, multi-hop, and fabricated-citation cases.

Store case ID, input, context and source IDs, output, claims, human labels, severity, abstention, locale, and provenance. Separate development and holdout sets.

Weight risk. A rare unsupported dosage, amount, access decision, or irreversible action outweighs harmless wording errors. Gate critical slices separately.

Implement a Layered Detection Pipeline

Use a sequence that spends the cheapest reliable evidence first:

YAML
hallucination_gate:
  capture: [input, output, retrieved_context, tool_results, versions]
  deterministic_checks: [schema, citation_id, amount, permission, prohibited_claim]
  claim_verification: [nli_entailment, llm_judge]
  uncertainty_signal: semantic_entropy_on_selected_cases
  outcomes: [pass, fail, needs_human_review]
  block_on: [unsupported_critical_claim, contradiction, fabricated_citation]

Validate structure and exact facts, then verify claims with NLI or a judge. Apply entropy selectively. Route severe failures, missing evidence, and disagreements to human review.

Store claim verdicts, not only an answer score. An aggregate can hide one catastrophic unsupported statement, so add severity and fabricated-citation rules.

Calibrate Metrics and Release Thresholds

Do not copy default thresholds. Use labeled calibration data, price false passes and failures, and inspect confusion by risk slice.

Version application, retrieval, context, judge, NLI, sampling, and metric components. Compare candidates on frozen cases.

Monitor privacy-safe production samples and promote confirmed failures into regression with stable expected outcomes.

Hallucination Detection Review Checklist

  • Define the permitted truth standard for every use case.
  • State that faithfulness and groundedness are the same construct.
  • Keep context precision, context recall, and answer relevancy separate.
  • Capture exact retrieved context and tool results used by the application.
  • Split outputs into atomic, reviewable factual claims.
  • Preserve evidence spans and distinguish contradiction from insufficient evidence.
  • Combine deterministic checks with calibrated NLI or LLM judges.
  • Use semantic entropy as uncertainty evidence, not proof of falsehood.
  • Label high-risk, unanswerable, stale, conflicting, and multi-hop cases.
  • Version models, prompts, contexts, evaluators, data, and thresholds.
  • Gate severe claims independently of aggregate scores.
  • Route evaluator disagreement and missing evidence to human review.

Frequently Asked Questions

What is an LLM hallucination?

An LLM hallucination is an output claim that is unsupported by the evidence or truth standard required for the task. In RAG, the operational test usually asks whether each answer claim is supported by the retrieved context.

Are faithfulness and groundedness different metrics?

They are different names for the same construct: whether output claims are supported by the provided context. RAGAS and DeepEval commonly use faithfulness, while TruLens and Azure commonly use groundedness.

Can an LLM reliably detect another LLM's hallucinations?

An LLM judge can evaluate nuanced claims at scale, but it is not an unquestionable oracle. Calibrate it against expert labels, require evidence and reasons, control judge versions, and route severe or disputed cases to humans.

What is semantic entropy in hallucination detection?

Semantic entropy estimates uncertainty by sampling multiple answers, grouping answers with the same meaning, and measuring how dispersed the probability is across those meaning groups. High uncertainty is a review signal, not direct proof of falsehood.

Which tools support LLM hallucination evaluation?

DeepEval, RAGAS, promptfoo, and TruLens support useful evaluation workflows. LangSmith evals and OpenAI Evals are also current framework options. Choose by data model, evaluator control, tracing, CI, privacy, and reporting needs.

What should block a release?

Block unsupported high-risk claims, contradictions with controlling evidence, fabricated citations, unsafe actions based on unsupported claims, and severe regressions in critical slices. Calibrate numerical thresholds on labeled data rather than copying defaults.

Make Unsupported Claims Inspectable

Good LLM hallucination detection does not merely label an answer bad. It identifies the exact unsupported claim, shows the evidence considered, records evaluator uncertainty, and assigns an action based on severity. That evidence makes failures debuggable and release decisions defensible.

Use the existing LLM hallucination detection overview for additional context, then compare evaluation designs in the /battles arena.

// LIVE COURSE / THE TESTING ACADEMY

AI Tester Blueprint

Master GenAI, AI Agents, MCP, RAG, CrewAI. Build 23+ real AI projects.

From the instructor behind this guide.

AI testing roles are up 180% and pay 12-22 LPA. 12+ weeks / 65+ live hrs / Sat-Sun 8:30 AM IST.

Code PROMODE / 10% offJoin the batch

The Testing Academy editorial desk

Practical QA guidance built around test evidence, production tradeoffs, and interview-ready explanations.

Published July 17, 2026 / Reviewed July 17, 2026

PRIMARY REFERENCES

Verify the details at the source

QABattle guides are practical explanations. Product behavior, standards, and APIs can change, so use these primary references for the canonical details.

  1. 01
    Official deepeval.com reference

    deepeval.com

    Primary documentation selected and verified for the claims in this guide.

  2. 02
    Official docs.ragas.io reference

    docs.ragas.io

    Primary documentation selected and verified for the claims in this guide.

  3. 03
    Official trulens.org reference

    trulens.org

    Primary documentation selected and verified for the claims in this guide.

  4. 04
    Evaluation best practices

    OpenAI

    Official guidance for task-specific datasets, graders, evaluation design, and continuous iteration.

FAQ / QUICK ANSWERS

Questions testers ask

What is an LLM hallucination?

An LLM hallucination is an output claim that is unsupported by the evidence or truth standard required for the task. In RAG, the operational test usually asks whether each answer claim is supported by the retrieved context.

Are faithfulness and groundedness different metrics?

They are different names for the same construct: whether output claims are supported by the provided context. RAGAS and DeepEval commonly use faithfulness, while TruLens and Azure commonly use groundedness.

Can an LLM reliably detect another LLM's hallucinations?

An LLM judge can evaluate nuanced claims at scale, but it is not an unquestionable oracle. Calibrate it against expert labels, require evidence and reasons, control judge versions, and route severe or disputed cases to humans.

What is semantic entropy in hallucination detection?

Semantic entropy estimates uncertainty by sampling multiple answers, grouping answers with the same meaning, and measuring how dispersed the probability is across those meaning groups. High uncertainty is a review signal, not direct proof of falsehood.

Which tools support LLM hallucination evaluation?

DeepEval, RAGAS, promptfoo, and TruLens support useful evaluation workflows. LangSmith evals and OpenAI Evals are also current framework options. Choose by data model, evaluator control, tracing, CI, privacy, and reporting needs.

What should block a release?

Block unsupported high-risk claims, contradictions with controlling evidence, fabricated citations, unsafe actions based on unsupported claims, and severe regressions in critical slices. Calibrate numerical thresholds on labeled data rather than copying defaults.