Inferensys

Prompt

Model Hallucination Detection and Escalation Prompt

A practical prompt playbook for using Model Hallucination Detection and Escalation Prompt in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Model Hallucination Detection and Escalation Prompt.

This prompt is designed for AI reliability engineers and operations teams who need to systematically detect and escalate model hallucinations in production outputs. The primary job-to-be-done is comparing a model's generated claims against a provided ground-truth context or a set of known facts, then producing a structured severity score and a list of specific, unsupported claims that require human review. The ideal user is someone monitoring an AI pipeline—such as a RAG system, a summarization service, or a customer-facing chatbot—who needs an automated, auditable signal to trigger a human-in-the-loop intervention before a hallucinated output reaches an end user or is written to a system of record.

Use this prompt when you have a reliable source of truth available at inference time, such as a retrieved document chunk, a database record, or a verified knowledge base entry. It is most effective as a post-generation guardrail: the model first generates a response, and then this prompt acts as a critic, comparing the response to the evidence. The output is not a corrected response but a structured escalation payload containing a severity_score (e.g., LOW, MEDIUM, HIGH, CRITICAL), a list of unsupported_claims with direct quotes from the output and the conflicting or missing evidence, and a recommended_action (e.g., PUBLISH, FLAG_FOR_REVIEW, BLOCK). This design keeps the verification step separate from generation, making the hallucination detection logic easier to test, version, and calibrate independently.

Do not use this prompt as a substitute for source-grounding in the initial generation step. If your primary model is already instructed to answer only from provided context, this prompt serves as a second-layer audit, not the first line of defense. Avoid using it on creative or open-ended tasks where there is no single factual ground truth, as it will over-flag valid stylistic or inferential output. The biggest production risk is over-escalation: flagging accurate but paraphrased statements as hallucinations. To mitigate this, you must calibrate the prompt with clear rules distinguishing semantic equivalence from contradiction, and you should pair it with an evaluation harness that measures the false-positive rate on a golden dataset of known-good outputs. The next section provides the exact prompt template you can adapt and deploy.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Model Hallucination Detection and Escalation Prompt delivers reliable value and where it introduces unacceptable risk. Use these cards to decide whether this prompt fits your operational context before wiring it into a production pipeline.

01

Good Fit: Grounded QA Pipelines

Use when: outputs must be verified against a known, provided context window or a fixed knowledge base. The prompt excels at comparing generated claims to source material and flagging unsupported statements. Guardrail: Always pass the exact source context alongside the generated output; never rely on the model's parametric knowledge for verification.

02

Bad Fit: Creative or Subjective Content

Avoid when: evaluating marketing copy, fiction, brainstorming, or any output where factual grounding is not the primary quality measure. The prompt will over-flag stylistic choices and novel phrasing as hallucinations. Guardrail: Use a separate creativity or style eval prompt for these workflows; never route subjective content through a factual-accuracy detector.

03

Required Inputs: Source-Output Pair

What to watch: the prompt requires both the model's generated output and the exact source context it was supposed to use. Missing or truncated context produces unreliable severity scores. Guardrail: Implement a pre-check that validates both fields are present and non-empty before invoking the detection prompt; log any invocations with missing context for audit.

04

Operational Risk: Over-Escalation Fatigue

What to watch: a sensitive hallucination detector can flood human review queues with low-severity flags, causing reviewer fatigue and eventual ignoring of critical alerts. Guardrail: Calibrate severity thresholds against a golden dataset of known hallucinations and benign outputs; implement rate limiting on escalations per time window and monitor false-positive rates weekly.

05

Operational Risk: Silent Under-Escalation

What to watch: the prompt may miss subtle hallucinations where the model fabricates plausible-sounding details that are absent from the source but consistent with its style. Guardrail: Pair this prompt with a separate coverage or completeness check that verifies all claims in the output are explicitly attributable to the source; use both signals together before clearing an output.

06

Latency and Cost Sensitivity

