Inferensys

Prompt

Hallucination Detection Prompt for Generated Answers

A practical prompt playbook for using Hallucination Detection Prompt for Generated Answers in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and critical limitations for the hallucination detection prompt.

This prompt is a post-generation guardrail for Retrieval-Augmented Generation (RAG) systems. Its job is to take a generated answer and the source evidence used to produce it, decompose the answer into discrete factual claims, and verify each claim against the evidence. The output is a structured audit trail that flags unsupported statements, identifies faithful synthesis, and separates interpretation from fabrication. The ideal user is a QA engineer, an AI pipeline builder, or a product team lead who needs automated hallucination detection before an answer reaches a user. You should use this prompt when you are building CI/CD quality gates for answer accuracy, calibrating hallucination rates against human audits, or implementing a runtime safety net that catches fabrications missed during generation.

To use this prompt effectively, you must provide two critical inputs: the full generated answer text and the complete set of source evidence chunks that were used during generation. The prompt does not perform retrieval itself; it assumes the evidence is already selected. The output is a structured JSON object containing a list of claims, each with a verification status (SUPPORTED, UNSUPPORTED, or PARTIALLY_SUPPORTED), the specific source passage that supports or contradicts the claim, and a brief explanation of the mismatch if the claim is unsupported. This structure is designed for direct integration into an automated evaluation pipeline. You can wire the output to a validation function that blocks answers exceeding a configurable unsupported-claim threshold, logs the audit trail for human review, or feeds the flagged claims back into a self-correction loop.

Do not use this prompt as a substitute for retrieval quality improvements. If your retrieval system consistently returns irrelevant or insufficient context, this prompt will correctly flag most answers as unsupported, but it will not fix the root cause. It is a detection tool, not a repair tool. In high-stakes domains such as healthcare, legal, or finance, this prompt must not be the sole safety mechanism. Always route answers with a high proportion of unsupported claims or any UNSUPPORTED claim in a critical category to a human review queue. The prompt itself can hallucinate—it may incorrectly classify a supported claim as unsupported or vice versa. Calibrate its performance against a golden dataset of human-annotated answers before relying on it in production, and monitor its false positive and false negative rates over time.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must have in place before deploying it as a production guardrail.

01

Good Fit: Post-Generation QA Gate

Use when: you need an automated second pass to verify claims in a generated answer against retrieved source chunks before the answer reaches a user. Guardrail: Run this prompt as a synchronous check in your RAG pipeline; block or flag the answer if unsupported claims exceed a threshold.

02

Bad Fit: Real-Time Chat Without Sources

Avoid when: the system does not have access to the original retrieved evidence chunks, or when latency budgets are under 200ms. Guardrail: Do not use this prompt on free-form LLM outputs where no ground-truth context exists; it will hallucinate verification results.

03

Required Inputs

What you need: the original user question, the full generated answer, and the exact retrieved context chunks with their source identifiers. Guardrail: If any input is missing or truncated, abort verification and escalate to a human review queue rather than producing a false-clean signal.

04

Operational Risk: Verification Drift

What to watch: the verifier model can hallucinate support for claims it wants to confirm, especially when evidence is ambiguous. Guardrail: Calibrate against a human-annotated golden set monthly; track false-positive and false-negative rates, and never treat the verifier as a substitute for human audit in regulated domains.

05

Operational Risk: Cost Amplification

What to watch: running a full claim-by-claim verification on every answer doubles your inference cost per user query. Guardrail: Sample verification for low-risk traffic, or gate verification behind a lightweight confidence classifier that only triggers deep checks on uncertain answers.

06

Escalation Boundary

What to watch: the verifier flags a claim as unsupported, but the original answer was correct and the source chunk was poorly chunked. Guardrail: When verification fails, log the specific claim-evidence pair and route to a human review queue; never auto-rewrite the answer without human approval in high-stakes domains.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt for decomposing a generated answer into claims and verifying each against source evidence to detect hallucinations.

