Inferensys

Prompt

Reference-Guided Hallucination Detection Prompt Template

A practical prompt playbook for using Reference-Guided Hallucination Detection Prompt Template in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the ideal conditions, required inputs, and inappropriate use cases for the reference-guided hallucination detection prompt.

This prompt is designed for content verification teams, RAG system builders, and evaluation engineers who need a structured, claim-by-claim audit of AI-generated text against a known-correct reference document. The primary job-to-be-done is production hallucination auditing: you have an authoritative source and a model-generated output, and you need a machine-readable trail that marks every claim as grounded, hallucinated, or unsupported before the content is published, stored, or acted upon. The ideal user is someone integrating this into an automated pipeline—think a CI/CD step for documentation, a pre-publish check for AI-written summaries, or a regression gate for RAG answer quality.

This prompt is not a general factuality scorer, a toxicity filter, or a replacement for human editorial review in high-risk domains. It requires an explicit, comprehensive reference text. If the reference is incomplete, the prompt will correctly flag claims as 'unsupported,' but that label may reflect reference gaps rather than model errors. Use this when you can provide a reference that is authoritative enough to confirm or refute each claim. The prompt works best with factual, declarative content—summaries, reports, technical documentation, and RAG answers—rather than creative writing, opinion pieces, or open-ended analysis where 'ground truth' is ambiguous. For regulated domains such as healthcare, finance, or legal, this prompt is a triage tool, not a final arbiter; always route severity-flagged outputs to human review.

Before deploying this prompt, ensure you have three things: a model-generated text to audit, a reference document that contains the authoritative facts, and a clear policy for what happens to each severity classification. The prompt produces a structured JSON output with claim-level verdicts and severity labels, which you can feed directly into downstream validation logic, logging systems, or review queues. Avoid using this prompt on outputs longer than a few thousand words without chunking—the claim decomposition step loses reliability on very long texts. If you need aggregate metrics across many outputs, pair this prompt with the Regression Test Suite Execution or Golden Dataset Benchmark Harness playbooks. For real-time streaming outputs, consider a lighter-weight groundedness check instead.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before embedding it in a production pipeline.

01

Good Fit: Content Verification Pipelines

Use when: You have a known-correct reference document and need to audit a model-generated summary or report for unsupported claims. Guardrail: The reference must be the single source of truth. If multiple conflicting references exist, resolve them before invoking this prompt.

02

Bad Fit: Open-Domain Fact-Checking

Avoid when: You need to verify facts against general world knowledge rather than a specific provided reference. Risk: The model will hallucinate external facts to fill gaps if the reference is silent on a topic. Guardrail: Use a retrieval-augmented fact-checking prompt instead, and always provide explicit source text.

03

Required Inputs

Risk: Missing or ambiguous inputs cause the judge to default to leniency or hallucinate a reference. Guardrail: Always provide a complete, unambiguous [REFERENCE_TEXT] and a [MODEL_OUTPUT] to evaluate. A [SEVERITY_THRESHOLD] for flagging critical hallucinations must be defined in the application layer.

04

Operational Risk: High Token Consumption

Risk: Processing long documents claim-by-claim is expensive and slow, potentially doubling the cost of generation. Guardrail: Implement a pre-filter to extract only verifiable claims from the output before running this prompt. Cache reference embeddings to avoid re-processing the same source document.

05

Operational Risk: Ambiguous Grounding

Risk: The judge may classify a claim as 'unsupported' when it's a reasonable paraphrase, leading to false positives and alert fatigue. Guardrail: Calibrate the prompt with few-shot examples that clearly distinguish between 'hallucinated' (contradicted) and 'unsupported' (not found). Use a human-reviewed golden dataset for calibration.

06

Not a Replacement for Human Review