What to watch: running a secondary LLM call for hallucination detection doubles latency and token cost for every user-facing response. This is prohibitive for real-time chat or high-throughput pipelines. Guardrail: Apply this prompt only to high-risk output categories (e.g., medical, legal, financial) or use it as an asynchronous post-processing step; for low-risk traffic, rely on lighter-weight regex or embedding-based checks.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for detecting hallucinations in model outputs against provided context and producing a structured escalation payload.

This prompt template is designed to be dropped into a hallucination detection and escalation workflow. It compares a model-generated claim against a provided ground-truth context and produces a structured output that includes a severity score, a list of unsupported claims, and a clear escalation decision. The template uses square-bracket placeholders for all dynamic inputs, making it straightforward to parameterize in application code. Before integrating this prompt, ensure you have a reliable source of ground-truth context—this prompt is only as effective as the evidence it can verify against. For high-stakes domains like healthcare or finance, always route CRITICAL severity findings to a human review queue rather than taking automated action.

text
You are an AI reliability auditor. Your task is to compare a model-generated CLAIM against a provided GROUND_TRUTH_CONTEXT and determine whether the claim is fully supported, partially supported, or unsupported (hallucinated).

## INPUTS

**GROUND_TRUTH_CONTEXT:**
[GROUND_TRUTH_CONTEXT]

**MODEL_CLAIM:**
[MODEL_CLAIM]

**OUTPUT_SCHEMA:**
[OUTPUT_SCHEMA]

**CONSTRAINTS:**
[CONSTRAINTS]

## INSTRUCTIONS

1. Extract every factual assertion from the MODEL_CLAIM.
2. For each assertion, check whether it is explicitly supported by the GROUND_TRUTH_CONTEXT.
3. Classify each assertion as:
   - `SUPPORTED`: Directly stated in the context.
   - `PARTIALLY_SUPPORTED`: Partially stated but missing key details or contains minor inaccuracies.
   - `UNSUPPORTED`: Not stated in the context or directly contradicted by it.
4. Assign an overall `severity_score` from 1 to 5:
   - 1: All claims fully supported.
   - 2: Minor unsupported details, no material impact.
   - 3: One or more partially supported claims that could mislead.
   - 4: At least one fully unsupported claim with potential harm.
   - 5: Multiple unsupported claims or a single critically false claim.
5. If severity_score is 4 or 5, set `escalation_required` to `true` and populate the `escalation_payload`.
6. If the MODEL_CLAIM is creative, subjective, or opinion-based rather than factual, note this in `notes` and do not flag as hallucination unless it contradicts explicit context.

## OUTPUT FORMAT

Respond with a single JSON object matching the OUTPUT_SCHEMA exactly. Do not include any text outside the JSON.

To adapt this template for your system, replace the placeholders with your specific inputs. The [GROUND_TRUTH_CONTEXT] should contain the verified source material—this could be a retrieved document chunk, a database record, or a human-verified fact set. The [MODEL_CLAIM] is the output you're auditing, typically from a prior model call. The [OUTPUT_SCHEMA] placeholder should be replaced with your exact expected JSON schema, including fields like assertions (array of objects with claim_text, support_status, and evidence_excerpt), severity_score (integer 1-5), escalation_required (boolean), and escalation_payload (object with reason, unsupported_claims, and recommended_action). The [CONSTRAINTS] placeholder lets you inject domain-specific rules, such as "do not flag marketing language as hallucination" or "treat any medical dosage discrepancy as severity 5." After adapting the template, run it against a golden dataset of known hallucinations and accurate outputs to calibrate your severity thresholds before production deployment.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the hallucination detection prompt. Each variable must be populated before model invocation. Validation notes describe how to verify the input is well-formed before sending.

PlaceholderPurposeExampleValidation Notes

[MODEL_OUTPUT]

The generated text to evaluate for hallucination

The patient was prescribed 50mg of Lisinopril daily based on the clinical trial results from 2023.