The following prompt template is designed to be dropped directly into your post-generation validation pipeline. It instructs the model to act as a factual verification auditor, extracting every discrete factual claim from a generated answer and checking each one against a provided source evidence block. The output is a structured JSON object that flags unsupported and contradicted claims, providing a clear, auditable grounding score. This is not a prompt for generating answers; it is a guardrail for verifying them.

text
You are a factual verification auditor. Your task is to decompose a generated answer into discrete factual claims and verify each claim against the provided source evidence. You must flag any claim that cannot be fully supported by the evidence as unsupported. Do not introduce external knowledge. Do not fill gaps with assumptions.

## Source Evidence
[SOURCE_EVIDENCE]

## Generated Answer
[GENERATED_ANSWER]

## Verification Instructions
1. Extract every discrete factual claim from the Generated Answer. A factual claim is a statement that can be verified as true or false against the Source Evidence.
2. For each claim, search the Source Evidence for direct support. A claim is supported only if the evidence explicitly states the fact or the fact can be directly inferred from a single passage without additional assumptions.
3. Assign a verification status to each claim:
   - SUPPORTED: The claim is explicitly stated in or directly inferable from the Source Evidence.
   - UNSUPPORTED: The claim cannot be verified from the Source Evidence.
   - CONTRADICTED: The Source Evidence directly contradicts the claim.
4. For SUPPORTED claims, provide the exact source passage ID and the supporting text.
5. For UNSUPPORTED claims, explain what is missing from the evidence.
6. For CONTRADICTED claims, provide the conflicting evidence passage ID and text.
7. Produce a final grounding score: the percentage of claims that are SUPPORTED.

## Output Format
Return a JSON object with the following structure:
{
  "claims": [
    {
      "claim_id": "string",
      "claim_text": "string",
      "verification_status": "SUPPORTED | UNSUPPORTED | CONTRADICTED",
      "source_passage_id": "string | null",
      "source_text": "string | null",
      "explanation": "string"
    }
  ],
  "grounding_score": number,
  "total_claims": number,
  "supported_claims": number,
  "unsupported_claims": number,
  "contradicted_claims": number
}

To adapt this template, replace the [SOURCE_EVIDENCE] placeholder with the raw text of your retrieved documents, ideally with each passage prefixed by a unique ID (e.g., [P1], [P2]) to make citation mapping deterministic. Replace [GENERATED_ANSWER] with the full text output from your RAG synthesis step. For high-stakes domains like healthcare or legal, consider adding a [CONSTRAINTS] section that explicitly forbids the model from making any inferential leaps, requiring verbatim support for every claim. The JSON output schema is strict; validate it in your application layer before processing the results to guard against malformed model responses.

After running this prompt, your application should parse the grounding_score and iterate through the claims array. Any claim with a status of UNSUPPORTED or CONTRADICTED represents a potential hallucination. Your next step should be to route answers with a grounding score below your defined threshold (e.g., 0.95) to a human review queue or a self-correction loop. Do not treat this prompt as a final arbiter of truth; it is a signal that requires calibration against human-annotated ground truth to measure its own hallucination recall and false positive rate.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the hallucination detection prompt. Each variable must be populated before the prompt is sent to the model. Missing or malformed inputs are the most common cause of false negatives in production.

PlaceholderPurposeExampleValidation Notes

[GENERATED_ANSWER]

The full text of the answer produced by the upstream RAG system that needs to be verified claim-by-claim against source evidence.

The cat sat on the mat. The mat was purchased in 2019 from a vendor in Ohio.

Must be a non-empty string. Truncate at 8000 characters if longer; flag truncation in eval metadata. Null or empty input should abort the detection run and log an upstream generation failure.

[SOURCE_EVIDENCE]

The complete set of retrieved passages, documents, or chunks that were available to the generation step. This is the ground truth for verification.

