Inferensys

Prompt

Hallucination-Detection Quote Comparison Prompt

A practical prompt playbook for using the Hallucination-Detection Quote Comparison Prompt in production AI guardrail and safety workflows.
ML engineer detecting AI hallucinations on laptop, fact-checking interface visible, technical debugging moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for hallucination detection via quote comparison.

This prompt is designed for AI safety engineers and guardrail developers who need to systematically detect hallucinations by comparing model-generated statements against source documents. The core job is to flag unsupported claims and produce structured outputs with missing-evidence indicators. You should use this prompt when you have a generated text that makes factual assertions and a set of source documents that should contain the supporting evidence. The ideal user is building a production validation pipeline where hallucination detection must operate as an automated guardrail before responses reach end users.

This prompt is not appropriate for open-ended creative generation, subjective opinion evaluation, or scenarios where source documents are unavailable. It requires both the generated statement and the source context as inputs. The prompt works best when source documents are well-structured, the claims are factual and verifiable, and you have a clear definition of what constitutes sufficient evidence. For high-stakes domains like healthcare, legal, or financial applications, you must pair this prompt with human review workflows and evidence grounding requirements. Do not rely solely on automated hallucination detection for regulated outputs.

Before implementing this prompt, ensure you have established evaluation criteria for precision and recall against human-annotated ground truth. The prompt outputs flagged spans with missing-evidence indicators, but the quality of detection depends heavily on the clarity of your evidence standards. Common failure modes include over-flagging legitimate paraphrases as hallucinations and missing subtle fabrications that sound plausible. You should calibrate the prompt against a golden dataset of known hallucinations and valid statements before deploying to production. The next step is to wire this prompt into your validation harness with proper logging, retry logic, and escalation paths for ambiguous cases.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not for comparing generated statements against source documents.

01

Good Fit: Pre-Release Hallucination Audits

Use when: You need to audit model-generated summaries or answers against source documents before shipping to users. Guardrail: Run this prompt on a stratified sample of outputs, not just random picks. Focus on high-risk claim types like numbers, dates, and named entities.

02

Bad Fit: Real-Time Chat Filtering

Avoid when: You need sub-100ms hallucination detection in a live chat stream. Guardrail: This prompt requires full source context and careful comparison, which adds latency. Use it in async validation pipelines, not in the critical path of user-facing chat.

03

Required Inputs: Verbatim Source Text

Risk: Running comparison on summarized or chunked source text introduces false positives. Guardrail: Always pass the exact source passage the model was supposed to use. If the source is a long document, pre-extract the relevant section before running this prompt.

04

Operational Risk: Over-Flagging Minor Paraphrases

Risk: The prompt may flag legitimate paraphrases as unsupported, creating alert fatigue. Guardrail: Calibrate the prompt with a tolerance instruction for semantic equivalence. Use a human-annotated calibration set to tune the threshold between paraphrase and fabrication.

05

Operational Risk: Missing Implicit Claims

Risk: The prompt may miss unsupported claims that are implied rather than stated explicitly. Guardrail: Add an explicit instruction to flag claims that require inference beyond the source. Pair this prompt with a separate coverage check that asks: 'What does the source NOT say?'

06

Pipeline Fit: Post-Generation Validation Layer

Risk: Treating this prompt as a one-off manual check instead of an automated harness. Guardrail: Wire this prompt into a regression test suite. Run it on every prompt change against a golden dataset of known hallucinations and faithful outputs. Block releases if hallucination detection precision drops.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for comparing model-generated statements against source documents to flag unsupported claims with missing-evidence indicators.

This prompt template is the core instruction set for a hallucination-detection guardrail. It takes a model-generated statement and one or more source documents, then outputs a structured verdict for each claim in the statement: supported, contradicted, or unsupported. The template is designed to be dropped into an evaluation harness, a post-generation validation step, or a real-time safety filter before responses reach users. It forces the model to cite exact evidence spans and explain its reasoning, making every flag auditable.