Risk: In regulated domains like healthcare or finance, an automated 'grounded' score can create a false sense of security. Guardrail: This prompt is a triage tool. All outputs flagged as 'hallucinated' or 'critical severity' must be routed to a human review queue before any downstream action is taken.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt template for detecting unsupported claims by comparing model output against a reference document, claim by claim.

This prompt template is the core of a reference-guided hallucination detection harness. It instructs the model to act as an auditor, decomposing the [MODEL_OUTPUT] into discrete claims and then checking each one against the [REFERENCE_TEXT]. The output is a structured JSON report that flags every claim as grounded, hallucinated, or unsupported, with a severity classification for any violations. This is not a general-purpose fact-checker; it strictly measures fidelity to the provided reference, not objective truth.

text
You are an expert fact-checking auditor. Your task is to compare a piece of generated text against a provided reference document. You must identify every factual claim in the generated text and determine whether it is supported by the reference.

# INPUTS
## MODEL OUTPUT
[MODEL_OUTPUT]

## REFERENCE TEXT
[REFERENCE_TEXT]

# INSTRUCTIONS
1. Decompose the entire MODEL OUTPUT into a list of discrete, verifiable factual claims. A claim is a single statement that can be proven true or false against the REFERENCE TEXT. Ignore opinions, stylistic phrasing, and grammatical structures.
2. For each claim, search the REFERENCE TEXT for direct support.
3. Classify each claim into exactly one of the following categories:
   - **grounded**: The claim is explicitly stated in or directly inferable from the REFERENCE TEXT.
   - **hallucinated**: The claim directly contradicts information in the REFERENCE TEXT.
   - **unsupported**: The claim is not found in the REFERENCE TEXT and cannot be confirmed or denied by it.
4. For any `hallucinated` or `unsupported` claim, assign a severity:
   - **critical**: The claim introduces a dangerous, legally risky, or fundamentally misleading fabrication.
   - **major**: The claim is a significant factual error or unsupported assertion that changes the meaning.
   - **minor**: The claim is a small detail, date, or name that is wrong or unsupported but does not change the core meaning.
5. For every claim, provide the exact text span from the MODEL OUTPUT and, for `grounded` claims, the exact supporting text span from the REFERENCE TEXT.

# CONSTRAINTS
- Do not use outside knowledge. The REFERENCE TEXT is the only source of truth.
- If the MODEL OUTPUT contains no verifiable claims, return an empty list.
- If a claim is a summary or paraphrase, it is `grounded` only if the core fact is present in the REFERENCE TEXT.

# OUTPUT SCHEMA
Return a valid JSON object with the following structure:
{
  "analysis": [
    {
      "claim_text": "String - the exact claim from the model output",
      "category": "grounded | hallucinated | unsupported",
      "severity": "critical | major | minor | null",
      "reference_evidence": "String or null - the supporting text from the reference for grounded claims",
      "explanation": "String - brief reasoning for the classification"
    }
  ],
  "summary": {
    "total_claims": "Integer",
    "grounded_count": "Integer",
    "hallucinated_count": "Integer",
    "unsupported_count": "Integer"
  }
}

To adapt this template, replace [MODEL_OUTPUT] with the text you are auditing and [REFERENCE_TEXT] with the authoritative source. For high-stakes domains like healthcare or finance, always route critical and major findings to a human review queue. Before deploying, run this prompt against a golden dataset of known hallucinations to calibrate your severity thresholds and ensure the JSON output is reliably parseable by your downstream validation logic.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Reference-Guided Hallucination Detection prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check that the input is well-formed and safe.

PlaceholderPurposeExampleValidation Notes

[MODEL_OUTPUT]

The generated text to audit for hallucinations

The patient's blood pressure was 140/90, indicating stage 2 hypertension requiring immediate medication.

Must be non-empty string. Check length under model context limit. Strip any prior system or user prompt artifacts before insertion.

[REFERENCE_TEXT]

The authoritative source document against which claims are verified

Patient vitals: BP 120/80. Assessment: normal. No medication indicated.

