This prompt is designed for evaluation engineers and AI reliability teams who need to automate the comparison of a model-generated output against a known-correct reference answer. The core job-to-be-done is producing a structured, machine-readable consistency score with span-level annotations that decompose the model output into atomic claims, align each claim to the reference, and flag unsupported or contradictory statements. The ideal user is someone integrating this prompt into a CI/CD gate for regression testing, benchmark maintenance, or pre-release validation where an authoritative 'golden answer' exists and any deviation must be measured precisely, not just flagged as a binary pass/fail.
Prompt
Factual Consistency Against Reference Prompt Template

When to Use This Prompt
Defines the ideal scenario, user, and prerequisites for deploying the Factual Consistency Against Reference prompt in an automated evaluation pipeline.
Use this prompt when you have a stable, curated set of reference answers and need diagnostic detail to debug model drift. It is particularly effective in domains where partial credit matters—for example, a model might get the core fact right but hallucinate a supporting detail, and you need to capture both signals. The prompt expects a structured [MODEL_OUTPUT] and a [REFERENCE_ANSWER] as inputs, and it returns a consistency score alongside a claim-by-claim audit trail. This output can be consumed directly by an evaluation harness to block a release if the consistency score drops below a configured threshold or if a critical hallucination is detected.
Do not use this prompt when no authoritative reference answer is available, when the reference itself is contested or ambiguous, or when you only need a simple binary pass/fail without diagnostic detail. It is also unsuitable for evaluating creative or open-ended generation where multiple valid outputs exist without a single ground truth. In those cases, consider a pairwise comparison or rubric-based judge instead. For high-risk domains such as healthcare or legal review, always route flagged contradictions to a human reviewer before taking action, and ensure the reference answers themselves are subject to expert validation.
Use Case Fit
This prompt template is designed for automated fact-checking pipelines where a model output must be compared against a known-correct reference answer. It works best in high-precision evaluation environments and breaks down when applied to open-ended creative tasks or when a reliable reference does not exist.
Good Fit: Regression Testing
Use when: You have a golden dataset of reference answers and need to automatically detect factual regressions in a new model or prompt version. Guardrail: Ensure your reference dataset covers edge cases and is version-locked to prevent drift in your ground truth.
Good Fit: RAG Output Verification
Use when: Validating that a RAG system's final answer is factually consistent with the specific source document it was meant to summarize. Guardrail: The reference must be the exact source chunk, not a paraphrased summary, to avoid false positives in the consistency check.
Bad Fit: Creative Content Evaluation
Avoid when: Evaluating creative writing, marketing copy, or brainstorming outputs where there is no single "correct" answer. Risk: The prompt will penalize stylistic variation as factual inconsistency, producing misleadingly low scores.
Required Input: Authoritative Reference
What to watch: The prompt is entirely dependent on the quality of the [REFERENCE_ANSWER]. An incomplete or poorly written reference will cause the judge to incorrectly flag correct statements as hallucinations. Guardrail: Implement a human-review step for the reference data before it enters the automated pipeline.
Operational Risk: High Token Costs
What to watch: Processing long documents with span-level annotations can significantly increase token consumption and latency. Guardrail: Set a maximum length for both the [MODEL_OUTPUT] and [REFERENCE_ANSWER] and use a pre-filter to reject inputs that exceed the budget before calling the judge model.
Operational Risk: Judge Model Bias
What to watch: The LLM judge may exhibit a bias toward longer, more verbose outputs or a specific writing style, mistaking fluency for factual accuracy. Guardrail: Calibrate the judge against a human-annotated dataset to measure its correlation and detect systematic biases before relying on its scores for gating decisions.
Copy-Ready Prompt Template
A production-ready prompt for comparing a model output against a reference answer to produce a structured consistency score with span-level annotations.
This prompt template is the core of your factual consistency evaluation pipeline. It instructs the model to act as a meticulous fact-checker, comparing a generated [MODEL_OUTPUT] against a known-correct [REFERENCE_ANSWER]. The prompt is designed to produce a structured JSON report that includes an overall consistency score, a detailed breakdown of supported, unsupported, and contradicted claims, and specific text spans from the output that are in question. This structured output is essential for automated downstream processing, such as flagging hallucinations for human review or calculating aggregate precision and recall metrics across a test suite.
textYou are an expert fact-checker evaluating the factual consistency of a model-generated output against a verified reference answer. Your task is to produce a structured analysis that can be used for automated quality assurance. # INPUTS [MODEL_OUTPUT]: The text to be evaluated. [REFERENCE_ANSWER]: The verified, ground-truth text to compare against. [EVALUATION_CONTEXT]: Any additional context or instructions for the evaluation. # INSTRUCTIONS 1. **Decompose**: Break down the [MODEL_OUTPUT] into a list of discrete, verifiable factual claims. 2. **Compare**: For each claim, determine its relationship to the [REFERENCE_ANSWER]. Use the following labels: - **SUPPORTED**: The claim is directly stated in or can be logically inferred from the reference. - **UNSUPPORTED**: The claim introduces new information not present in the reference. - **CONTRADICTED**: The claim directly conflicts with information in the reference. 3. **Annotate**: For each claim, provide the exact text span from the [MODEL_OUTPUT] that contains the claim. 4. **Score**: Calculate an overall factual consistency score on a scale of 0.0 to 1.0, where 1.0 means all claims are fully supported. The formula is: `(Number of SUPPORTED claims) / (Total number of claims)`. 5. **Flag**: If any claim is CONTRADICTED, set a high-priority `hallucination_flag` to `true`. # CONSTRAINTS - Do not penalize the [MODEL_OUTPUT] for omitting information that is present in the [REFERENCE_ANSWER]. Only evaluate the claims that are actually made. - Treat synonymous phrasing as SUPPORTED. - If the [MODEL_OUTPUT] is empty or nonsensical, return a score of 0.0 and an appropriate error message. # OUTPUT_SCHEMA You must respond with a single valid JSON object conforming to this schema: { "consistency_score": <float 0.0-1.0>, "hallucination_flag": <boolean>, "claim_analysis": [ { "claim_text": "<exact text span from model output>", "verdict": "<SUPPORTED|UNSUPPORTED|CONTRADICTED>", "rationale": "<brief explanation referencing the reference answer>" } ], "error_message": "<null or a string if the output could not be evaluated>" }
To adapt this template, replace the square-bracket placeholders with your actual data. The [MODEL_OUTPUT] and [REFERENCE_ANSWER] are the core inputs. The [EVALUATION_CONTEXT] placeholder is optional but powerful; use it to inject domain-specific rules, such as "ignore differences in date formatting" or "the reference answer is the definitive source for all statistical figures." Before integrating this into a CI/CD pipeline, run it against a small, hand-labeled golden dataset to calibrate the consistency_score threshold that constitutes a "pass" for your specific use case. A score of 0.9 might be acceptable for a summarization task, while a score of 1.0 might be required for a regulated financial report.
Prompt Variables
Required inputs for the Factual Consistency Against Reference prompt. Each placeholder must be populated before execution. Validation notes describe how to verify the input is well-formed before sending it to the model.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[MODEL_OUTPUT] | The generated text to evaluate for factual consistency against the reference | The capital of France is Paris, a city known for its cuisine. | Must be a non-empty string. Check length > 0. If null or empty, skip evaluation and log an input error. |
[REFERENCE_ANSWER] | The known-correct or authoritative answer to compare against | Paris is the capital of France. | Must be a non-empty string. Verify source provenance before use. If the reference is unverified, flag the evaluation result as low-confidence. |
[FACT_TYPES] | A list of fact categories to check, controlling what the evaluator looks for | ["entity", "numeric", "temporal", "causal"] | Must be a valid JSON array of strings. Allowed values: entity, numeric, temporal, causal, definition, procedural. Reject unknown types before execution. |
[SCORING_MODE] | Controls whether scoring is binary, partial-credit, or severity-weighted | partial_credit | Must be one of: binary, partial_credit, severity_weighted. Default to partial_credit if missing. Reject unrecognized values. |
[CONTRADICTION_SEVERITY_THRESHOLD] | Minimum severity level for flagging a contradiction as a failure | major | Must be one of: minor, major, critical. Contradictions at or above this level trigger a failure flag. Use critical for regulated domains. |
[OUTPUT_SCHEMA] | The expected JSON structure for the evaluation result | {"consistency_score": float, "claims": [...], "flags": [...]} | Must be a valid JSON Schema or example object. Validate parseability before sending. If missing, use the default schema from the playbook harness. |
[DOMAIN_CONTEXT] | Optional domain-specific terminology or constraints to improve judgment accuracy | Medical: 'hypertension' and 'high blood pressure' are equivalent. | Can be null. If provided, must be a non-empty string. Use to define synonym mappings and domain-specific equivalence rules. |
Implementation Harness Notes
How to wire the factual consistency prompt into an automated evaluation pipeline with validation, retries, and human review gates.
This prompt is designed to be called programmatically as a judge model within a CI/CD or batch evaluation pipeline, not as a one-off chat interaction. The harness should treat the LLM call as a deterministic function: input a model output and a reference answer, receive a structured consistency score with span-level annotations. The primary integration points are the evaluation runner (which iterates over test cases), the prompt rendering layer (which injects [MODEL_OUTPUT] and [REFERENCE_ANSWER] into the template), and the result consumer (which stores scores, flags hallucinations, and triggers alerts).
Validation and retry logic is critical because the output schema includes nested objects and enum-constrained fields. Implement a JSON schema validator that checks for the presence of overall_score, claim_annotations array, and correct enum values for verdict (must be one of supported, partially_supported, contradicted, unsupported). If validation fails, retry up to 2 times with the error message appended to the prompt as a correction hint. If the third attempt still fails, log the raw output and escalate for human review. For high-stakes domains like healthcare or finance, configure the harness to require human sign-off on any output where overall_score falls below 0.8 or where contradicted verdicts appear.
Model choice matters for this task. Use a model with strong instruction-following and structured output capabilities (GPT-4o, Claude 3.5 Sonnet, or equivalent). Set temperature=0 to maximize reproducibility across runs. If you're processing thousands of comparisons, implement batching with asynchronous calls and a concurrency limit appropriate for your API tier. Store every evaluation result—including the raw prompt, model response, parsed score, and validation status—in a structured log or database table. This traceability is essential for debugging score drift, auditing judge performance, and defending evaluation results to stakeholders. Avoid running this prompt on outputs that exceed the judge model's context window; if the combined [MODEL_OUTPUT] and [REFERENCE_ANSWER] exceed ~60% of the context limit, chunk the content or summarize before comparison.
Expected Output Contract
Defines the structured JSON output that the Factual Consistency Against Reference prompt must produce. Use this contract to validate responses in your evaluation pipeline before computing aggregate scores.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
consistency_score | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or non-numeric. | |
overall_judgment | enum: consistent | partially_consistent | inconsistent | Must match one of the three enum values exactly. Reject on case mismatch or unknown value. | |
summary | string | Must be non-empty and between 20 and 500 characters. Reject if null, empty, or exceeds length limit. | |
claim_annotations | array of objects | Must be a non-empty array. Reject if null, empty, or not an array. Each element must conform to the claim_annotation schema below. | |
claim_annotations[].claim_text | string | Must be a non-empty string extracted verbatim from the model output. Reject if null or empty. | |
claim_annotations[].reference_span | string or null | If grounded, must contain an exact substring from the reference answer. If hallucinated, must be null. Reject if non-null but span not found in reference. | |
claim_annotations[].verdict | enum: grounded | unsupported | contradicted | Must match one of the three enum values exactly. Reject on case mismatch or unknown value. | |
claim_annotations[].confidence | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or non-numeric. |
Common Failure Modes
Factual consistency evaluation fails in predictable ways. These are the most common failure modes when comparing model outputs against reference answers, with practical mitigations for each.
Paraphrase Penalized as Inconsistency
What to watch: The judge marks semantically equivalent statements as inconsistent because wording differs from the reference. This inflates false-positive inconsistency rates and punishes valid rewrites. Guardrail: Include explicit instructions to distinguish meaning-preserving paraphrases from factual deviations. Calibrate with a paraphrase tolerance threshold and validate against human judgments on rewrites.
Omission Confused with Contradiction
What to watch: The judge treats missing information as contradictory information, assigning high severity to simple omissions. This distorts scoring and misleads debugging efforts. Guardrail: Use separate scoring dimensions for omission versus contradiction. Require the judge to label each flagged item with a category—missing, contradicted, or unsupported—before assigning severity.
Reference Bias in Multi-Reference Evaluation
What to watch: When multiple valid reference answers exist, the judge anchors on the first or most detailed reference and penalizes correct answers that match a different valid reference. Guardrail: Score against all references and take the best match. Include an inter-reference agreement check to flag when references themselves conflict, and surface those cases for human review.
Numerical Near-Miss Misclassification
What to watch: The judge treats numerically close values as incorrect when they fall within acceptable tolerance ranges, especially for financial, scientific, or engineering outputs. Guardrail: Define explicit tolerance bands per metric type. Include unit-awareness instructions and require the judge to report both the reference value and the output value with the computed delta before deciding consistency.
Span Grounding Drift in Long Documents
What to watch: The judge claims a statement is supported by the reference but points to the wrong span or a span that doesn't actually support the claim. This creates false confidence in hallucinated content. Guardrail: Require exact quote extraction from the reference for each grounded claim. Add a secondary verification step that checks whether the quoted span genuinely supports the claim before accepting the grounding.
Confidence Miscalibration on Ambiguous Claims
What to watch: The judge assigns high confidence to consistency judgments on genuinely ambiguous claims where reasonable evaluators would disagree. This hides edge cases that need human review. Guardrail: Include an uncertainty instruction requiring the judge to flag claims where the reference is ambiguous, incomplete, or open to interpretation. Route flagged claims to human review and track disagreement rates to calibrate future thresholds.
Evaluation Rubric
Use this rubric to test whether the factual consistency prompt produces reliable, actionable scores and annotations. Each criterion defines a pass standard, a failure signal, and a concrete test method to run before shipping the prompt into a production pipeline.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Score Range Adherence | Output score is an integer between 0 and 5 inclusive | Score is missing, null, float, or outside 0-5 range | Parse output JSON; assert score field exists, is integer, 0 <= score <= 5 |
Span-Level Annotation Completeness | Every claim in [MODEL_OUTPUT] has a corresponding entry in the annotations array with start_char, end_char, and verdict | Annotations array is empty, missing entries for identifiable claims, or contains unresolved character offsets | Count claims in [MODEL_OUTPUT]; assert annotations array length matches; verify each annotation has non-null start_char, end_char, verdict |
Verdict Vocabulary Compliance | Every annotation verdict is exactly one of: 'supported', 'partially_supported', 'contradicted', 'unsupported' | Verdict contains typos, synonyms like 'correct', or custom labels outside the allowed set | Extract all verdict values; assert set is subset of allowed vocabulary |
Evidence Span Grounding | Each annotation includes an evidence_span field that quotes the exact text from [REFERENCE_ANSWER] supporting the verdict | evidence_span is null, paraphrased, or contains text not present in [REFERENCE_ANSWER] | For each annotation, check evidence_span is substring of [REFERENCE_ANSWER]; fail if any span is absent or hallucinated |
Partial Credit Justification | When verdict is 'partially_supported', the justification field explains which sub-claim is supported and which is not | justification is empty, generic, or repeats the verdict without decomposition | Filter annotations where verdict equals 'partially_supported'; assert justification length > 50 characters and contains specific claim breakdown |
Hallucination Flagging Accuracy | All 'contradicted' or 'unsupported' verdicts appear in the top-level hallucinations array with severity and explanation | hallucinations array is empty when annotations contain contradicted or unsupported claims | Cross-reference annotations with hallucinations array; assert every contradicted or unsupported annotation has a corresponding hallucination entry |
Output Schema Validity | Full JSON output validates against the expected schema: score, annotations array, hallucinations array, summary string | Missing required fields, extra fields, or wrong types cause parse failure | Validate output against JSON Schema; assert no validation errors |
Summary Alignment with Score | The summary field textually explains the score and references the most critical findings | Summary is boilerplate, contradicts the score, or ignores major hallucinations | LLM-as-judge check: prompt a separate model to verify summary consistency with score and hallucination count; assert agreement |
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
Use the base prompt with a single reference answer and lighter validation. Drop the span-level annotation requirement and request only a consistency score with a one-sentence justification. Run against 10–20 examples to calibrate thresholds before adding complexity.
codeCompare the [MODEL_OUTPUT] to the [REFERENCE_ANSWER]. Return a consistency score from 0–100 and a one-line explanation.
Watch for
- Scores that look plausible but lack evidence grounding
- No distinction between omission and contradiction
- Overly generous scoring on vague outputs that happen to not conflict

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