Inferensys

Prompt

Hallucination Detection Eval Prompt Template

A practical prompt playbook for using Hallucination Detection Eval Prompt Template in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the right scenarios for deploying a claim-by-claim hallucination detection eval, and recognize when it's the wrong tool for the job.

This prompt is designed for RAG and summarization teams who need to verify the factual accuracy of AI-generated text against a set of provided source documents. It instructs an LLM to act as an evaluator, decomposing a generated answer into individual claims and checking each one for support in the evidence. The output is a structured, claim-by-claim verification report that flags unsupported statements, fabricated details, and contradictions with the source material. Use this prompt as part of your regression testing suite to catch hallucination regressions before they reach production, or embed it in your CI/CD pipeline as a quality gate for any system where factual grounding is non-negotiable.

This prompt is ideal when you have a closed-world assumption: the source documents provided in [CONTEXT] represent the complete universe of acceptable evidence. It works best for extractive or abstractive summarization, RAG-based Q&A, and document-grounded content generation. The evaluator will flag any claim that cannot be directly attributed to the provided sources, making it particularly effective for catching fabricated statistics, invented quotes, and plausible-sounding but unsupported assertions. For best results, pair this with a golden dataset of known hallucinations and correct answers so you can measure both precision (are flagged claims actually unsupported?) and recall (are all hallucinations caught?).

Do not use this prompt when the generated text is expected to contain novel reasoning, creative synthesis, or external knowledge beyond the provided sources—the evaluator will incorrectly flag legitimate inferences as hallucinations. It is also unsuitable for evaluating stylistic qualities, tone, or user experience; this prompt checks only factual grounding. For open-ended generation tasks, prefer a reference-free evaluation prompt. For tasks requiring both factual and qualitative assessment, combine this with a multi-axis rubric scorer. Always require human review for high-stakes domains like healthcare, legal, or finance, where a missed hallucination could cause real harm. The LLM judge itself can hallucinate, so run this eval multiple times and check for score stability before trusting a single pass.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Hallucination Detection Eval Prompt Template delivers reliable verification and where it introduces risk. Use these cards to decide if this eval harness fits your RAG or summarization pipeline before integrating it into your CI/CD gates.

01

Good Fit: Claim-Level Factual Verification

Use when: you need to verify every factual claim in a generated summary or RAG answer against a provided source document. Guardrail: The prompt template produces a claim-by-claim report with evidence grounding checks, making it ideal for regulated or high-stakes content where unsupported statements are unacceptable.

02

Bad Fit: Open-Ended Creative Generation

Avoid when: evaluating creative writing, brainstorming, or subjective analysis where there is no single source of truth. Guardrail: The hallucination detector will flag stylistic choices and legitimate interpretations as unsupported claims, producing false positives that erode trust in the eval harness.

03

Required Inputs: Source-Output Pairing

Risk: Running the eval without a complete, authoritative source document produces meaningless results. Guardrail: The prompt requires both [SOURCE_DOCUMENT] and [GENERATED_OUTPUT] as inputs. Implement a pre-flight check that rejects eval runs where the source is truncated, missing, or from a different context than the output.

04

Operational Risk: Judge Hallucination

Risk: The LLM judge itself can hallucinate when evaluating claims, especially when source documents are long or ambiguous. Guardrail: Add a self-consistency check by running the eval twice with shuffled claim order. Flag outputs where the judge disagrees with itself as requiring human review before blocking a release.

05

Operational Risk: Source-Output Misalignment

Risk: The eval may flag claims as unsupported when the source document is incomplete, outdated, or covers a different scope than the output. Guardrail: Include a preliminary relevance check that verifies the source document actually addresses the query before running hallucination detection. Abort the eval with a clear diagnostic if coverage is below threshold.

06

Operational Risk: Confidence Threshold Drift

Risk: Over time, the LLM judge may become more lenient or strict, causing pass/fail thresholds to drift without any prompt change. Guardrail: Maintain a golden set of 20-30 known hallucination and non-hallucination examples. Run them weekly and alert if the judge's accuracy drops below 95% or if systematic bias toward leniency or strictness emerges.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for detecting hallucinations in AI-generated text by verifying claims against source evidence.

This prompt template is designed to be copied directly into your evaluation harness. It instructs an LLM judge to decompose a generated response into individual claims, then verify each claim against provided source context. The output is a structured report that flags unsupported statements, fabricated details, and source contradictions. Use this as the core instruction set for your hallucination detection eval step before shipping RAG or summarization features.