Must be non-empty string. Verify source is the correct reference for this output. Flag if reference is shorter than 50 characters as potentially incomplete.

[CLAIM_EXTRACTION_METHOD]

Instruction for how to decompose [MODEL_OUTPUT] into discrete verifiable claims

Extract every factual assertion as a separate claim. Include numerical values, diagnoses, and action recommendations.

Must be a complete sentence or short paragraph. Avoid ambiguous extraction instructions. Test that extracted claims are atomic and independently verifiable.

[SEVERITY_CLASSES]

Taxonomy for classifying hallucination impact when detected

CRITICAL: patient harm likely; MAJOR: clinical decision affected; MINOR: non-clinical detail wrong; NONE: fully grounded.

Must define at least 3 severity levels. Each level must have a clear, mutually exclusive definition. Avoid overlapping criteria between levels.

[OUTPUT_FORMAT]

Schema or structure instruction for the analysis report

Return JSON array of objects with fields: claim_text, verdict (grounded|hallucinated|unsupported), evidence_span, severity, explanation.

Must specify valid JSON schema. Include enum constraints for verdict and severity fields. Validate that evidence_span is a substring of [REFERENCE_TEXT] or explicitly null.

[ABSTENTION_CONDITIONS]

Rules for when the model should refuse to evaluate a claim

If [REFERENCE_TEXT] does not address the claim's domain, mark as UNSUPPORTED. If [MODEL_OUTPUT] is unintelligible, return error object.

Must define clear boundaries. Test with out-of-domain references and garbled outputs. Ensure abstention does not default to hallucinated or grounded.

[CONFIDENCE_THRESHOLD]

Minimum confidence required to mark a claim as grounded or hallucinated

0.85

Must be a float between 0.0 and 1.0. Values below 0.7 risk high false-positive rates. Require human review for claims where model confidence is below this threshold.

[MAX_CLAIMS]

Upper limit on number of claims extracted to prevent runaway analysis

50

Must be a positive integer. Set based on typical [MODEL_OUTPUT] length. If output exceeds limit, truncate and flag for human review. Prevents cost overruns on long documents.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Reference-Guided Hallucination Detection prompt into a production verification pipeline with validation, retries, and human review gates.

This prompt is designed to be the core analysis step in a content verification pipeline, not a standalone chat interaction. The typical harness wraps the LLM call in a pre-processing layer that extracts and normalizes claims from the generated content, then feeds each claim alongside the reference text into this prompt. Post-processing validates the structured output, enriches it with metadata, and routes high-severity hallucinations to a human review queue. The harness should treat the LLM as a claim classifier that produces machine-readable verdicts, not as a final arbiter of truth.

Input preparation requires splitting the generated content into discrete claims before invoking this prompt. Use a lightweight extraction step—either a separate LLM call with a claim extraction prompt or a rule-based sentence splitter—to produce a list of atomic statements. Each claim is then paired with the full reference text and passed to this prompt individually or in small batches. Output validation must parse the JSON response and verify that every claim in the input appears in the output with exactly one verdict from the allowed enum: grounded, hallucinated, or unsupported. Reject malformed responses and retry with the same input up to two times before escalating. Severity routing uses the severity field to decide next actions: low severity hallucinations can be logged for trend analysis, medium triggers a review task in a queue, and high or critical should block publication and notify the content owner immediately. Store the full prompt, response, and validation result in an audit log for traceability.