Passage 1: The cat sat on the mat. Passage 2: The mat was purchased in 2019.

Must be a non-empty array of objects with at least 'text' and 'source_id' fields. Each passage text must be a non-empty string. If evidence is empty, the prompt should return an abstention signal rather than attempting verification.

[VERIFICATION_GRANULARITY]

Controls whether the prompt decomposes the answer into sentence-level claims, clause-level claims, or paragraph-level claims for verification.

sentence

Must be one of: 'sentence', 'clause', 'paragraph'. Default to 'sentence' if not provided. Clause-level produces more claims and higher token usage; paragraph-level may miss embedded fabrications.

[CITATION_FORMAT]

Specifies how source references should appear in the verification output. Determines whether the model returns source_id, document_title, passage_index, or a combination.

source_id_and_index

Must be one of: 'source_id', 'source_id_and_index', 'source_id_and_title', 'full_citation'. If the evidence objects lack the required fields, the validator should reject the run before the prompt is sent.

[CONFIDENCE_THRESHOLD]

The minimum confidence score a claim must have to be marked as 'supported'. Claims below this threshold are flagged as 'unsupported' or 'uncertain'.

0.7

Must be a float between 0.0 and 1.0. Values below 0.5 increase false positives; values above 0.9 increase false negatives. Log the threshold with every eval run for calibration tracking.

[OUTPUT_SCHEMA]

The exact JSON schema the model must follow for the verification output. Includes claim list, per-claim support status, source mapping, and confidence scores.

See output-contract table for full schema definition.

Must be a valid JSON Schema object. Validate that the schema includes required fields: 'claims', 'overall_grounding_score', 'unsupported_claim_count'. Schema mismatch between prompt instruction and post-processing parser is a top-3 production failure mode.

[MAX_CLAIMS]

Upper bound on the number of claims the model should extract from the generated answer. Prevents unbounded decomposition on long answers.

20

Must be a positive integer. If the answer contains more distinct factual claims than this limit, the model should prioritize claims with highest potential fabrication risk. Log truncation events for monitoring.

[ABSTENTION_RULES]

Instructions for when the verification itself should be abandoned, such as when source evidence is entirely irrelevant or the generated answer is nonsensical.

Abstain if source evidence has zero semantic overlap with the generated answer.

Must be a non-empty string. If left blank, the model may hallucinate source matches for completely ungrounded answers. Test abstention behavior with adversarial inputs where evidence is deliberately unrelated.

PROMPT PLAYBOOK

Implementation Harness Notes

Wire this prompt as a post-generation verification step in your RAG pipeline to catch unsupported claims before they reach users.

This verification prompt is designed to operate as a post-generation guardrail, not a pre-generation filter. After your primary answer generation model produces a response, pass both the generated answer and the retrieved source passages to this prompt. The model will decompose the answer into individual claims, match each claim against the provided evidence, and return a structured JSON payload with per-claim grounding assessments and an overall grounding_score. This architecture keeps the verification logic decoupled from the synthesis logic, allowing you to tune, version, and evaluate each component independently.

Parse the JSON output and check the grounding_score field against your defined threshold. If the score falls below your threshold, route the answer for human review, trigger a regeneration with stricter grounding instructions, or surface the unsupported claims to the user with appropriate caveats. For CI/CD integration, run this prompt against a golden dataset of question-answer-evidence triples and track grounding scores over time. Log every verification result—including the original answer, evidence, and claim breakdown—for audit trails. Implement retry logic with temperature variation if the model fails to produce valid JSON. Set a timeout appropriate for your latency budget; verification adds one additional model call per answer.

Choose a model for verification that balances accuracy and cost. A smaller, faster model may suffice for straightforward factual checks, while complex multi-hop answers may require the same tier model used for generation. Always validate the JSON schema before trusting the output—malformed JSON is a common failure mode. If the verification model consistently misses a specific class of hallucination, add few-shot examples of that failure pattern to the prompt. For high-stakes domains, maintain a human audit sample of verification decisions to calibrate your threshold and detect drift in the verifier's behavior over time.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact fields, types, and validation rules your application should expect from the hallucination detection prompt. Use this contract to build a parser and validator before integrating the prompt into a production guardrail.