text
You are an expert fact-checker evaluating AI-generated text for hallucinations. Your task is to verify whether every factual claim in the generated response is supported by the provided source context.

## INPUT

**Generated Response:**
[RESPONSE]

**Source Context:**
[SOURCE_CONTEXT]

## INSTRUCTIONS

1. Decompose the Generated Response into a list of discrete, verifiable factual claims. Ignore opinions, stylistic phrasing, and grammatical structures.
2. For each claim, search the Source Context for direct supporting evidence, indirect supporting evidence, or contradictions.
3. Classify each claim into exactly one of these categories:
   - **SUPPORTED**: The claim is directly stated in or can be directly inferred from the Source Context.
   - **UNSUPPORTED**: The claim is not present in the Source Context and cannot be inferred from it. This is a potential hallucination.
   - **CONTRADICTED**: The claim directly conflicts with information in the Source Context.
4. For SUPPORTED claims, include the exact quote or passage from the Source Context that supports it.
5. For UNSUPPORTED claims, note whether the claim is plausible but unverifiable, or likely fabricated.
6. For CONTRADICTED claims, include the conflicting evidence from the Source Context.
7. Calculate a **Groundedness Score** as: (Number of SUPPORTED claims) / (Total number of claims). Express as a percentage.

## OUTPUT FORMAT

Return a valid JSON object with this exact schema:

{
  "groundedness_score": number,
  "total_claims": number,
  "supported_claims": number,
  "unsupported_claims": number,
  "contradicted_claims": number,
  "claims": [
    {
      "claim_text": "string",
      "classification": "SUPPORTED" | "UNSUPPORTED" | "CONTRADICTED",
      "source_evidence": "string or null",
      "notes": "string"
    }
  ],
  "overall_assessment": "string"
}

## CONSTRAINTS

- Do not classify stylistic choices, tone, or formatting as claims.
- If the Generated Response contains no factual claims, return an empty claims array with a groundedness_score of 100 and note this in the overall_assessment.
- If the Source Context is empty or irrelevant, classify all factual claims as UNSUPPORTED.
- Be strict: if evidence is missing, do not assume it exists elsewhere.

To adapt this template, replace [RESPONSE] with the AI-generated text under evaluation and [SOURCE_CONTEXT] with the retrieved passages, document excerpts, or knowledge base entries that should ground the response. For RAG systems, [SOURCE_CONTEXT] is typically the chunks returned by your retriever. For summarization, it is the original document. If your eval harness requires a different output schema, modify the JSON structure but preserve the claim-level granularity—this is what makes the report actionable. Always run this eval against a golden dataset with known hallucinations before relying on it in CI/CD.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Hallucination Detection Eval Prompt Template. Each placeholder must be populated before the prompt can produce a reliable claim-by-claim verification report.

PlaceholderPurposeExampleValidation Notes

[RESPONSE_TEXT]

The model-generated text to evaluate for hallucination

The Acme 3000 processor achieves 4.2 TFLOPS and was released in Q3 2023.

Must be non-empty string. Truncate if over 32k tokens to avoid judge degradation. Strip trailing whitespace before injection.

[SOURCE_CONTEXT]

The ground-truth reference material the response should be grounded in

Product spec v2.1: Acme 3000 released Q4 2023, rated at 3.8 TFLOPS peak.

May be null if evaluating closed-book generation. When present, each claim must be checked against this context. Validate encoding is UTF-8.

[CLAIM_EXTRACTION_MODE]

Controls whether the eval prompt extracts claims first or expects pre-extracted claims

auto

Must be one of: auto, manual. In auto mode, the prompt extracts atomic claims from [RESPONSE_TEXT] before verification. In manual mode, [PRE_EXTRACTED_CLAIMS] is required.

[PRE_EXTRACTED_CLAIMS]

Pre-segmented claims when [CLAIM_EXTRACTION_MODE] is manual

["Acme 3000 achieves 4.2 TFLOPS", "Released in Q3 2023"]

Required when [CLAIM_EXTRACTION_MODE] is manual. Must be a JSON array of claim strings. Null allowed when mode is auto. Validate array is non-empty if provided.

[VERIFICATION_STRICTNESS]

Threshold for flagging unsupported or contradictory claims

strict

Must be one of: lenient, moderate, strict. Lenient allows reasonable inference from context. Strict requires explicit source support. Moderate permits well-supported implications. Affects false-positive rate.

[OUTPUT_SCHEMA]

The expected JSON structure for the verification report

See output-contract table for field definitions

Must be a valid JSON Schema object or reference to a named schema. Validate that schema includes required fields: claim_id, claim_text, verdict, evidence, confidence. Reject if schema is malformed.