Must be non-empty string. Truncate if longer than context window minus prompt overhead. Check for null or whitespace-only inputs before invocation.

[SOURCE_CONTEXT]

Ground-truth evidence against which claims are verified

Clinical note: Patient prescribed Lisinopril 25mg daily on 2024-03-15. No clinical trial data referenced in record.

Must be non-empty string. Validate that context is from the correct source and timestamp. If multiple sources exist, concatenate with source labels. Null allowed only when testing abstention behavior.

[CLAIM_EXTRACTION_DEPTH]

Controls how granularly claims are extracted from the model output

sentence-level

Must be one of: phrase-level, sentence-level, paragraph-level. Default to sentence-level if unset. Reject unknown values before prompt assembly.

[SEVERITY_THRESHOLD]

Minimum hallucination severity score that triggers escalation to human review

0.7

Must be float between 0.0 and 1.0. Validate range before invocation. Values below 0.3 may cause over-escalation; values above 0.9 may miss material hallucinations. Log threshold in trace for audit.

[OUTPUT_SCHEMA]

Expected JSON structure for the detection result

{"claims": [...], "severity_score": float, "escalation_required": boolean, "unsupported_claims": [...]}

Must be valid JSON schema string. Validate parseability before prompt assembly. Schema must include severity_score, escalation_required, and unsupported_claims fields at minimum. Reject schemas missing required fields.

[ESCALATION_POLICY]

Rules defining when human review is mandatory regardless of severity score

Escalate if output contains medication dosage, lab result, or diagnosis claim not present in source context.

Must be non-empty string describing policy conditions. Validate that policy references fields present in OUTPUT_SCHEMA. Policy should be specific enough to test programmatically. Null allowed if no override policy exists.

[FALSE_POSITIVE_EXAMPLES]

Examples of creative but accurate outputs that should NOT be flagged as hallucination

Patient education summary rephrased clinical guidelines in plain language without fabricating specific values.

Must be array of 1-5 example strings. Validate array length. Each example should represent a known failure mode where previous prompt versions over-flagged. Empty array allowed but increases false-positive risk.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the hallucination detection prompt into a production monitoring pipeline with validation, retries, and human review.

This prompt is designed to sit inside a post-generation monitoring step, not as a real-time guardrail blocking every model response. In a typical deployment, every output from a primary generative model passes through an asynchronous evaluation queue. The hallucination detection prompt receives the original user query, the retrieved or provided context, and the model's final response. It returns a structured JSON payload with a severity score, a list of unsupported claims, and a recommended action. The application layer reads the action field: pass responses are logged and forwarded; flag responses are routed to a human review queue; block responses may trigger an automatic retry or fallback response before human review.

Validation and retry logic is critical because the detection prompt itself can produce malformed JSON or hallucinate about the presence of hallucinations. Implement a JSON schema validator that checks for required fields (severity_score, unsupported_claims, action, reasoning). If validation fails, retry up to two times with the same input but append the validation error message to the prompt as [PREVIOUS_VALIDATION_ERROR]. If the third attempt still fails validation, escalate the entire evaluation attempt to a human reviewer with the raw model output and detection prompt response attached. Log every validation failure for later analysis—frequent failures may indicate prompt drift or a need to switch to a more reliable model for the detection step.

Model selection matters more here than in many other prompts. The detection prompt requires careful reading comprehension and restraint—it must not flag creative but factually-grounded statements as hallucinations. GPT-4o and Claude 3.5 Sonnet perform well on this task, while smaller or faster models tend to over-flag. If latency is critical, use a fast model for the primary generation and a slower, more capable model for the detection step. For high-volume pipelines, consider batching detection requests and running them on a separate compute budget. Always log the model version alongside each evaluation result so that changes in detection behavior can be correlated with model updates.