Below is the copy-ready template. Replace each square-bracket placeholder with your application's specific inputs, output schema, and constraints before use. The template assumes you are comparing a single generated statement against a set of source documents. For multi-statement analysis, wrap this in a loop or batch call with per-statement context windows.

text
You are a hallucination-detection auditor. Your task is to compare a model-generated statement against provided source documents and flag every claim that lacks support, contradicts the sources, or fabricates details not present in the evidence.

## INPUT

**Generated Statement:**
[STATEMENT]

**Source Documents:**
[DOCUMENTS]

Each source document includes a unique [DOC_ID] and its full text. Use only these documents as ground truth.

## OUTPUT SCHEMA

Return a JSON object with the following structure:

{
  "statement_under_review": "[STATEMENT]",
  "claims": [
    {
      "claim_text": "Exact claim extracted from the statement",
      "verdict": "supported | contradicted | unsupported",
      "supporting_quote": "Verbatim quote from source or null",
      "source_doc_id": "[DOC_ID] or null",
      "reasoning": "Brief explanation of why the verdict applies",
      "confidence": "high | medium | low"
    }
  ],
  "overall_hallucination_risk": "none | low | medium | high | critical",
  "summary": "One-sentence summary of findings"
}

## CONSTRAINTS

[CONSTRAINTS]

Default constraints if none provided:
- Flag any claim not directly supported by a verbatim quote from the sources as "unsupported."
- If a claim directly contradicts a source, mark it "contradicted" and quote the conflicting passage.
- Do not infer, assume, or fill gaps. Absence of evidence means "unsupported."
- If the statement contains multiple claims, decompose them and evaluate each independently.
- Set confidence to "low" when the source text is ambiguous or the claim is partially supported.
- If no source documents are provided, mark all claims as "unsupported" with confidence "high."

## EXAMPLES

[EXAMPLES]

## RISK LEVEL

[RISK_LEVEL]

Default risk handling:
- For "high" or "critical" overall risk, recommend blocking the response and logging the incident.
- For "medium" risk, recommend human review before release.
- For "low" or "none," the response may proceed with caution.

To adapt this template, start by defining your [CONSTRAINTS] block. If your use case requires strict verbatim matching, add a rule that quotes must match character-for-character. If you allow paraphrased support, specify the acceptable degree of semantic equivalence and require the model to explain the paraphrase mapping. The [EXAMPLES] block is critical for calibration: include at least one example each of a supported claim, a contradicted claim, and an unsupported claim with the correct output shape. Without examples, the model may conflate "unsupported" with "contradicted" or over-attribute support to vaguely related passages. The [RISK_LEVEL] block should align with your product's tolerance for false negatives. In safety-critical domains, lower the threshold for "critical" risk and always require human review for anything above "low."

Before deploying, validate that the output JSON matches the schema exactly. A common failure mode is the model omitting the supporting_quote field when the verdict is "unsupported"—explicitly require null rather than an empty string to avoid parsing errors downstream. Also test edge cases: empty source lists, statements with no factual claims (e.g., greetings), and documents in languages that differ from the statement. Each of these should produce a predictable, schema-compliant output rather than a refusal or malformed JSON. Wire the output into your logging and observability pipeline so you can track hallucination rates by model version, prompt version, and document source over time.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Hallucination-Detection Quote Comparison Prompt. Each variable must be populated before the prompt is sent. Validation notes describe how to check input quality and catch common failures before execution.

PlaceholderPurposeExampleValidation Notes

[MODEL_STATEMENT]

The generated claim or sentence to verify against source documents

The patient presented with acute hypertension requiring immediate intervention.

Must be a single atomic claim. Split multi-claim paragraphs before comparison. Reject if empty or exceeds 500 characters.

[SOURCE_DOCUMENT]

The reference text that should contain supporting or contradicting evidence

Clinical note from 2024-03-15: Patient BP 180/110. Administered lisinopril 10mg. Patient stable.

Must be non-empty. Truncate to 4000 tokens max. Strip non-printable characters. Log document ID and retrieval rank for provenance.