Field or ElementType or FormatRequiredValidation Rule

verification_id

string (UUID v4)

Must parse as a valid UUID v4. Reject if missing or malformed.

original_answer

string

Must be a non-empty string. Reject if null or whitespace only.

claims

array of objects

Must be a JSON array. Reject if not present or empty. Each element must be an object.

claims[].claim_text

string

Must be a non-empty string. Reject if null or whitespace only. Should be a verbatim extract from the original_answer.

claims[].verification_status

string (enum)

Must be one of: 'SUPPORTED', 'UNSUPPORTED', 'CONTRADICTED', 'PARTIALLY_SUPPORTED'. Reject on any other value.

claims[].source_evidence

array of strings

If present, each string must be a non-empty excerpt from the provided [SOURCE_CONTEXT]. If verification_status is 'SUPPORTED' or 'PARTIALLY_SUPPORTED', this array must not be empty. Validate via substring match against [SOURCE_CONTEXT].

claims[].confidence_score

number (float 0.0-1.0)

Must be a number between 0.0 and 1.0 inclusive. Reject if out of range or not a number. A score below 0.5 should correlate with 'UNSUPPORTED' or 'CONTRADICTED' status.

overall_hallucination_score

number (float 0.0-1.0)

Must be a number between 0.0 and 1.0 inclusive. Reject if out of range. A score of 1.0 indicates no unsupported claims; 0.0 indicates all claims are unsupported.

PRACTICAL GUARDRAILS

Common Failure Modes

Hallucination detection prompts fail in predictable ways. Here are the most common failure modes, why they happen, and how to guard against them before they reach production.

01

False Negatives: Hallucinations Pass Verification

What to watch: The verifier prompt misses fabricated claims because the generated answer sounds plausible or uses domain terminology convincingly. This often happens when the source evidence is dense or technical, and the verifier defaults to surface-level plausibility rather than strict entailment checking. Guardrail: Require claim-by-claim decomposition before verification. Each atomic claim must be matched to a specific source span with an explicit entailment decision. Use a structured output schema that forces the verifier to cite the exact passage or return null for unsupported claims.

02

False Positives: Correct Answers Flagged as Hallucinations

What to watch: The verifier incorrectly flags faithful answers as unsupported because it fails to recognize paraphrases, inferences, or information distributed across multiple passages. This erodes trust in the guardrail and creates unnecessary human review burden. Guardrail: Include explicit instructions that paraphrased content and reasonable inferences from evidence are acceptable. Provide few-shot examples showing correct answers that rephrase source material without introducing new facts. Calibrate against a human-annotated dataset and measure false positive rate per claim type.

03

Verifier Hallucinates Its Own Analysis

What to watch: The detection prompt itself fabricates source evidence, invents passage references, or claims support where none exists. A hallucination detector that hallucinates is worse than no detector at all. Guardrail: Run the verifier output through a secondary check that confirms cited passages actually exist in the provided context. Use exact string matching or embedding similarity to validate that quoted evidence appears in the source material. Log all verifier citations that cannot be matched to input context.

04

Context Window Truncation Drops Critical Evidence

What to watch: When the generated answer plus source evidence exceeds the verifier's context window, evidence gets truncated. The verifier then flags claims as unsupported because the supporting passage was cut off. Guardrail: Chunk verification by claim group rather than sending the entire answer with all evidence at once. Prioritize evidence passages that are most likely to support each claim. If truncation is unavoidable, include a TRUNCATED_CONTEXT flag in the output schema so downstream systems know the verification may be incomplete.

05

Ambiguous Claims Produce Inconsistent Verdicts