Human review integration should present reviewers with a clean diff view: the original context on the left, the model's claims in the center, and the detection prompt's flagged items on the right. Include the severity score and reasoning. Reviewers should be able to confirm, dismiss, or reclassify each flagged claim. Track reviewer decisions over time to measure the detection prompt's precision and recall. If more than 30% of flagged claims are dismissed by reviewers, recalibrate the prompt's threshold language or adjust the severity score boundaries. For regulated domains, require a second reviewer for any block action before the response is permanently discarded or the user is notified.

Avoid wiring this prompt as a synchronous blocker on every user-facing response unless your latency budget can absorb an additional model call and your false-positive rate is well-characterized. A better pattern for user-facing applications is to let responses through but flag them for asynchronous review, with the ability to retroactively correct or retract responses if hallucinations are confirmed. For internal analytics or content generation pipelines where downstream decisions depend on factual accuracy, synchronous blocking with a fast fallback (e.g., 'I couldn't verify that claim') is appropriate. In all cases, instrument the pipeline with metrics: detection latency, validation failure rate, flag rate, reviewer confirmation rate, and time-to-review. These metrics will tell you whether the harness is working before a user complaint does.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the hallucination detection payload. Every field must be parseable by downstream routing, logging, and human review systems.

Field or ElementType or FormatRequiredValidation Rule

hallucination_score

float (0.0 to 1.0)

Must be a number between 0 and 1 inclusive. 0.0 = fully grounded, 1.0 = entirely fabricated.

severity_level

enum: [none, low, medium, high, critical]

Must match one of the five enum values. Map from hallucination_score using configurable thresholds.

escalation_required

boolean

Must be true if severity_level is high or critical, or if any unsupported_claim has confidence below the configured floor.

unsupported_claims

array of objects

Each object must contain claim_text (string), source_contradiction (string or null), and confidence_gap (float 0.0-1.0). Array can be empty if no claims are unsupported.

claim_text

string

true (per claim)

The exact sentence or phrase from the model output that could not be verified. Must be a substring of the original output.

source_contradiction

string or null

true (per claim)

If a source directly contradicts the claim, include the conflicting excerpt. If no source addresses the claim, set to null.

confidence_gap

float (0.0 to 1.0)

true (per claim)

Difference between model's asserted confidence and evidence support. 1.0 means model was fully confident but zero evidence exists.

grounded_summary

string

A one-paragraph summary of what the provided context actually supports, stripped of any unsupported claims. Must not introduce new information.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when detecting model hallucinations and how to guard against it in production.

01

Over-Flagging Creative but Accurate Outputs

Risk: The prompt misclassifies novel but factually correct summaries or creative rephrasings as hallucinations because they don't match the source text verbatim. This floods the review queue with false positives and erodes trust in the detector. Guardrail: Include explicit counterexamples in the prompt showing valid paraphrases and require the model to cite the specific source passage that contradicts the claim before flagging. Calibrate severity scoring to distinguish stylistic variation from factual invention.

02

Silent Hallucination on Missing Context

Risk: When the provided context is incomplete or irrelevant to the user's query, the model fabricates plausible-sounding details to fill the gap instead of flagging the information as unavailable. The hallucination detector fails because it only checks against provided context, not against what should be present. Guardrail: Add a pre-check step that evaluates whether the provided context is sufficient to answer the query. If not, escalate for context gap before running the hallucination check. Include an explicit 'insufficient evidence' severity tier.

03

Context Boundary Confusion

Risk: The model treats its own parametric knowledge as provided context, blending training data with the actual source material. Claims that are true in the world but unsupported by the provided document pass through undetected because the detector cannot distinguish the source of the model's knowledge. Guardrail: Structure the prompt to require strict source grounding with direct quotations. Add a validation rule that any unsupported claim must be flagged regardless of its real-world truth, and include eval tests that mix well-known facts with deliberately absent context.

04

Severity Score Inflation on Minor Deviations

Risk: Minor numerical rounding, date formatting differences, or synonym substitutions trigger high-severity hallucination flags, making the severity score useless for triage. Reviewers learn to ignore high scores, causing genuinely dangerous fabrications to be missed. Guardrail: Define a clear severity rubric with concrete examples at each level. Use structured output to separate 'critical fabrication,' 'minor imprecision,' and 'stylistic variation.' Implement a post-processing rule that caps severity when the semantic meaning is preserved despite surface-form differences.

05

Prompt Injection Masquerading as Hallucination

Risk: An attacker crafts input that causes the model to generate deliberately false claims that the hallucination detector then attributes to model error rather than recognizing the adversarial input. The escalation path treats it as a quality issue instead of a security incident. Guardrail: Run the hallucination detection prompt only after an upstream prompt injection check. If injection is detected, route to the security escalation path, not the quality review queue. Include adversarial test cases where injected instructions produce false claims that should be classified as attacks, not hallucinations.

06

Long-Context Truncation and Evidence Loss

Risk: When source documents exceed the context window, critical evidence is truncated before the hallucination detector can evaluate it. The detector then flags claims as unsupported because the supporting passage was cut, producing false positives that waste reviewer time. Guardrail: Implement chunking with overlap and run hallucination detection per chunk before aggregating results. Add a metadata field indicating whether the full context was available. If context was truncated, downgrade confidence in the hallucination score and flag the limitation explicitly in the escalation payload.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the hallucination detection prompt before deployment. Each row defines a pass standard, a failure signal, and a concrete test method to validate production readiness.

CriterionPass StandardFailure SignalTest Method

Grounded Claim Accuracy

All claims explicitly supported by [CONTEXT] are flagged as grounded (severity: none)

A supported claim is incorrectly flagged as unsupported or hallucinated

Run 50 grounded claim examples; require 100% precision on grounded classification

Unsupported Claim Detection

Claims not present in [CONTEXT] are flagged with severity >= low and the specific unsupported text is quoted

An unsupported claim is missed or severity is incorrectly set to none

Run 50 unsupported claim examples; require >=95% recall on unsupported detection

Contradiction Detection

Claims that directly contradict [CONTEXT] are flagged with severity >= high and the conflicting context is cited

A contradiction is flagged as low severity or the conflicting evidence is not cited

Run 30 contradiction pairs; require >=90% detection rate with correct severity assignment

Creative Output Over-Flagging

Creative, inferential, or stylistic language that does not assert new facts is not flagged as hallucination

A metaphor, summary phrase, or stylistic choice is incorrectly flagged as unsupported

Run 20 creative-but-accurate outputs; require false-positive rate below 10%

Severity Scoring Calibration

Severity levels (none, low, medium, high, critical) align with the defined schema: critical for fabricated dangerous claims, low for minor unsupported details

A minor unsupported detail receives critical severity, or a fabricated safety claim receives low severity

Run 20 mixed-severity examples; require exact severity match in >=85% of cases

Output Schema Compliance

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

Response is malformed JSON, missing required fields, or contains fields with wrong types

Parse all outputs with schema validator; require 100% structural validity across 100 test runs

Citation Traceability

Every flagged unsupported claim includes a quote from the model output and, when applicable, the closest [CONTEXT] passage

A flag is raised without quoting the specific claim text or without referencing the relevant context

Run 40 flagged outputs; require >=95% contain both the claim quote and context reference

Empty Context Handling

When [CONTEXT] is empty or null, all factual claims are flagged as unsupported with severity >= medium

Model generates claims and marks them as grounded when no context is provided

Run 20 empty-context inputs; require 100% of factual claims flagged as unsupported

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single hallucination severity score (1-5). Use a simple JSON output with severity, unsupported_claims (array of strings), and summary. Skip strict schema validation during early testing.

code
[SYSTEM]: You are a hallucination detector. Compare the [MODEL_OUTPUT] against the [SOURCE_CONTEXT]. Identify any claims not supported by the context. Return JSON with severity (1-5), unsupported_claims, and summary.

Watch for

  • Over-flagging creative but accurate paraphrases as hallucinations
  • Missing severity calibration—test with known-good and known-bad examples
  • No baseline false-positive rate established before moving to production
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.