[SOURCE_METADATA]

Document provenance fields required for audit trail and authority scoring

{"doc_id": "note-4512", "date": "2024-03-15", "author": "Dr. Chen", "source_type": "clinical_note"}

Validate JSON parse. Require doc_id and date fields. Reject if date is in the future or doc_id is missing. Null allowed for author if unavailable.

[COMPARISON_MODE]

Controls whether the prompt checks for support, contradiction, or both

support_only

Must be one of: support_only, contradiction_only, full_comparison. Reject unknown values. Default to full_comparison if null.

[CONFIDENCE_THRESHOLD]

Minimum confidence score required to flag a statement as supported or contradicted

0.75

Must be a float between 0.0 and 1.0. Reject values outside range. Default to 0.7 if null. Lower thresholds increase false positives; higher thresholds increase missed hallucinations.

[OUTPUT_SCHEMA]

Expected JSON structure for the comparison result

{"statement": "string", "verdict": "supported|contradicted|insufficient_evidence", "matched_quote": "string|null", "confidence": 0.0-1.0, "reasoning": "string"}

Validate schema before prompt assembly. Reject if required fields missing. Use this schema to parse and validate model output after generation.

[FEW_SHOT_EXAMPLES]

Optional demonstration pairs showing correct comparison behavior

[{"statement": "Patient was discharged.", "source": "Discharge order placed at 14:00.", "verdict": "supported", "quote": "Discharge order placed at 14:00.", "confidence": 0.92}]

Null allowed. If provided, validate each example has all required fields. Limit to 3 examples to avoid context bloat. Check that examples match the comparison_mode setting.

[ABSTENTION_RULES]

Conditions under which the prompt should return insufficient_evidence rather than guessing

If no sentence in source addresses the statement topic, return insufficient_evidence. If source mentions topic but lacks specific detail, return insufficient_evidence with confidence below 0.5.

Must be non-empty string. Review for clarity: vague abstention rules cause the model to over-flag or under-flag. Test against known edge cases before production deployment.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Hallucination-Detection Quote Comparison Prompt into an AI safety guardrail or output validation pipeline.

The Hallucination-Detection Quote Comparison Prompt is not a standalone tool; it is a guardrail component designed to sit between a primary model's output and the end user. In a production pipeline, the prompt receives a generated statement and the source document that supposedly supports it, then returns a structured verdict with flagged spans and missing-evidence indicators. The harness must enforce that every claim entering this check is paired with its exact source context—passing a summary or a different document defeats the purpose. This prompt is most effective when deployed as a synchronous validation step: the primary model generates a response, the harness extracts individual factual claims, and each claim is routed through the comparison prompt before the response is released.

To integrate this prompt into an application, wrap it in a validation function that accepts a [STATEMENT] and [SOURCE_DOCUMENT] pair, calls the model, and parses the structured output against a strict schema. The output should include a verdict field (SUPPORTED, UNSUPPORTED, CONTRADICTED), a list of flagged_spans with character offsets, and a missing_evidence array describing what the source lacks. Implement a retry layer: if the model returns malformed JSON or fails to produce the required fields, retry once with a repair prompt that includes the raw output and the schema. Log every comparison result—statement, source excerpt, verdict, and raw model response—for audit and eval. For high-risk domains such as legal or healthcare, route UNSUPPORTED and CONTRADICTED verdicts to a human review queue before the response reaches the user. Never auto-approve a statement that the comparison prompt flags as unsupported.

Model choice matters. Use a model with strong instruction-following and structured output capabilities, such as GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro. Avoid smaller or older models that may hallucinate the comparison itself. Set temperature=0 to maximize consistency across repeated checks. If latency is a concern, batch multiple statement-source pairs into a single call with an array input, but ensure each pair is independently evaluated and the output array preserves ordering. For evaluation, build a golden dataset of statement-source pairs with human-annotated verdicts and flagged spans. Measure precision and recall of hallucination detection against these annotations, and monitor drift over time as models and source documents change. The harness should also track the rate of UNSUPPORTED verdicts—a sudden spike may indicate a retrieval failure upstream, not a prompt problem.