What to watch: Vague or hedged claims in the generated answer produce unreliable verification results. The verifier may accept a weakly worded fabrication or reject a properly caveated true statement depending on how it interprets ambiguity. Guardrail: Require the answer generation prompt to produce specific, verifiable claims with explicit caveats. In the verifier prompt, instruct the model to flag ambiguous claims separately with an UNCERTAIN label rather than forcing a binary supported/unsupported decision. Route uncertain claims to human review.

06

Temporal Drift Between Evidence and Verification

What to watch: The source evidence contains time-sensitive information, but the verifier treats all claims as equally valid regardless of recency. An answer may be faithfully grounded in outdated evidence while still being misleading. Guardrail: Include document dates and recency metadata in the evidence context. Add verification criteria that checks whether claims reflect the most current available evidence. Flag claims grounded in documents older than a configurable threshold with a STALE_EVIDENCE warning separate from the hallucination flag.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the hallucination detection prompt's output quality before shipping. Each criterion defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Claim Recall

All verifiable claims from [GENERATED_ANSWER] are extracted into the claim list

A factual statement present in the answer is missing from the extracted claims

Human audit of 50+ samples comparing answer text to extracted claim list; target >95% recall

Grounding Precision

Every claim marked as SUPPORTED has a valid [SOURCE_ID] and the source text contains the claim's fact

A claim is marked SUPPORTED but the cited source does not contain the claim or contradicts it

Automated check: for each SUPPORTED claim, retrieve cited passage and run a textual entailment model; flag mismatches

Unsupported Flag Accuracy

Claims marked UNSUPPORTED are genuinely absent from all provided [CONTEXT] passages

A claim is marked UNSUPPORTED but the fact is explicitly stated in the provided context

Automated check: for each UNSUPPORTED claim, search all context passages for the claim's key entities and relations; flag false positives

Schema Compliance

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

Output is missing required fields, contains extra keys, or has incorrect types (e.g., string instead of array)

JSON Schema validator run against every output; check for confidence_score as float, claims as array, source_id as string or null

Confidence Score Calibration

The confidence_score correlates with the ratio of SUPPORTED to total claims

High confidence score (e.g., 0.95) but multiple claims are UNSUPPORTED or CONTRADICTED

Calculate expected confidence as (SUPPORTED claims / total claims); flag if absolute difference from reported score exceeds 0.2

Contradiction Detection

Claims marked CONTRADICTED have at least one source passage that directly opposes the claim

A claim is marked CONTRADICTED but no source passage contains opposing evidence

For each CONTRADICTED claim, require the output to include a contradicting_source_id; verify that source passage contains a negated or opposing statement

Abstention on Empty Context

When [CONTEXT] is empty or null, output contains zero claims and a confidence_score of 0.0

Output generates claims or a confidence score above 0.0 when no context is provided

Unit test with empty context input; assert claims array is empty and confidence_score equals 0.0

Hallucination-Free Reasoning

The reasoning field for each claim contains only information derived from the claim and its cited source

The reasoning field introduces new facts, entities, or external knowledge not present in the claim or source

Human audit of reasoning fields for 30+ samples; flag any statement in reasoning that cannot be traced to the claim text or cited source passage

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single frontier model and manual review of flagged claims. Keep the output schema simple: a flat list of claims with supported boolean and evidence string. Run on a small batch of 20-50 generated answers to calibrate thresholds before adding complexity.

Prompt modification

  • Remove strict JSON schema enforcement; accept markdown-structured output
  • Replace [OUTPUT_SCHEMA] with: Return a list where each item has claim, supported (true/false), and evidence (quote or "none")
  • Drop confidence scoring and severity classification fields
  • Use a single [CONTEXT] block rather than per-source metadata

Watch for

  • Over-flagging paraphrased claims as unsupported when the meaning matches but wording differs
  • Missing false negatives where fabricated claims use source-adjacent vocabulary
  • Model conflating "partially supported" with "supported" without nuance
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.