Model choice matters for this workflow. Use a model with strong instruction-following and JSON output capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable defaults. Avoid smaller or older models that may conflate unsupported with hallucinated or fail to produce valid JSON under the output schema. Retry logic should distinguish between format failures (invalid JSON, missing fields) and content failures (verdicts that don't match the claim list). Format failures get up to two retries with the same prompt; content failures should be logged and escalated without retry, as they indicate a model capability gap rather than a transient error. Human review integration is essential for medium and above severity findings. The harness should enrich each flagged claim with the original content snippet, the reference excerpt, the model's reasoning, and a direct link to the source document so reviewers can make a final determination without reconstructing context. Track reviewer decisions to measure judge accuracy over time and feed corrections back into eval datasets for prompt improvement.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact structure, types, and validation rules for the hallucination detection report. Use this contract to build a parser that can ingest the model's JSON output and programmatically flag any deviation before the results are surfaced to a user or logged.

Field or ElementType or FormatRequiredValidation Rule

verification_report

object

Top-level key must exist and be a valid JSON object. Reject if missing or not an object.

verification_report.claim_analyses

array

Must be a non-empty array. Each element must be an object. Reject if empty or not an array.

verification_report.claim_analyses[].claim_text

string

Must be a non-empty string exactly matching a verbatim span from [MODEL_OUTPUT]. Reject if empty or not found in source.

verification_report.claim_analyses[].verdict

string

Must be one of the allowed enum values: 'grounded', 'hallucinated', 'unsupported'. Reject on any other value.

verification_report.claim_analyses[].reference_evidence

string or null

If verdict is 'grounded', must be a non-empty string quoting [REFERENCE_TEXT]. If 'hallucinated' or 'unsupported', must be null. Reject on mismatch.

verification_report.claim_analyses[].severity

string

Must be one of: 'critical', 'major', 'minor'. 'critical' is only allowed if verdict is 'hallucinated'. Reject on invalid assignment.

verification_report.claim_analyses[].confidence_score

number

Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or not a number.

verification_report.summary

object

Must contain keys: 'total_claims', 'grounded_count', 'hallucinated_count', 'unsupported_count'. All values must be non-negative integers summing to total_claims. Reject on mismatch.

PRACTICAL GUARDRAILS

Common Failure Modes

Reference-guided hallucination detection fails in predictable ways. These are the most common failure modes and the practical guardrails that prevent them from reaching production.

01

False Negatives on Implicit Claims

What to watch: The judge misses hallucinations when claims are implied rather than stated outright. A model output saying 'the system processes data quickly' may be flagged as grounded even when the reference only mentions throughput in a different context. Guardrail: Add an explicit instruction to extract and verify all factual assertions, including implied performance characteristics, comparative statements, and causal claims. Test with outputs containing hedged or indirect claims.

02

Reference Scope Mismatch

What to watch: The judge marks claims as unsupported when the reference is too narrow, or marks claims as grounded when the reference is too broad and tangentially related. A claim about 'deployment latency' checked against a reference about 'system architecture' produces unreliable verdicts. Guardrail: Require a reference scope declaration before evaluation. If the reference doesn't cover the claim domain, flag as 'out of reference scope' rather than hallucinated or grounded. Build scope-mismatch detection into the prompt harness.

03

Severity Inflation on Minor Deviations

What to watch: The judge assigns high severity to trivial wording differences while missing substantive factual errors. A paraphrased definition gets flagged as 'critical hallucination' while a wrong numerical value passes as 'minor variation.' Guardrail: Define severity tiers with concrete examples in the prompt. Critical = contradicts a core fact in the reference. Minor = wording difference with preserved meaning. Test calibration with a labeled dataset containing both paraphrase pairs and genuine contradictions.

04

Claim Fragmentation and Double-Counting

What to watch: The judge splits a single claim into multiple fragments, then counts each fragment as a separate hallucination, inflating error rates. Or it merges distinct claims into one, masking multiple failures. Guardrail: Include claim segmentation rules in the prompt template. Specify that each claim must be a single verifiable atomic statement. Add a post-processing deduplication step that merges overlapping claim spans before scoring. Test with outputs containing compound sentences.

05

Over-Reliance on Surface Lexical Match

What to watch: The judge treats keyword overlap as grounding evidence, marking claims as supported when the reference contains matching words but different meaning. 'The model achieves 95% accuracy' gets grounded against a reference stating 'accuracy below 95% is unacceptable.' Guardrail: Require the judge to explain the semantic relationship between claim and evidence, not just cite matching spans. Add a contradiction check that explicitly looks for negations, qualifiers, and scope differences. Include few-shot examples of surface-match failures.

06

Abstention Drift on Ambiguous References

What to watch: When the reference is ambiguous or self-contradictory, the judge either hallucinates a definitive verdict or marks everything as unsupported, producing useless results. Guardrail: Add an explicit instruction for handling reference ambiguity. When the reference contains conflicting information, the judge should flag the reference conflict and mark affected claims as 'unverifiable due to reference ambiguity' rather than hallucinated. Include a reference quality pre-check step before running the full evaluation.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Reference-Guided Hallucination Detection prompt before shipping. Each criterion targets a specific failure mode in claim extraction, grounding verification, or severity classification. Run these tests against a curated set of known-correct reference-claim pairs.

CriterionPass StandardFailure SignalTest Method

Claim Extraction Completeness

All discrete factual claims in [MODEL_OUTPUT] are extracted with no omissions

Extracted claim count is zero or misses a verifiable factual assertion present in the output

Compare extracted claims against a human-annotated gold set of claims for 10 test outputs

Grounding Classification Accuracy

Each claim is correctly labeled as grounded, hallucinated, or unsupported per [REFERENCE_TEXT]

A claim labeled grounded contains a fact absent from or contradicted by the reference

Spot-check 20 claims with binary human judgment; require >95% agreement with prompt labels

Evidence Span Precision

Every grounded claim cites a specific, verbatim or near-verbatim span from [REFERENCE_TEXT]

Evidence span is missing, points to wrong section, or is a vague paraphrase that does not contain the claimed fact

Parse evidence spans and verify substring match or semantic equivalence against reference text

Severity Classification Consistency

Hallucinated claims are assigned correct severity: critical for contradictions, major for fabrications, minor for unsupported details

A direct contradiction of the reference is labeled minor, or a trivial unsupported detail is labeled critical

Run 10 hallucination examples with pre-labeled severity; measure exact match and off-by-one tolerance

Unsupported Claim Handling

Claims not verifiable from [REFERENCE_TEXT] are labeled unsupported, not hallucinated

Unsupported claims are incorrectly merged into hallucinated category without evidence of contradiction

Audit all unsupported labels against reference to confirm absence of contradictory evidence

Output Schema Compliance

Output is valid JSON matching [OUTPUT_SCHEMA] with all required fields present and correctly typed

JSON parse fails, required field is missing, or severity field contains an undefined enum value

Validate output against JSON Schema; run schema check as automated gate in eval harness

Null Reference Handling

When [REFERENCE_TEXT] is empty or null, all claims are labeled unsupported with appropriate confidence reduction

Empty reference triggers hallucinated labels or crashes the extraction pipeline

Pass empty string and null reference inputs; verify graceful degradation and no false hallucination flags

Confidence Score Calibration

Confidence scores correlate with evidence strength: direct quotes > paraphrases > inference

A claim with no reference evidence receives confidence >0.5, or a direct quote receives confidence <0.8

Bin claims by evidence type and verify mean confidence follows expected ordering across 50 samples

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single reference document and lighter output validation. Skip severity classification and keep the output to a flat list of claims with grounded / hallucinated / unsupported labels. Run ad-hoc on a few samples to calibrate thresholds before adding schema enforcement.

code
For each claim in [MODEL_OUTPUT], compare it against [REFERENCE_TEXT].
Label each claim as:
- grounded: directly supported by the reference
- hallucinated: contradicted by the reference
- unsupported: not mentioned in the reference

Return a JSON array of { "claim": string, "label": string, "evidence": string | null }

Watch for

  • Missing evidence spans when claims are labeled grounded
  • Overly aggressive hallucination flags on paraphrased statements
  • No handling of partially supported claims
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.