This prompt is designed for AI safety engineers and output validation pipeline builders who need a structured, automated gate before a user-facing answer is generated. Its primary job is to assess the risk of hallucination given a specific user query and a set of retrieved evidence chunks. It does not generate an answer; instead, it produces a risk level and a breakdown of contributing factors such as gap severity, source ambiguity, and query complexity. The ideal user is integrating this into a production RAG pipeline where the cost of a confident but wrong answer is high, such as in customer support, clinical documentation, or financial analysis.
Prompt
RAG Hallucination Risk Assessment Prompt

When to Use This Prompt
Defines the operational boundaries and ideal deployment scenarios for the RAG Hallucination Risk Assessment Prompt as a pre-generation safety gate.
Deploy this prompt as a synchronous check between the retrieval step and the answer generation step. The required inputs are a [USER_QUERY] and a [RETRIEVED_CONTEXT] array. The output is a structured JSON object containing a [RISK_LEVEL] (e.g., LOW, MEDIUM, HIGH, CRITICAL) and a [RISK_FACTORS] list. Use this output to route the request: LOW risk can proceed directly to answer generation, MEDIUM might trigger a re-retrieval or a partial answer with caveats, and HIGH or CRITICAL should escalate for human review or return a refusal message. This prompt is not a replacement for a full grounding verification check on the final generated answer; it is a pre-emptive safety filter.
Do not use this prompt when the user query is trivial, the operational cost of refusal is higher than the cost of a minor hallucination, or when the retrieval system is known to be highly unreliable. In these cases, the risk assessment itself becomes a bottleneck or a source of noise. Avoid using this prompt as a standalone quality score without downstream routing logic; its value is realized only when the risk level actively changes the system's behavior. The next step after implementing this gate is to pair it with a 'Missing Context Request Generation Prompt' for MEDIUM risk scenarios, ensuring the system can actively work to de-risk the query before giving up.
Use Case Fit
Where the RAG Hallucination Risk Assessment Prompt works, where it fails, and the operational prerequisites for production use.
Good Fit: Pre-Generation Safety Gates
Use when: You need a structured risk assessment before generating a user-facing answer. This prompt excels as a synchronous guard in a RAG pipeline where blocking a high-risk response is cheaper than repairing a hallucinated one. Guardrail: Place this prompt after retrieval and evidence ranking, but before the final answer generation call.
Bad Fit: Real-Time Chat with No Retrieval
Avoid when: There is no retrieved evidence to assess, such as in a general-purpose chatbot or a model responding from its own weights. The prompt relies on comparing a query against provided context. Guardrail: If your application does not use RAG, use a general-purpose hallucination detection or refusal prompt instead.
Required Inputs
What you need: A user query, a set of retrieved passages with source metadata, and a defined output schema for the risk assessment. The prompt cannot function without explicit evidence to analyze. Guardrail: Validate that the retrieval set is not empty before calling this prompt. An empty context list should immediately route to a refusal flow.
Operational Risk: Latency Budget
What to watch: Adding a risk assessment step increases end-to-end latency. This can degrade user experience in synchronous, low-latency applications. Guardrail: Implement a timeout and a circuit breaker. If the risk assessment exceeds 2 seconds, fall back to a default safe behavior such as answering with high-uncertainty caveats or refusing.
Operational Risk: False Positives
What to watch: The model may flag a query as high-risk when the evidence is actually sufficient but poorly ranked or formatted. This leads to unnecessary refusals and user frustration. Guardrail: Log all high-risk assessments with their contributing factors. Periodically audit a sample to calibrate your risk threshold and identify retrieval quality issues.
Operational Risk: Source Ambiguity Exploitation
What to watch: If sources conflict, the model might default to a high-risk score instead of resolving the conflict. This masks a retrieval problem as a hallucination risk. Guardrail: Add a pre-processing step to detect and flag conflicting evidence. If a conflict is detected, route to a dedicated conflict-resolution prompt before the risk assessment.
Copy-Ready Prompt Template
A copy-ready prompt template for assessing hallucination risk in RAG systems before answer generation.
This prompt template is designed to be used as a pre-generation safety gate. It takes a user query and the retrieved evidence set and produces a structured risk assessment before any answer is shown to the user. The output includes a risk level, contributing factors, and a recommendation for whether to proceed, escalate, or refuse. Use this template when the cost of a hallucinated answer is high—customer-facing support, clinical summaries, financial analysis, or any workflow where user trust depends on accuracy.
textYou are a hallucination risk assessor for a Retrieval-Augmented Generation (RAG) system. Your job is to evaluate whether the available evidence is sufficient to answer the user's query without hallucination. Do not answer the query. Only assess the risk. ## INPUT **User Query:** [USER_QUERY] **Retrieved Evidence:** [RETRIEVED_EVIDENCE] **Risk Tolerance:** [RISK_TOLERANCE] ## ASSESSMENT DIMENSIONS Evaluate the following dimensions and assign a severity level (NONE, LOW, MEDIUM, HIGH, CRITICAL) for each: 1. **Evidence Gaps:** Are there specific facts, entities, dates, or claims in the query that have no supporting evidence? 2. **Source Ambiguity:** Do multiple sources conflict, or is the evidence vague, outdated, or from low-authority sources? 3. **Query Complexity:** Does the query require multi-hop reasoning, temporal comparisons, or synthesis across many passages? 4. **Inference Distance:** How many inferential steps separate the raw evidence from a complete answer? 5. **Coverage Completeness:** What percentage of the query's information needs are directly addressed by the evidence? ## OUTPUT SCHEMA Return a JSON object with this exact structure: { "risk_level": "LOW" | "MEDIUM" | "HIGH" | "CRITICAL", "risk_score": 0.0-1.0, "dimension_assessments": [ { "dimension": "string", "severity": "NONE" | "LOW" | "MEDIUM" | "HIGH" | "CRITICAL", "explanation": "string" } ], "contributing_factors": ["string"], "recommendation": "PROCEED" | "PROCEED_WITH_CAVEATS" | "ESCALATE" | "REFUSE", "recommendation_rationale": "string", "missing_information_summary": "string or null" } ## CONSTRAINTS - Do not answer the user's query. - Do not fabricate evidence or fill gaps with your own knowledge. - If evidence is missing, state what is missing explicitly. - If sources conflict, describe the conflict rather than choosing sides. - For HIGH or CRITICAL risk, the recommendation must be ESCALATE or REFUSE. - Base every assessment strictly on the provided evidence.
Adaptation guidance: Replace [USER_QUERY] with the raw user input. [RETRIEVED_EVIDENCE] should contain the full text of retrieved passages, ideally with source identifiers and retrieval scores. [RISK_TOLERANCE] accepts values like LOW, MEDIUM, or HIGH and should be set based on the application's tolerance for hallucination—clinical and financial systems should use LOW. For production use, add [EXAMPLES] with 2-3 annotated query-evidence pairs showing correct risk assessments to improve consistency. If your system uses a specific output schema language, replace the JSON block with your schema definition. For high-throughput systems, consider adding a [CONSTRAINTS] block that limits the response to 200 tokens and removes the explanation fields to reduce latency.
Prompt Variables
Placeholders required by the RAG Hallucination Risk Assessment Prompt. Each variable must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed and safe.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The user question or information need being evaluated for hallucination risk. | What were the key drivers of revenue decline in Q3 2024? | Non-empty string check. Reject if length > 4000 chars. Sanitize for prompt injection markers. |
[RETRIEVED_CONTEXT] | The set of passages, documents, or evidence chunks returned by the retrieval system. | Passage 1: Revenue declined 12% YoY due to... Passage 2: The new pricing model launched in... | Must be a non-null array or delimited string. Validate each passage has a source identifier. Reject empty context sets. |
[CONTEXT_METADATA] | Optional metadata for each retrieved passage including source authority, recency, and retrieval score. | {"passage_1": {"source": "10-K Filing", "date": "2024-11-01", "score": 0.89}} | If provided, validate JSON structure. Each key must match a passage in [RETRIEVED_CONTEXT]. Null allowed if metadata unavailable. |
[QUERY_COMPLEXITY] | Pre-assessed complexity level of the query: simple, moderate, complex, or multi-hop. | complex | Must be one of enum: [simple, moderate, complex, multi-hop]. If auto-detected, log the detection method. Default to moderate if unknown. |
[DOMAIN] | The knowledge domain or vertical context for the assessment. | financial_reporting | Must be a non-empty string. Use a controlled vocabulary for consistency. Null allowed for general-domain queries. |
[RISK_THRESHOLD] | The acceptable risk level for auto-proceeding. Outputs above this threshold should trigger human review or refusal. | medium | Must be one of enum: [low, medium, high, critical]. Default to medium if not specified. Document who set this threshold. |
[OUTPUT_SCHEMA] | The expected JSON schema for the risk assessment output. | {"risk_level": "string", "contributing_factors": ["string"], "confidence": "float"} | Validate as valid JSON Schema. Reject schemas that lack required fields: risk_level, contributing_factors. Schema must be parseable by downstream validator. |
Implementation Harness Notes
How to wire the RAG Hallucination Risk Assessment Prompt into a pre-generation safety gate with validation, retries, and logging.
This prompt is designed to operate as a pre-generation safety gate in a RAG pipeline. It should run after retrieval and evidence assembly but before the final answer generation step. The model receives the user query, the retrieved context set, and any metadata about source recency or authority. It returns a structured risk assessment that your application can use to decide whether to proceed with answer generation, request more evidence, escalate for human review, or return a refusal to the user. The prompt is not a post-hoc hallucination detector—it predicts risk before the answer exists, which makes it valuable for preventing confident wrong answers rather than catching them afterward.
Wire the prompt into your application as a synchronous pre-check with a strict timeout and a deterministic fallback. On the happy path, parse the JSON output and read the risk_level field. Map risk levels to routing decisions: low proceeds directly to answer generation; medium may proceed with additional grounding instructions injected into the answer-generation prompt; high triggers a re-retrieval attempt or clarification request; critical escalates to a human review queue or returns a refusal message. Always log the full risk assessment payload alongside the query, retrieval set, and eventual answer for audit and evaluation. If the model returns malformed JSON, apply a repair prompt or fall back to a conservative high risk classification rather than silently proceeding.
Validation and retry logic is essential because this prompt sits on the critical path. Validate that the output contains a recognized risk_level value from the allowed set (low, medium, high, critical), that contributing_factors is a non-empty array, and that each factor includes both a factor name and a severity rating. If validation fails, retry once with the same input and a stronger format reminder appended to the prompt. If the retry also fails, log the failure, classify the risk as high, and route to human review. For model choice, prefer a fast, instruction-following model with strong JSON output discipline—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are suitable. Avoid using a small or local model for this gate unless you have calibrated its risk assessment accuracy against a labeled dataset, because false-negative low risk classifications will let hallucinations through to users.
Evaluation and calibration should happen before production deployment. Build a test set of 50–100 query-and-context pairs with known hallucination outcomes from your own system. Run the risk assessment prompt against this set and measure whether high and critical risk classifications correlate with actual hallucination events. Tune the routing thresholds based on your tolerance for false positives (unnecessary refusals) versus false negatives (hallucinations reaching users). In high-stakes domains such as healthcare, legal, or finance, bias toward over-classifying risk and routing to human review. In lower-stakes applications, you may allow medium risk to proceed with stronger grounding instructions. Document your threshold decisions and re-evaluate them whenever you change retrieval logic, knowledge base content, or the underlying model.
Expected Output Contract
Defines the structured JSON output for the RAG Hallucination Risk Assessment Prompt. Use this contract to validate the model's response before it reaches downstream safety gates.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
risk_level | enum: low | medium | high | critical | Must match one of the four enum values exactly. Case-sensitive check. | |
risk_score | number (0.0 - 1.0) | Must be a float between 0.0 and 1.0. Reject if out of range or non-numeric. | |
contributing_factors | array of objects | Must be a non-empty array. Reject if empty or missing. | |
contributing_factors[].factor | string | Must be a non-empty string. Reject if null or whitespace-only. | |
contributing_factors[].severity | enum: low | medium | high | critical | Must match one of the four enum values. Case-sensitive check. | |
contributing_factors[].evidence_gap | string | Must reference a specific gap in the provided context. Reject if generic or unverifiable against [RETRIEVED_CONTEXT]. | |
assessment_summary | string | Must be 1-3 sentences. Reject if empty or exceeds 500 characters. | |
requires_human_review | boolean | Must be true if risk_level is high or critical. Flag for manual review if mismatch detected. |
Common Failure Modes
What breaks first when assessing hallucination risk and how to guard against it in production.
Overconfidence on Ambiguous Evidence
What to watch: The model assigns a low hallucination risk score when evidence is vague, contradictory, or only tangentially related. It mistakes quantity of retrieved passages for quality of support. Guardrail: Require the prompt to explicitly enumerate specific evidence gaps before calculating the final risk level. Add a validator that flags risk scores below a threshold when gap count exceeds a configured limit.
Query Complexity Blindness
What to watch: The risk assessment treats a multi-hop, temporal, or comparative query the same as a simple factoid lookup. It fails to recognize that complex queries amplify the probability of hallucination even when individual passages look relevant. Guardrail: Add a query decomposition step before risk assessment. The prompt must classify query complexity (single-hop, multi-hop, temporal, comparative) and weight the risk score accordingly.
Source Authority Neglect
What to watch: The model ignores source trustworthiness signals and treats all retrieved passages as equally authoritative. A hallucination risk assessment based on low-quality or outdated sources produces a falsely reassuring score. Guardrail: Include source metadata (recency, authority tier, domain) in the evidence payload. The prompt must factor source quality into the risk calculation and flag when all supporting evidence comes from low-authority sources.
Gap Severity Underestimation
What to watch: The model detects that information is missing but downplays the severity. It treats a missing critical entity the same as a missing minor detail, producing a medium risk score when the gap is actually a hard blocker. Guardrail: Require the prompt to assign a severity rating (blocker, major, minor) to each identified gap. The final risk level must be bounded below by the highest-severity gap found.
Hallucinated Risk Factors
What to watch: The model invents risk factors or contributing reasons that are not grounded in the provided evidence or query. It fabricates plausible-sounding but unsupported concerns, undermining trust in the safety gate itself. Guardrail: Require each contributing factor in the output to cite a specific evidence passage, gap, or query property. Add a post-assessment verification step that checks whether every listed factor is traceable to the input.
Threshold Gaming Under Load
What to watch: When the system is under pressure to produce answers quickly, the risk assessment prompt starts returning borderline scores that just barely pass the safety threshold. Operators lower the threshold to reduce refusal rates, and the safety gate erodes. Guardrail: Monitor the distribution of risk scores over time and alert on drift toward the threshold boundary. Implement a secondary random audit that re-evaluates a sample of passed assessments with a stricter prompt variant.
Evaluation Rubric
Use this rubric to evaluate the RAG Hallucination Risk Assessment Prompt's output quality before integrating it into a production safety gate. Each criterion targets a specific failure mode that can cause the risk assessment to be unreliable.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Risk Level Parsability | Output contains exactly one of the defined risk levels: LOW, MEDIUM, HIGH, or CRITICAL. | Risk level is missing, ambiguous, or not in the defined enum. | Parse the output field. Assert the value is a string and matches the allowed enum list. |
Factor Enumeration Completeness | Every contributing factor listed in the output is explicitly linked to a gap, ambiguity, or complexity signal from the input. | A factor is stated without a clear connection to the input evidence or query, indicating hallucination. | For each factor, trace its origin to a specific sentence in the [QUERY] or [EVIDENCE] input. Flag untraceable factors. |
Gap Severity Justification | The risk level is justified by the severity of identified evidence gaps, not by generic language. | The justification uses vague terms like 'evidence might be weak' without naming the specific missing information. | Check if the output's rationale references a specific gap from the [EVIDENCE] that would prevent a complete answer. |
Source Ambiguity Handling | If multiple sources conflict, the output identifies the conflict as a contributing factor to hallucination risk. | Conflicting sources are present in [EVIDENCE] but the output does not mention the conflict, or claims evidence is consistent. | Provide [EVIDENCE] with two contradictory passages. Assert the output's factors include a source conflict signal. |
Query Complexity Calibration | A complex, multi-part query with a simple evidence set results in a HIGH or CRITICAL risk level. | A complex query with insufficient evidence is rated LOW or MEDIUM risk without acknowledging the complexity mismatch. | Use a multi-hop [QUERY] with a single, tangentially related [EVIDENCE] passage. Assert the risk level is not LOW. |
Overconfidence Detection | When [EVIDENCE] is completely irrelevant to the [QUERY], the output is CRITICAL, not HIGH or MEDIUM. | The output rates the risk as MEDIUM or HIGH when no evidence supports any part of the query. | Provide a [QUERY] and a completely off-topic [EVIDENCE] set. Assert the output risk level is CRITICAL. |
Output Schema Adherence | The output is valid JSON matching the specified [OUTPUT_SCHEMA] with all required fields present. | The output is missing a required field, contains extra unrequested fields, or is not valid JSON. | Validate the output string against the [OUTPUT_SCHEMA] using a JSON schema validator. Assert no errors. |
Refusal Recommendation Consistency | A CRITICAL risk assessment always includes a recommendation to refuse or escalate, not to attempt an answer. | A CRITICAL risk output suggests generating an answer with caveats instead of refusing. | For any test case resulting in CRITICAL risk, assert the output's recommendation field contains a refusal or escalation directive. |
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 frontier model (GPT-4o, Claude 3.5 Sonnet). Remove the strict JSON output schema and ask for a plain-text risk assessment. Focus on getting the risk logic right before adding validation harnesses.
codeAssess the hallucination risk for answering [QUERY] given the evidence below. Return a risk level (LOW/MEDIUM/HIGH/CRITICAL) and a short explanation. Evidence: [RETRIEVED_CONTEXT]
Watch for
- Inconsistent risk level assignments across similar inputs
- Overly verbose explanations that bury the risk signal
- No handling of empty or malformed evidence inputs

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