This prompt is designed for a single, high-stakes job: verifying a RAG-generated answer against its source context after the answer has been produced but before it reaches the end user. The ideal user is a QA engineer, platform engineer, or AI architect implementing an automated release gate in a production pipeline. The required context is a complete, unmodified set of source documents or chunks that were used to generate the answer, alongside the final answer text itself. The prompt assumes the answer already exists; it does not assess whether the initial retrieval was sufficient, nor does it rewrite the answer to fix errors. Its sole purpose is to produce a structured audit report that flags unsupported statements, identifies missing citations, and detects factual contradictions, enabling a programmatic pass/fail decision.
Prompt
Post-Generation Factual Audit Prompt Template

When to Use This Prompt
Determine if the Post-Generation Factual Audit is the right tool for your release gate, and when a different verification strategy is required.
Use this prompt when factual accuracy is non-negotiable and the cost of a hallucination reaching a user is high—for example, in clinical decision support, legal research, financial analysis, or compliance documentation. It is particularly effective when you need a consistent, machine-readable verdict that can trigger automated actions: blocking a response, routing it for human review, or logging an incident. The prompt works best with capable instruction-following models (e.g., GPT-4, Claude 3.5 Sonnet) that can perform fine-grained textual alignment. You should wire the output into a validation layer that checks for the required JSON schema and retries on parse failures. For high-risk domains, always include a human review step for any answer that receives a FAIL verdict, and log the full audit report alongside the answer for auditability.
Do not use this prompt as a pre-generation evidence sufficiency check—that requires a different prompt designed to assess whether the retrieved context can answer the question at all. Do not use it to evaluate the stylistic quality, tone, or helpfulness of an answer; it is strictly a factual audit. Avoid using it on extremely long answers (e.g., multi-page reports) without first segmenting the answer into verifiable units, as the model's attention may degrade. If your primary concern is citation format compliance rather than factual accuracy, use a lighter-weight citation cross-reference prompt instead. Finally, remember that this prompt is a probabilistic guardrail, not a deterministic verifier—it reduces hallucination risk but does not eliminate it. Combine it with complementary checks like embedding-based semantic similarity and human sampling to build a defense-in-depth strategy.
Use Case Fit
Where the Post-Generation Factual Audit Prompt Template delivers value and where it introduces risk. Use these cards to decide if this audit gate fits your release pipeline.
Good Fit: Regulated Answer Delivery
Use when: You are shipping RAG answers in healthcare, legal, or finance where an unsupported claim creates compliance risk. Guardrail: Run the audit as a synchronous pre-release gate. Block delivery on any unsupported or contradiction finding until a human reviews the audit report.
Good Fit: Automated QA Pipelines
Use when: You need a repeatable, structured pass/fail signal for every generated answer before it reaches an eval dataset or end user. Guardrail: Map the audit output schema directly to your CI/CD eval assertions. Fail the build if audit_score < threshold or flagged_claims > 0.
Bad Fit: Real-Time Chat with Latency Budgets
Avoid when: User-facing chat requires sub-second response times. A full claim-by-claim audit adds significant latency. Guardrail: Use a lightweight, single-pass hallucination classifier for real-time gating. Reserve the full audit for async post-hoc review or batch QA runs.
Required Inputs
What you must provide: The generated answer text and the complete set of retrieved context passages used to produce it. Guardrail: If the retrieval pipeline drops source metadata, the audit cannot trace claims to evidence. Enforce that context includes document IDs and passage text in the prompt contract.
Operational Risk: Audit Hallucination
What to watch: The audit model itself can hallucinate when judging claims, especially on ambiguous or highly technical content. Guardrail: Never treat the audit output as ground truth. Run periodic inter-annotator agreement checks between the audit model and human reviewers. Escalate borderline cases to a human-in-the-loop queue.
Operational Risk: Context Window Overflow
What to watch: Long answers with many retrieved passages can exceed the audit model's context window, causing truncated or incomplete audits. Guardrail: Chunk the audit into sections if the combined answer and context exceed 80% of the model's context limit. Merge partial audit reports with a deduplication step.
Copy-Ready Prompt Template
A copy-ready prompt template for performing a structured factual audit of a RAG-generated answer against its source context.
The following prompt template is designed to be pasted directly into your audit harness. It instructs the model to act as a meticulous fact-checker, comparing a generated answer against the provided source context. The prompt is structured to produce a machine-readable JSON audit report, making it suitable for automated pass/fail gating in a CI/CD pipeline or a pre-release review step. Before using this template, ensure you have the generated answer, the exact retrieved context used to produce it, and the original user query.
textYou are an expert fact-checker auditing a generated answer for factual accuracy. Your task is to compare the answer against the provided source context and produce a structured audit report. ## INPUT **User Query:** [USER_QUERY] **Source Context (retrieved documents):** [SOURCE_CONTEXT] **Generated Answer:** [GENERATED_ANSWER] ## AUDIT INSTRUCTIONS 1. **Decompose the Answer:** Break the generated answer down into discrete, verifiable factual claims. 2. **Verify Each Claim:** For each claim, determine if it is **SUPPORTED**, **UNSUPPORTED**, or **CONTRADICTED** by the source context. A claim is SUPPORTED only if the context directly states it. A claim is UNSUPPORTED if the context is silent on the matter. A claim is CONTRADICTED if the context states the opposite. 3. **Check for Citations:** If the answer includes citations, verify that each cited source genuinely supports the claim it is attached to. Flag any citation fabrication. 4. **Identify Missing Information:** Note any part of the user query that the source context cannot answer, and check if the generated answer correctly abstains or acknowledges the gap. ## OUTPUT FORMAT Return a single JSON object with the following schema: { "audit_result": "PASS" | "FAIL", "overall_score": 0.0-1.0, "claims_audit": [ { "claim_text": "string", "verdict": "SUPPORTED" | "UNSUPPORTED" | "CONTRADICTED", "source_evidence": "string or null", "citation_valid": true | false | "N/A" } ], "flagged_issues": [ { "severity": "CRITICAL" | "MAJOR" | "MINOR", "type": "UNSUPPORTED_CLAIM" | "CONTRADICTION" | "CITATION_FABRICATION" | "MISSING_ABSTENTION", "description": "string" } ], "abstention_check": { "query_has_gap": true | false, "answer_abstained_correctly": true | false | "N/A", "explanation": "string" } } ## CONSTRAINTS - Base your audit strictly on the provided source context. Do not use outside knowledge. - If the source context is insufficient to verify a claim, the verdict must be UNSUPPORTED. - The overall_score should reflect the proportion of SUPPORTED claims, penalized heavily for CONTRADICTED claims. - Set audit_result to "FAIL" if any CRITICAL or MAJOR issue is found.
To adapt this template for your specific pipeline, replace the square-bracket placeholders with your actual data. The [SOURCE_CONTEXT] should be the exact text of the retrieved chunks, including any document IDs or metadata you want the model to reference. For high-stakes domains like healthcare or finance, you should add a [RISK_LEVEL] parameter and adjust the CONSTRAINTS section to require a higher evidence threshold for a PASS verdict. The JSON output schema is designed to be parsed by downstream validation code, which can enforce your team's specific pass/fail rules, such as a minimum overall_score or a zero-tolerance policy for CONTRADICTED claims.
After pasting this prompt, the next critical step is to validate the model's output against the expected schema. A malformed JSON response from the audit step should trigger a retry or a safe failure. For production systems, log every audit report alongside the answer and context to build a dataset for refining your RAG pipeline and your audit criteria. Do not treat this prompt as a substitute for human review in high-risk applications; instead, use it as a scalable first-pass filter to catch obvious hallucinations before they reach a human reviewer or end-user.
Prompt Variables
Required inputs for the Post-Generation Factual Audit Prompt. Validate each variable before sending to prevent runtime failures and ensure the audit is performed against the correct evidence.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[GENERATED_ANSWER] | The full text of the answer produced by the RAG system that needs to be audited. | The Paris Agreement was signed in 2016 and aims to limit global warming to 1.5 degrees Celsius above pre-industrial levels. | Must be a non-empty string. Check for null, empty, or whitespace-only values. Truncate if exceeding model context window after accounting for other variables. |
[SOURCE_CONTEXT] | The retrieved passages or documents that were provided to the generation model as grounding evidence. | Document_001: The Paris Agreement is a legally binding international treaty on climate change. It was adopted by 196 Parties at COP21 in Paris on 12 December 2015 and entered into force on 4 November 2016. | Must be a non-empty string. Validate that the context contains identifiable document or passage boundaries. If empty, abort audit and flag as insufficient evidence. |
[AUDIT_CRITERIA] | A list of specific checks the audit must perform, such as unsupported claims, missing citations, factual contradictions, or fabricated numbers. | Check for: 1) Claims not found in source context, 2) Contradictions with source context, 3) Fabricated dates or statistics, 4) Missing citations for factual assertions. | Must be a non-empty list or structured string. Validate that each criterion is actionable. If criteria include citation checks, ensure [SOURCE_CONTEXT] includes citation markers or document IDs to reference. |
[OUTPUT_SCHEMA] | The exact JSON schema or structured format the audit report must conform to for downstream automated gating. | {"audit_passed": boolean, "findings": [{"claim_text": string, "verdict": string, "source_evidence": string | null, "rationale": string}]} | Must be a valid JSON Schema or a precise natural-language description of required fields. Validate that the schema includes a pass/fail field and a findings array. Test parse the schema before runtime. |
[SEVERITY_THRESHOLD] | The minimum severity level at which a finding should cause the audit to fail. Allows tuning of the gate sensitivity. | FAIL_ON: critical_factual_error, contradiction. WARN_ON: minor_detail_fabrication, missing_citation. | Must be a defined list of severity labels that match the labels used in the audit prompt instructions. Validate that the labels are consistent with the [OUTPUT_SCHEMA] expected values. If null, default to failing on all findings. |
[CONSTRAINTS] | Additional behavioral rules for the audit, such as handling of direct quotes, treatment of common knowledge, or domain-specific evidence standards. | Do not flag widely known facts (e.g., 'Paris is the capital of France') as unsupported. Treat direct quotes from source context as fully supported. If a claim is a paraphrase, require close semantic alignment. | Must be a string or null. If provided, check for contradictions with [AUDIT_CRITERIA]. If null, the audit will apply default strict grounding rules. Ensure constraints do not weaken the gate to the point of uselessness. |
[CITATION_MAP] | A mapping from citation markers in the [GENERATED_ANSWER] to the specific source passages they reference. Required for citation integrity checks. | {"cite_1": "Document_001 paragraph 2", "cite_2": "Document_003 paragraph 5"} | Must be a valid JSON object or null. If [AUDIT_CRITERIA] includes citation checks, this field is required and must not be null. Validate that every key in the map appears as a citation marker in the [GENERATED_ANSWER]. |
[MODEL_INSTRUCTIONS] | System-level instructions that define the auditor role, output standards, and any refusal policies for the audit model itself. | You are a meticulous factual auditor. You must only flag claims that are definitively unsupported or contradicted. If evidence is ambiguous, note the ambiguity but do not fail the audit. | Must be a non-empty string. Validate that instructions do not conflict with [CONSTRAINTS] or [AUDIT_CRITERIA]. Ensure the audit model is instructed to output valid JSON conforming to [OUTPUT_SCHEMA]. |
Implementation Harness Notes
How to wire the Post-Generation Factual Audit into an automated release gate with validation, retries, and human escalation.
The Post-Generation Factual Audit prompt is designed to operate as a synchronous gate in your answer delivery pipeline. After the primary RAG system generates an answer, the raw output, the retrieved context passages, and the user's original query are all passed to this audit prompt before the answer reaches the user. The audit prompt's structured output—containing a pass/fail status, a list of flagged claims, and a severity breakdown—is parsed by your application to decide whether to release the answer, block it, or escalate for human review. Do not treat this as an offline evaluation step; it is a runtime guardrail that must complete within your latency budget.
To wire this into production, wrap the model call in a validation and retry layer. First, parse the model's JSON output against a strict schema that expects fields like audit_status, flagged_claims, and overall_severity. If the JSON is malformed or missing required fields, use an Output Repair prompt to fix the structure before proceeding. If the audit status is pass, release the answer. If the status is fail with a severity of critical or high, block the answer and log the full audit report for immediate review. For medium severity failures, you may choose to surface the answer with a caveat, but only if your product's risk tolerance explicitly allows it. Implement a retry budget of no more than two attempts: if the audit prompt itself fails to produce valid JSON after two repair attempts, escalate the entire request to a human review queue rather than silently passing a potentially flawed answer.
For teams running at scale, consider model routing for this audit step. A smaller, faster model can perform the initial claim extraction and grounding check, while a more capable model is reserved for ambiguous cases where the smaller model's confidence score falls below a defined threshold (e.g., below 0.85). Log every audit result—pass and fail—along with the prompt version, model identifier, and timestamp. These logs become your audit trail for governance and your dataset for improving the audit prompt itself. Avoid the temptation to skip the audit when latency spikes; instead, invest in prompt caching for the system instructions and source passages that remain stable across requests.
Expected Output Contract
Define the exact shape of the audit report so downstream gating logic can parse it reliably.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
audit_id | string (UUID v4) | Must parse as valid UUID v4. Reject if missing or malformed. | |
overall_verdict | enum: ['PASS', 'FAIL', 'UNCERTAIN'] | Must be one of the three allowed values. Reject any other string. | |
claims | array of claim objects | Must be a non-empty array. Reject if null or empty. | |
claims[].claim_text | string | Must be a non-empty string exactly matching a span from [ANSWER]. Reject if empty or not found in answer. | |
claims[].verdict | enum: ['SUPPORTED', 'UNSUPPORTED', 'CONTRADICTED', 'UNVERIFIABLE'] | Must be one of the four allowed values. Reject any other string. | |
claims[].source_evidence | array of strings | Each string must be a verbatim excerpt from [CONTEXT]. Reject if any excerpt is not found in context. | |
claims[].confidence | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or not a number. | |
flagged_statements | array of strings | If present, each string must be a verbatim sentence from [ANSWER]. Reject if any string is not found in answer. |
Common Failure Modes
Post-generation factual audits fail in predictable ways. Here are the most common failure modes when using an LLM to verify its own or another model's output, and how to guard against them.
Auditor Model Hallucinates the Audit
What to watch: The auditing model fabricates source spans, invents contradictions, or flags correct statements as unsupported. This is especially common when the provided context is long or complex. Guardrail: Always include a self-verification step where the auditor must quote the exact source text for each flagged issue. If the quoted text doesn't match the context, discard the flag.
False Negatives from Paraphrase Blindness
What to watch: The auditor marks a faithful paraphrase as unsupported because it doesn't share keywords with the source. This leads to an avalanche of false positives that erode trust in the gate. Guardrail: Explicitly instruct the auditor to assess semantic equivalence, not just lexical overlap. Include few-shot examples of valid paraphrases that should pass the audit.
Context Window Truncation Silently Drops Evidence
What to watch: When the answer plus all retrieved context exceeds the auditor model's context window, evidence is silently truncated. The auditor then flags statements as unsupported because it never saw the supporting passage. Guardrail: Implement a pre-audit context budget check. If the combined input exceeds 80% of the model's context limit, split the audit into chunked verification passes or reduce the context before auditing.
Auditor Inherits Generator's Bias
What to watch: The auditing model shares the same pre-training biases as the generator. Both models may agree on a plausible-sounding but factually incorrect statement, causing the audit to pass fabricated content. Guardrail: Use a different model family for auditing than for generation when possible. If using the same family, raise the audit temperature slightly and require explicit evidence quotes to disrupt shared confabulation patterns.
Citation Format Mismatch Causes Spurious Failures
What to watch: The auditor expects citations in a specific format (e.g., [1]) but the answer uses a different style (e.g., (Source A)). The auditor then reports missing citations even when they exist. Guardrail: Pass the expected citation format as an explicit field in the audit prompt. Include a pre-check step that normalizes citation references before the factual audit begins.
Compound Claim Confusion
What to watch: A sentence containing multiple factual claims is partially supported. The auditor issues a single pass/fail verdict for the entire sentence, obscuring which part failed. Guardrail: Require the auditor to decompose multi-claim sentences before verification. The output schema should support per-claim verdicts, not per-sentence verdicts. If decomposition isn't possible, flag compound sentences for manual review.
Evaluation Rubric
Use this rubric to test the Post-Generation Factual Audit Prompt Template before deploying it as a release gate. Each criterion targets a specific failure mode in automated audit reports.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Unsupported Claim Detection | Audit correctly flags a claim with zero evidence in [CONTEXT] as UNSUPPORTED | Claim marked as SUPPORTED when no source passage contains the fact | Inject a fabricated claim into [ANSWER]; verify audit report labels it UNSUPPORTED |
Citation Fabrication Detection | Audit identifies when a citation points to a source that does not contain the cited claim | Audit accepts a valid-looking citation for a claim the source never makes | Swap citation IDs so [CLAIM_A] cites [SOURCE_B]; verify audit flags the mismatch |
Missing Citation Flagging | Audit flags every factual assertion in [ANSWER] that lacks an inline citation | Audit passes an answer where a factual sentence has no citation marker | Strip one citation from a multi-claim answer; verify audit lists the unattributed assertion |
Contradiction Identification | Audit detects when [ANSWER] states the opposite of what [CONTEXT] says | Audit marks a directly contradictory statement as SUPPORTED or PARTIALLY_SUPPORTED | Modify a date or figure in [ANSWER] to conflict with [CONTEXT]; verify CONTRADICTED verdict |
Partial Support Handling | Audit correctly labels a claim as PARTIALLY_SUPPORTED when evidence covers only part of the claim | Audit rounds up to SUPPORTED when evidence is incomplete | Provide evidence for only one clause of a compound claim; verify PARTIALLY_SUPPORTED with rationale |
Empty Context Handling | Audit marks all claims as UNSUPPORTED when [CONTEXT] is empty or irrelevant | Audit hallucinates support by fabricating connections to empty context | Pass an empty string or irrelevant passage as [CONTEXT]; verify all claims flagged UNSUPPORTED |
Audit Report Schema Compliance | Output strictly matches the expected JSON schema with all required fields present | Output missing required fields, wrong types, or extra unstructured text outside the JSON | Parse the audit output with a schema validator; verify no missing keys, null where required, or type errors |
Confidence Score Calibration | Audit assigns a low confidence score when evidence is sparse or contradictory | Audit assigns high confidence to an answer with multiple unsupported claims | Feed an answer with 3 unsupported claims and 1 supported claim; verify overall confidence below 0.5 |
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 audit result. Implement a two-pass approach: first extract claims, then verify each claim independently. Wire the audit output into an automated release gate that blocks answers with any CONTRADICTED or high-severity UNSUPPORTED findings.
Prompt modification
json{ "system": "You are a production factual auditor. Your output must conform to the exact JSON schema provided. Do not deviate.", "schema": { "audit_report": { "claims": [{ "claim_text": "string", "verdict": "SUPPORTED|UNSUPPORTED|CONTRADICTED", "evidence_spans": ["string"], "confidence": 0.0-1.0 }], "overall_pass": "boolean", "failure_reasons": ["string"] } }, "retry_on_parse_failure": 2, "eval_threshold": {"precision": 0.90, "recall": 0.85} }
Watch for
- Silent format drift under high load or different input lengths
- Schema validation rejecting legitimate edge cases (null evidence for UNSUPPORTED)
- Retry loops consuming budget on consistently malformed outputs
- Missing human review escalation for borderline cases near the pass/fail threshold

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