[CONFIDENCE_THRESHOLD]

Minimum confidence score for a verdict to be considered reliable

0.7

Float between 0.0 and 1.0. Claims with confidence below this threshold should be flagged for human review. Default 0.7. Lower values increase false positives; higher values increase missed hallucinations.

[MAX_CLAIMS]

Upper bound on claims to evaluate in a single run

50

Integer between 1 and 200. Prevents runaway token usage on long responses. If response yields more claims, truncate and note in report metadata. Validate as positive integer.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the hallucination detection eval prompt into an automated QA pipeline with validation, retries, and human review gates.

The hallucination detection eval prompt is not a one-off manual check; it is a programmatic component of a regression testing harness. Wire it into your CI/CD pipeline or a scheduled batch job that runs against every RAG or summarization output before release. The harness must supply the prompt with a structured [INPUT] containing the original query, the generated text, and the retrieved context or source documents. The model choice matters: use a capable instruction-following model (e.g., GPT-4, Claude 3.5 Sonnet) as the judge, and pin the model version to avoid judge drift across eval runs. If your application is high-stakes (healthcare, legal, finance), route all outputs flagged as containing unsupported claims to a human review queue before the eval result is considered final.

Build a validation layer around the prompt's output. The expected output is a JSON object with a claims array, where each claim has claim_text, verdict (one of supported, unsupported, contradicted, unverifiable), evidence_source, and confidence. Before accepting the eval result, validate that the JSON parses correctly, that every claim from the generated text is accounted for, and that no verdict values fall outside the allowed enum. If validation fails, retry the eval prompt once with the validation error message appended to the [CONSTRAINTS] field. Log every eval result—including raw model output, parse errors, and retry counts—to your observability platform for trace analysis. For RAG systems, cross-reference the evidence_source fields against your actual retrieved document IDs to catch cases where the judge hallucinates source references.

Set explicit pass/fail thresholds based on your risk tolerance. For example, a single contradicted claim or more than two unsupported claims might trigger an automatic failure and block the release. Use the confidence scores to weight findings: low-confidence flags should still surface for review but might not block deployment if all high-confidence verdicts are clean. Run the eval prompt against a golden dataset of known hallucinations and known faithful outputs to calibrate your thresholds before relying on it in production. Avoid treating the judge's output as ground truth—it is a signal that reduces, but does not eliminate, the need for spot-checking and human oversight in regulated domains.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the hallucination detection eval report. Use this contract to parse and gate the LLM's JSON response before accepting a verdict.

Field or ElementType or FormatRequiredValidation Rule

verdict

string enum: ["FULLY_SUPPORTED", "PARTIALLY_SUPPORTED", "UNSUPPORTED", "CONTRADICTED"]

Must match one of the four enum values exactly. Reject on unknown verdicts.

confidence_score

number (0.0 to 1.0)

Must be a float between 0 and 1 inclusive. Reject if confidence is above 0.95 when verdict is UNSUPPORTED or CONTRADICTED.

claims

array of objects

Must be a non-empty array. Reject if no claims are extracted from the [TARGET_TEXT].

claims[].claim_id

string

Must be unique within the claims array. Use a simple incrementing ID like "C1", "C2".

claims[].claim_text

string

Must be a verbatim or near-verbatim extractable statement from [TARGET_TEXT]. Reject if the claim cannot be located in the source.

claims[].support_status

string enum: ["SUPPORTED", "UNSUPPORTED", "CONTRADICTED"]

Must match one of the three enum values. Reject if status is SUPPORTED but no evidence is cited.

claims[].evidence

array of objects or null

Required when support_status is SUPPORTED or CONTRADICTED. Must be null when support_status is UNSUPPORTED. Reject on mismatch.

claims[].evidence[].source_id

string

Must match a source_id present in the provided [SOURCE_CONTEXT]. Reject on fabricated source references.

PRACTICAL GUARDRAILS

Common Failure Modes

Hallucination detection evals break in predictable ways. Here are the most common failure modes and how to guard against them before they corrupt your verification pipeline.

01

Judge Hallucinates the Verification

What to watch: The LLM judge fabricates evidence or invents source passages to confirm or deny a claim, defeating the purpose of the eval. This happens most often when the judge is asked to verify claims without strict source-grounding instructions. Guardrail: Require the judge to quote the exact source text for every verification decision. If no source text supports or contradicts a claim, the judge must output UNSUPPORTED rather than inferring an answer.

02

Overconfidence on Ambiguous Claims

