This prompt acts as a binary gate for RAG pipelines, content verification systems, and any workflow where AI-generated text must be fact-checked against provided source documents. It decomposes a model's output into individual claims, maps each claim to specific evidence in the source material, and returns a grounded/ungrounded verdict. The primary job-to-be-done is preventing hallucinated content from reaching end users by enforcing evidence-backed output before delivery. Ideal users include RAG system builders, evaluation engineers running CI/CD prompt regression suites, and production operators who need continuous hallucination monitoring on live traffic.
Prompt
Hallucination Detection Gate Prompt

When to Use This Prompt
A binary gate for RAG pipelines that decomposes model output into individual claims, maps each to source evidence, and returns a grounded/ungrounded verdict before the answer reaches a user.
Deploy this prompt as a pre-delivery check in question-answering systems where the cost of a hallucination is high—customer-facing support, clinical documentation, legal research, or financial analysis. Wire it into your evaluation harness as a regression gate: every prompt change must pass hallucination detection against a golden dataset of known grounded and ungrounded output pairs. For production monitoring, sample a percentage of live responses through this gate and track the grounded-to-ungrounded ratio over time. A rising ungrounded rate signals retrieval degradation, prompt drift, or model behavior change that requires investigation before users notice.
Do not use this prompt when no source evidence is provided, when the output is purely creative or subjective, or when the acceptable risk of hallucination is non-zero and the cost of blocking is higher than the cost of an error. This prompt is also inappropriate for open-domain conversation where grounding against a fixed document set would produce false negatives on legitimate general-knowledge responses. If your workflow requires nuanced faithfulness scoring rather than a binary gate, use the RAG Answer Faithfulness Gate Prompt instead. For production deployments, always pair this prompt with a human review escalation path for edge cases where the model's grounding verdict is low-confidence or where blocked outputs represent high-value transactions that warrant manual verification.
Use Case Fit
The Hallucination Detection Gate is a high-precision tool for RAG pipelines, not a general-purpose fact-checker. It excels at verifying if a claim is explicitly supported by provided source text, but it requires disciplined input formatting and a clear understanding of its binary output contract.
Good Fit: RAG Answer Verification
Use when: you need to automatically verify if every sentence in a generated answer is directly supported by the retrieved chunks. Guardrail: Decompose the answer into atomic claims before sending them to the gate to avoid ambiguous multi-fact sentences.
Bad Fit: Open-Domain Fact-Checking
Avoid when: you need to verify a claim against the model's internal knowledge or the entire internet. Guardrail: This prompt only checks grounding against the provided [SOURCE_TEXT]. For open-domain checks, integrate a web search tool before calling this gate.
Required Inputs: Atomic Claims & Sources
Risk: Feeding a long, complex paragraph will produce unreliable results. Guardrail: Pre-process the output with a 'Claim Decomposition' prompt to isolate single, verifiable facts. The [SOURCE_TEXT] must be the exact retrieved chunk, not a summary.
Operational Risk: Paraphrase Blindness
Risk: The gate may return a false negative (ungrounded) if the claim paraphrases the source without using the same keywords. Guardrail: Include a few-shot example in the prompt demonstrating that semantic equivalence counts as grounded. Monitor false-negative rates by spot-checking 'ungrounded' verdicts.
Operational Risk: Plausible Fabrications
Risk: The model may return a false positive (grounded) for a claim that sounds plausible and uses words from the source but draws an unsupported conclusion. Guardrail: Add an eval check that specifically tests for 'inferential leaps' where the claim adds information not literally present in the source.
Integration Pattern: CI/CD Quality Gate
Use when: you want to block a RAG pipeline deployment if faithfulness drops. Guardrail: Run this gate on a golden dataset of answer-source pairs. Calculate the pass rate. If the rate drops below a defined threshold (e.g., 95%), halt the deployment and investigate the prompt or retrieval change.
Copy-Ready Prompt Template
A ready-to-use system prompt for detecting hallucinations in RAG outputs by mapping each claim to source evidence and returning a binary grounded/ungrounded verdict.
This prompt template implements a hallucination detection gate for Retrieval-Augmented Generation (RAG) systems. It takes a model-generated response and the source documents used to produce it, then evaluates every factual claim individually. The prompt is designed to be placed in your system instructions for an LLM judge that acts as a verification layer before outputs reach end users. Replace the square-bracket placeholders with your actual data before sending the request.
textYou are a hallucination detection judge for a RAG system. Your job is to verify whether every factual claim in a generated response is supported by the provided source documents. ## INPUT - Generated Response: [RESPONSE] - Source Documents: [SOURCE_DOCUMENTS] ## INSTRUCTIONS 1. Extract every factual claim from the Generated Response. A factual claim is any statement that asserts something true about the world, including dates, names, numbers, events, relationships, or properties. 2. For each claim, search the Source Documents for direct supporting evidence. A claim is grounded only if the source documents explicitly state it or it can be directly inferred from a single source without adding external knowledge. 3. Do not mark a claim as grounded if: - The source only partially supports it. - The claim combines information from multiple sources in a way not present in any single source. - The claim adds details, interpretations, or context not present in the sources. - The claim contradicts the sources. 4. For each claim, provide a direct quote from the source documents that supports it, or state "NO EVIDENCE FOUND" if no support exists. ## OUTPUT FORMAT Return a JSON object with this exact structure: { "overall_verdict": "grounded" | "ungrounded", "claims": [ { "claim_text": "string", "verdict": "grounded" | "ungrounded", "source_quote": "string or null", "source_id": "string or null" } ] } ## CONSTRAINTS - overall_verdict must be "ungrounded" if ANY claim is ungrounded. - Never fabricate source quotes. If no evidence exists, use null for source_quote and source_id. - If the Generated Response contains no factual claims, return an empty claims array with overall_verdict "grounded". - Do not evaluate claims about the response's own structure, formatting, or style.
To adapt this prompt, replace [RESPONSE] with the full text output from your generation model and [SOURCE_DOCUMENTS] with the retrieved passages, each labeled with a source identifier. If your sources lack IDs, add them before calling the judge. For high-stakes domains such as healthcare or legal, add a [RISK_LEVEL] parameter that triggers stricter evidence requirements and mandatory human review when the verdict is ungrounded. Test the prompt with both clearly grounded responses and known hallucinations to calibrate your acceptance threshold before deploying to production.
Prompt Variables
Required inputs for the Hallucination Detection Gate Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of false negatives in production.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[RESPONSE_TO_CHECK] | The full model-generated text that needs hallucination detection | The Apollo program's primary goal was to land humans on the Moon and return them safely to Earth. It also developed the first reusable spacecraft. | Must be a non-empty string. Truncate to the model's context window minus prompt overhead. Empty responses should bypass the gate and return ungrounded. |
[SOURCE_EVIDENCE] | The retrieved or provided ground-truth text against which claims are verified | Project Apollo's objectives, as stated by NASA, were: landing a man on the Moon and returning him safely to Earth. The Space Shuttle program, not Apollo, developed the first reusable spacecraft. | Must be a non-empty string. If no evidence is available, set to 'NO_EVIDENCE_PROVIDED' and expect all claims to be flagged as ungrounded. Do not pass null. |
[CLAIM_EXTRACTION_GRANULARITY] | Controls whether the prompt splits the response into sentences, clauses, or atomic facts before checking | sentence | Allowed values: 'sentence', 'clause', 'atomic_fact'. 'atomic_fact' is recommended for high-precision use cases but increases token consumption. Default to 'sentence' if not specified. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score (0.0-1.0) for a claim to be considered grounded | 0.7 | Must be a float between 0.0 and 1.0. Lower thresholds reduce false negatives on paraphrased support but increase false positives on plausible fabrications. 0.7 is a reasonable starting default. |
[OUTPUT_SCHEMA] | The exact JSON structure the model must return for each claim | {"claim_text": "string", "verdict": "grounded|ungrounded|uncertain", "source_quote": "string|null", "confidence": 0.0-1.0, "rationale": "string"} | Must be a valid JSON Schema object or a stringified example. The prompt should instruct the model to return a JSON array of these objects. Validate the output against this schema before accepting the verdict. |
[FALSE_NEGATIVE_EXAMPLES] | One or two few-shot examples of paraphrased support that should be marked grounded | Claim: 'The Apollo program landed people on the Moon.' Source: 'Apollo's objective was landing a man on the Moon.' Verdict: grounded | Include at least one example where the wording differs significantly but the meaning is the same. This is the primary defense against overly literal matching. Store these in a prompt library and version them. |
[FALSE_POSITIVE_EXAMPLES] | One or two few-shot examples of plausible-sounding claims that are not actually supported by the source | Claim: 'Apollo developed reusable spacecraft.' Source: 'Apollo landed men on the Moon. The Shuttle was reusable.' Verdict: ungrounded | Include at least one example where the claim combines facts from the source in an unsupported way. This is the primary defense against hallucinated synthesis. Version alongside false-negative examples. |
Implementation Harness Notes
How to wire the hallucination detection gate into a production RAG pipeline with validation, retries, and human review.
The hallucination detection gate operates as a synchronous check between answer generation and user delivery. After your RAG pipeline produces a candidate answer, split it into individual claims using sentence segmentation or a lightweight extraction step. Send each claim alongside its source context to the gate prompt. The gate returns a binary grounded/ungrounded verdict per claim with an evidence mapping. Aggregate these verdicts to decide whether the full answer passes, fails, or requires partial redaction. This gate is not a replacement for retrieval quality—it catches fabrication after generation, so pair it with retrieval precision monitoring.
Wire the gate as a post-generation validation step in your orchestration layer. For each claim, call the prompt with [CLAIM], [SOURCE_CONTEXT], and [EVIDENCE_THRESHOLD] set to your acceptable grounding level. Parse the JSON output and check the verdict field. If any claim returns ungrounded, either redact that claim, regenerate the answer with stricter grounding instructions, or escalate to human review depending on your risk tolerance. Implement a retry loop with a maximum of two regeneration attempts—after that, log the failure and surface the ungrounded claims to an operator. For high-stakes domains like healthcare or legal, configure the harness to block delivery entirely when any claim fails grounding and require human approval before release.
Log every gate invocation with the claim text, source context, verdict, and evidence mapping. This audit trail is essential for debugging retrieval gaps, tuning the evidence threshold, and defending decisions to stakeholders. Set up eval checks that run weekly against a golden dataset of known grounded and hallucinated claims. Measure false negatives on paraphrased support—where the model marks a claim ungrounded despite the source containing equivalent meaning—and false positives on plausible-sounding fabrications. If false negatives exceed 5%, lower the evidence threshold or add few-shot examples of acceptable paraphrasing. If false positives exceed 2%, tighten the threshold and add examples of subtle fabrications. Use these metrics to decide when to update the prompt template or switch to a more capable model for the gate itself.
Expected Output Contract
Fields returned by the Hallucination Detection Gate Prompt. Each claim in the input must produce one verdict object. The overall output is a JSON array of these objects, one per claim.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
claim_index | integer | Must be a zero-based index matching the order of claims in [CLAIMS] input. No gaps or duplicates allowed in the array. | |
claim_text | string | Must exactly match the original claim substring from [CLAIMS]. Any deviation indicates a parsing error and requires retry. | |
verdict | enum: GROUNDED | UNGROUNDED | UNCERTAIN | GROUNDED requires at least one source_evidence block with direct support. UNGROUNDED requires no supporting evidence found. UNCERTAIN requires ambiguous or partial support only. | |
source_evidence | array of objects | Required when verdict is GROUNDED. Each object must contain source_id (string matching [SOURCES] keys), relevant_excerpt (verbatim quote from source), and rationale (string explaining how excerpt supports claim). Empty array allowed for UNGROUNDED. | |
confidence | number between 0.0 and 1.0 | Must be a float. GROUNDED verdicts should have confidence >= 0.7. UNGROUNDED verdicts should have confidence >= 0.8. UNCERTAIN verdicts should have confidence < 0.7. Values outside expected ranges trigger a review flag. | |
fabrication_risk | enum: LOW | MEDIUM | HIGH | HIGH when claim contains specific entities, numbers, or dates not found in any source. MEDIUM when claim is plausible but unsupported. LOW when claim is vague or opinion-based. Must be consistent with verdict and source_evidence. | |
needs_human_review | boolean | Set to true when verdict is UNCERTAIN, confidence is below threshold for verdict type, or fabrication_risk is HIGH. False otherwise. Triggers escalation in the harness. |
Common Failure Modes
What breaks first when deploying a hallucination detection gate and how to guard against it.
False Negatives on Paraphrased Support
What to watch: The gate marks a claim as ungrounded because the source uses different wording, even when the meaning is identical. This happens frequently with technical synonyms, active/passive voice shifts, and reordered clauses. Guardrail: Include few-shot examples that pair paraphrased source sentences with grounded verdicts. Add an explicit instruction: 'Semantic equivalence counts as support. Do not require exact string matching.'
False Positives on Plausible Fabrications
What to watch: The model accepts a claim as grounded because the source mentions related entities or concepts, even though the specific factual assertion is absent. The gate confuses topical overlap with evidentiary support. Guardrail: Require direct quote mapping in the output schema. Add a verification step: 'For each claim marked grounded, extract the exact source sentence that supports it. If no single sentence or contiguous passage contains the fact, mark it ungrounded.'
Context Boundary Leakage
What to watch: The gate treats information from the model's pre-training as grounding evidence instead of restricting verification to the provided source documents. This is especially dangerous when the source is silent on a well-known fact. Guardrail: Add a hard constraint in the system prompt: 'You may ONLY use the provided source text to verify claims. If the source does not contain the information, mark the claim as ungrounded regardless of whether you believe it to be true.' Test with claims that are true but absent from the source.
Multi-Hop Inference Overreach
What to watch: The gate marks a claim as grounded when it requires combining two or more separate source statements through an inferential leap that the source never explicitly makes. The model fills in the logical gap. Guardrail: Distinguish between explicit support and inferred support in the output schema. Add a field for inference_required: true/false and set a policy rule: if inference is required and the claim is not a trivial deduction, route to human review or mark as ungrounded.
Negative Evidence Blindness
What to watch: The gate marks a claim as grounded because a source mentions the topic, but fails to detect that the source actually contradicts the claim. The presence of related text masks the contradiction. Guardrail: Add a contradiction check before the grounding check. Prompt: 'First, identify whether the source contradicts the claim. If it does, mark the claim as ungrounded and flag the contradiction. Only proceed to grounding verification if no contradiction exists.'
Claim Granularity Mismatch
What to watch: A compound sentence containing multiple factual assertions is treated as a single claim. The gate returns 'grounded' because one part is supported, masking that another part is a hallucination. Guardrail: Decompose input text into atomic claims before verification. Each atomic claim should contain exactly one verifiable fact. Run the gate on each atomic claim independently and aggregate results. A single ungrounded atomic claim fails the entire parent statement.
Evaluation Rubric
Criteria for evaluating the Hallucination Detection Gate Prompt's output quality before shipping. Each criterion includes a pass standard, failure signal, and test method to validate performance.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Claim Extraction Completeness | All factual claims in [MODEL_OUTPUT] are identified and listed in the verdict's claim array | Factual claims present in the output are missing from the verdict's claim list | Compare claim list against manual annotation of [MODEL_OUTPUT] across 50 samples; require recall >= 0.95 |
Source Evidence Mapping Accuracy | Each grounded claim maps to a specific [SOURCE_DOCUMENT] passage that directly supports the claim | A claim is marked grounded but the cited passage does not support it or is irrelevant | Human review of 100 grounded claim-source pairs; require precision >= 0.98 |
Paraphrased Support Detection | Claims supported by paraphrased or restructured source text are correctly classified as grounded | Paraphrased support is misclassified as ungrounded due to surface-level text mismatch | Curate 30 paraphrased-support test cases; require recall >= 0.90 on this subset |
Plausible Fabrication Rejection | Claims that sound plausible but lack source evidence are correctly classified as ungrounded | A fabricated claim is marked grounded because it sounds reasonable or uses domain-appropriate language | Inject 20 fabricated claims into test set; require false-positive rate <= 0.05 on fabricated claims |
Inference vs. Direct Support Distinction | Claims requiring inference beyond source text are flagged with inference_warning: true | Inferential claims are treated as directly grounded without noting the inference gap | Test 25 inference-required claims; require inference_warning flag rate >= 0.85 |
Verdict Structure Compliance | Output matches [OUTPUT_SCHEMA] exactly: binary verdict per claim, source mapping, and inference flag | Output is missing required fields, uses wrong types, or adds unschema'd fields | Schema validation check on 200 outputs; require structural compliance rate >= 0.99 |
Multi-Source Claim Handling | Claims supported by multiple sources cite all relevant passages in source_mapping array | Only one source is cited when multiple sources provide necessary support for the claim | Test 15 multi-source claims; require all-source citation rate >= 0.90 |
Negative Evidence Recognition | Claims contradicted by source material are classified as ungrounded with contradiction noted | Contradicted claims are marked grounded or ungrounded without contradiction flag | Curate 10 contradiction test cases; require contradiction detection rate >= 0.95 |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Add strict JSON schema validation, retry logic for malformed outputs, and structured logging of every verdict. Implement a claim-extraction step before the gate so the prompt receives pre-parsed claims rather than raw text.
Add a confidence threshold: if the model's grounding confidence is below 0.7, route to human review instead of auto-accepting. Store source-evidence mappings for audit trails.
Prompt modification
Add to [CONSTRAINTS]: "If evidence partially supports a claim but key details are missing, mark as ungrounded. When multiple sources are needed to fully support a claim, cite all required sources. If no source addresses the claim, mark as ungrounded immediately."
Watch for
- Silent format drift when model changes output structure under high load
- Missing human review escalation when confidence is borderline
- Source-evidence mappings that quote irrelevant passages
- Performance degradation with long context windows (many claims + many sources)

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us