The most common failure mode is source misalignment: the harness passes a source document that is related but not the exact text the primary model used. Prevent this by anchoring every generated claim to a specific source span at generation time, then passing that exact span to the comparison prompt. Another failure mode is the comparison model hallucinating a contradiction where none exists, often due to nuanced language or implicit context. Mitigate this by including a [CONSTRAINTS] field that instructs the model to flag only clear, unambiguous contradictions and to mark borderline cases as UNCERTAIN with an explanation. Finally, do not use this prompt as the sole hallucination defense. Combine it with retrieval quality checks, answer grounding verification, and user-facing uncertainty signals. The comparison prompt is one layer in a defense-in-depth strategy, not a silver bullet.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the hallucination detection output. Use this contract to parse, validate, and route the model response before it reaches downstream consumers or human reviewers.

Field or ElementType or FormatRequiredValidation Rule

[STATEMENT_ID]

string

Must match a statement ID from the input [STATEMENTS] array. Parse check: non-empty, alphanumeric with hyphens or underscores.

[STATEMENT_TEXT]

string

Must be an exact substring match of the original statement text from the input. Schema check: string equality comparison against source.

[VERDICT]

enum: SUPPORTED | UNSUPPORTED | CONTRADICTED | INSUFFICIENT_EVIDENCE

Must be one of the four allowed enum values. Parse check: case-sensitive exact match. No free-text or null allowed.

[SUPPORTING_QUOTE]

string or null

Required when [VERDICT] is SUPPORTED or CONTRADICTED. Must be a verbatim substring from [SOURCE_DOCUMENT]. Null allowed for UNSUPPORTED or INSUFFICIENT_EVIDENCE. Validation: substring search against source text.

[QUOTE_SOURCE_SPAN]

object: {start: int, end: int} or null

Required when [SUPPORTING_QUOTE] is present. Start and end must be valid character offsets within [SOURCE_DOCUMENT]. Null allowed when quote is null. Parse check: start < end, both non-negative integers.

[CONFIDENCE_SCORE]

float between 0.0 and 1.0

Must be a number between 0.0 and 1.0 inclusive. Parse check: numeric type, within bounds. Values below 0.5 should correlate with UNSUPPORTED or INSUFFICIENT_EVIDENCE verdicts.

[REASONING]

string

Must be a non-empty explanation of why the verdict was reached. Minimum 20 characters. Should reference specific evidence presence or absence. No validation on content, only length and non-null check.

[MISSING_EVIDENCE_INDICATOR]

boolean

Must be true when [VERDICT] is UNSUPPORTED or INSUFFICIENT_EVIDENCE, false otherwise. Schema check: boolean type. Cross-field validation against [VERDICT].

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when comparing model-generated statements against source documents, and how to guard against it.

01

Semantic Similarity Over Factual Equivalence

What to watch: The model flags a statement as supported because it shares keywords or topic with a source passage, even when the factual claim is different or inverted. Guardrail: Require the prompt to output a strict entailment direction (source entails claim, contradicts, or is neutral) rather than a similarity score. Validate with adversarial pairs that swap entities, quantities, or polarity.

02

Source-Statement Boundary Blurring

What to watch: The model treats its own generated explanation as evidence, hallucinating support by paraphrasing the claim back as if it were a source quote. Guardrail: Enforce a strict output schema that separates source_quote (verbatim from document) from model_reasoning. Add a validator that checks whether the quote string actually appears in the provided source text before accepting the output.

03

Silent Abstention on Missing Evidence

What to watch: When no source passage supports a claim, the model fabricates a plausible quote or marks it as supported with low confidence instead of explicitly flagging it as unsupported. Guardrail: Include a required evidence_found boolean field in the output schema. Add few-shot examples where the correct output is evidence_found: false with an empty quote array. Test with claims that have zero support in the provided documents.