What to watch: The judge assigns high confidence scores to claims that are partially true, context-dependent, or unverifiable from the provided sources. This masks real hallucination risks and inflates eval scores. Guardrail: Add a confidence calibration step that asks the judge to rate verifiability separately from correctness. Flag any claim where the source evidence is incomplete, outdated, or requires external knowledge.

03

Source-Output Alignment Drift

What to watch: The judge evaluates claims against the original source documents rather than the retrieved context actually provided to the generation model. This produces false positives when retrieval failed but the output was faithful to the retrieved snippets. Guardrail: Always pass the exact retrieved context used during generation into the eval prompt. Never substitute the full source document unless that was what the model received.

04

Claim Extraction Misses Implicit Assertions

What to watch: The claim extraction step only identifies explicit factual statements and misses implied claims, presuppositions, or embedded assumptions that are equally hallucinated. Guardrail: Instruct the claim extractor to identify both explicit and implicit factual assertions. Include few-shot examples showing how to surface presuppositions (e.g., 'The CEO announced the layoffs' implies the person is CEO and layoffs occurred).

05

Position Bias in Pairwise Verification

What to watch: When verifying claims in sequence, the judge's assessment of later claims is influenced by earlier verdicts, creating a consistency bias that masks isolated hallucinations. Guardrail: Randomize claim order across eval runs and measure verdict stability. If a claim's verdict changes based on surrounding claims, flag the judge as unreliable for that sample.

06

Length-Based False Negatives

What to watch: The judge penalizes concise, accurate outputs while giving a pass to verbose outputs that bury hallucinations in fluent prose. Shorter correct answers get flagged as 'insufficiently supported' while longer wrong answers pass. Guardrail: Normalize scores by output length and include length-invariant evaluation criteria. Test the judge against a golden set containing both concise correct answers and verbose incorrect answers to detect length bias.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test the output quality of the hallucination detection evaluator before relying on it in CI/CD. Use these criteria to validate that the prompt correctly identifies unsupported claims, fabricated details, and source contradictions.

CriterionPass StandardFailure SignalTest Method

Claim Extraction Completeness

All factual claims in [INPUT] are extracted with no omissions

Missing claims that appear in the source material but not in the evaluation output

Compare extracted claims against a pre-annotated golden set of known claims in 20 test documents

Source Grounding Accuracy

Every claim marked as supported has a valid [SOURCE] citation with matching evidence

Supported claims with citations that point to irrelevant passages or contradict the claim

Manual audit of 50 random claim-source pairs; pass if >95% have correct grounding

Unsupported Claim Detection

Claims without evidence in [SOURCE] are correctly flagged as unsupported with null citation

Unsupported claims incorrectly marked as supported or assigned fabricated citations

Inject 10 documents with known unsupported claims; verify all are flagged correctly

Fabrication Identification

Fabricated details not present in any source are explicitly labeled as fabricated

Fabricated numbers, dates, or names pass through without detection

Seed [INPUT] with 5 known fabrications per test case; require 100% detection rate

Source Contradiction Flagging

Conflicting claims across multiple [SOURCE] entries are identified with conflict explanation

Contradictory evidence is ignored or presented as consistent without noting the conflict

Use paired sources with deliberate contradictions; verify conflict flag appears in output

Confidence Calibration

Confidence scores correlate with actual correctness; high-confidence claims are >90% accurate

High-confidence scores assigned to incorrect grounding or fabricated claims

Calculate expected calibration error across 100 eval runs; require ECE < 0.1

Output Schema Compliance

Output matches [OUTPUT_SCHEMA] exactly with all required fields present and correctly typed

Missing fields, type mismatches, or extra fields not defined in the schema

Validate output against JSON schema programmatically; pass if zero schema violations

False Positive Rate on Accurate Text

Factually correct input with proper grounding produces zero unsupported or fabricated flags

Correct claims incorrectly flagged as unsupported or fabricated

Run against 30 known-accurate documents; require false positive rate < 2%

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add a [RETRIEVED_CONTEXT] placeholder and instruct the judge to compare each claim against the provided passages, not external knowledge. Include a citation requirement: each supported claim must reference a specific passage ID.

Prompt snippet

code
For each claim in [CLAIMS_LIST], check if it is directly supported by [RETRIEVED_CONTEXT]. 
Output: claim_id, verdict (SUPPORTED|UNSUPPORTED|CONTRADICTED), evidence_passage_id, explanation.

Watch for

  • Judge hallucinating support from passages that don't contain the claim
  • False positives when the model paraphrases the source too loosely
  • Missing passage IDs breaking downstream traceability
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.