04

Partial Match Over-Confidence

What to watch: The model finds a source that supports one part of a compound claim and marks the entire claim as supported, ignoring unsupported sub-claims. Guardrail: Decompose the target claim into atomic sub-claims before comparison. Require the prompt to evaluate each sub-claim independently and produce a per-claim support verdict. Aggregate only after individual verification.

05

Temporal Context Collapse

What to watch: A source from 2019 supports a claim that was true then but is false now, and the model does not detect the temporal mismatch. Guardrail: Include source publication date in the prompt context and add a temporal relevance check instruction. Require the output to flag when a supporting quote is older than a specified freshness threshold for time-sensitive claims.

06

Negation and Modality Blindness

What to watch: The model misses negation words, hedging language, or modal verbs in the source, treating 'may cause' as equivalent to 'causes' or 'did not find' as 'found'. Guardrail: Add explicit instructions to highlight and preserve negation, hedging, and modality markers. Include few-shot examples where the correct verdict hinges on a single negation word. Use a post-processing check that scans extracted quotes for negated versions of the claim.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of hallucination-detection outputs before shipping. Each criterion targets a specific failure mode in quote comparison guardrails. Run these tests against a golden dataset of human-annotated claim-evidence pairs.

CriterionPass StandardFailure SignalTest Method

Unsupported Claim Recall

= 0.95 recall of human-annotated unsupported claims

Guardrail passes unsupported claims as grounded

Compare flagged spans against human annotations on 100+ claim-evidence pairs

Supported Claim Precision

= 0.90 precision on claims flagged as unsupported

Guardrail flags claims that are actually supported by the source

Check each flagged span against source text; count false positives

Span Boundary Accuracy

Extracted span matches human-annotated span within +/- 10 characters

Flagged span includes extraneous text or truncates the unsupported portion

Compute character-level overlap between flagged span and ground-truth span

Missing-Evidence Indicator Presence

Every flagged claim includes a non-null missing-evidence indicator

Flagged claim has null or empty evidence-gap field

Schema validation check on [MISSING_EVIDENCE_INDICATOR] field in output

Source Grounding Fidelity

Every flagged span references the correct [SOURCE_DOCUMENT_ID]

Flagged span cites wrong source or hallucinated document ID

Cross-reference [SOURCE_DOCUMENT_ID] against test dataset source mapping

Abstention Correctness

Guardrail abstains when [SOURCE_DOCUMENTS] is empty or irrelevant

Guardrail produces flags when no valid source context exists

Test with empty [SOURCE_DOCUMENTS] and irrelevant-document inputs

Output Schema Compliance

Output matches [OUTPUT_SCHEMA] with all required fields present and typed correctly

Missing fields, wrong types, or extra fields in output JSON

Validate output against JSON Schema; reject on schema violation

Latency Threshold

Guardrail completes within 500ms for single claim-document pair

Response time exceeds 500ms in production-like conditions

Benchmark with 100 requests at p50, p95, p99 latency percentiles

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Wrap the prompt in a validation harness with schema enforcement, retry logic, and structured logging. Add a [CONFIDENCE_THRESHOLD] parameter so downstream systems can filter low-confidence flags. Run the prompt against a golden dataset of 200+ annotated examples and track precision, recall, and F1 per category (fabrication, contradiction, unsupported inference).

Prompt modification

  • Add strict [OUTPUT_SCHEMA] with required fields: flagged_span, claim_text, source_quote, hallucination_type, confidence_score, reasoning.
  • Include a [FEW_SHOT_EXAMPLES] section with 3-5 annotated cases covering fabrication, contradiction, and faithful paraphrase.
  • Add an abstention instruction: if the model cannot determine support status, it must output "verdict": "uncertain" rather than guessing.

Watch for

  • Silent format drift when the model returns extra fields or nests objects differently.
  • Confidence scores that don't calibrate—0.9 confidence on wrong flags erodes trust.
  • Missing human review for high-severity flags before they block downstream responses.
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.