This prompt is designed for RAG systems that have already produced an answer, but that answer contains claims that are unsupported, speculative, or entirely absent from the retrieved context. Instead of regenerating the entire answer blindly—which risks repeating the same hallucination—this prompt instructs the model to act as an auditor. Its job is to identify the specific evidence gaps in the generated answer, formulate targeted retrieval queries to fill those gaps, and produce a structured gap-to-query mapping that your application can use to execute a second, targeted retrieval round. The core job-to-be-done is evidence gap triage: you need to know exactly what evidence is missing before you can go fetch it.
Prompt
Evidence Gap Identification and Fill Prompt

When to Use This Prompt
Identify when to deploy the evidence gap auditor versus simpler retry or regeneration strategies.
Use this prompt when your initial retrieval was too narrow, when the model made an inferential leap beyond the provided documents, or when a downstream validator flags low citation coverage. It is particularly effective when the answer is mostly grounded but contains a few unsupported assertions—the auditor can isolate those assertions without discarding the valid portions of the response. The ideal user is an AI engineer or platform developer who has access to a retrieval system that accepts programmatic queries and can execute a second retrieval pass based on the auditor's output. You must provide the original question, the generated answer, and the initially retrieved context as inputs. The output is a structured JSON mapping of gap descriptions to reformulated retrieval queries, which your harness can iterate over to fetch missing evidence.
Do not use this prompt for simple formatting errors, malformed JSON, or cases where the entire answer is a hallucination with no retrievable grounding. If every claim is fabricated, there are no gaps to identify—the correct recovery is a full regeneration with stricter grounding constraints, not gap analysis. Similarly, do not use this prompt when the failure mode is a tool-call schema mismatch, an API error, or a context window overflow; those require different recovery strategies covered in the Tool Call Recovery, Infrastructure Error Retry, and Context Window Recovery playbooks. This prompt also assumes that your retrieval system can return useful results for the reformulated queries. If your corpus simply does not contain the evidence needed, the auditor will correctly identify gaps that cannot be filled, and your system should escalate to answer abstention rather than looping indefinitely.
Before wiring this into production, define a retry budget. A single audit-and-retrieve cycle is often sufficient, but if the second retrieval still leaves gaps, decide whether to audit again, fall back to a constrained regeneration, or escalate for human review. Log the gap-to-query mappings and the results of each retrieval round for observability. In high-stakes domains such as healthcare, legal, or finance, always route outputs with unresolved gaps to human review rather than presenting partially grounded answers to users. The next section provides the copy-ready prompt template you can adapt for your own RAG recovery harness.
Use Case Fit
Where the Evidence Gap Identification and Fill Prompt delivers value—and where it creates risk or waste.
Good Fit: Retrieval Retry Pipelines
Use when: Your RAG system has a retrieval retry capability and the initial answer shows thin or missing evidence. Guardrail: Only trigger gap-fill when a validator detects insufficient citation coverage or low confidence scores.
Good Fit: Multi-Hop or Composite Questions
Use when: The user question requires evidence from multiple documents or passages that a single retrieval pass cannot satisfy. Guardrail: Decompose the question into sub-queries before gap analysis to avoid conflating missing evidence with poor retrieval.
Bad Fit: Single-Pass Answer Generation
Avoid when: Your pipeline lacks a retrieval retry loop or cannot re-query the index. Guardrail: If you cannot act on the gap-fill queries, skip this prompt and invest in retrieval expansion before generation.
Bad Fit: Real-Time Chat Without Retrieval
Avoid when: The model is answering from parametric knowledge alone with no retrieval corpus to re-query. Guardrail: Gap identification without a retrieval target produces hallucinated source suggestions. Use abstention prompts instead.
Required Inputs
Risk: Incomplete inputs produce vague gap queries that retrieve irrelevant evidence. Guardrail: Always provide the original question, the generated answer, the retrieved context used, and a confidence or citation-coverage signal before invoking gap-fill.
Operational Risk: Retry Loop Amplification
Risk: Repeated gap-fill cycles can amplify retrieval noise, increase latency, and exhaust token budgets without improving answer quality. Guardrail: Cap retries at 2-3 iterations and escalate to human review or abstention when gap coverage stops improving.
Copy-Ready Prompt Template
A reusable prompt template for identifying evidence gaps in a generated answer and formulating targeted retrieval queries to fill them.
This prompt template is the core instruction set for an evidence gap analysis and fill workflow. It is designed to be wired into a retrieval retry harness where a previously generated answer has been flagged for insufficient grounding. The prompt instructs the model to act as a forensic auditor, comparing each factual claim in the generated answer against the provided evidence context. Its primary output is a structured mapping of unsupported claims to new, targeted retrieval queries, enabling a second-pass retrieval that is far more precise than a naive query rewrite.
codeYou are an evidence auditor for a retrieval-augmented generation (RAG) system. Your task is to analyze a generated answer against the provided source evidence, identify specific claims that lack sufficient support, and formulate targeted retrieval queries to fill those gaps. ## INPUT **Generated Answer:** [GENERATED_ANSWER] **Provided Evidence Passages:** [RETRIEVED_EVIDENCE] **Original User Query:** [USER_QUERY] ## INSTRUCTIONS 1. **Extract Claims:** Decompose the Generated Answer into a list of discrete, verifiable factual claims. Ignore stylistic or transitional language. 2. **Match to Evidence:** For each claim, determine if it is **SUPPORTED**, **PARTIALLY_SUPPORTED**, or **UNSUPPORTED** by the Provided Evidence Passages. A claim is only SUPPORTED if the evidence directly confirms it without requiring significant inference. 3. **Identify Gaps:** Collect all claims marked as UNSUPPORTED or PARTIALLY_SUPPORTED. For each, write a concise description of the specific evidence gap. 4. **Formulate Queries:** For each evidence gap, generate a single, highly specific retrieval query designed to find the missing information. The query should be a standalone search string, not a question about the answer. Prioritize precision over recall. 5. **Output Generation:** Produce a JSON object conforming to the [OUTPUT_SCHEMA] below. Do not include any text outside the JSON object. ## CONSTRAINTS - Do not hallucinate support. If evidence is missing, mark the claim as UNSUPPORTED. - If the entire answer is well-supported, return an empty `evidence_gaps` array. - Limit the total number of new queries to [MAX_QUERIES] to stay within a retry budget. - If a claim is a direct quote, verify it is present verbatim in the evidence. Flag any deviation as UNSUPPORTED. ## OUTPUT_SCHEMA { "answer_summary": "A one-sentence summary of the generated answer's main point.", "overall_grounding_score": 0.0, // Float between 0.0 (no support) and 1.0 (fully supported) "evidence_gaps": [ { "unsupported_claim": "The exact text of the unsupported claim.", "gap_description": "A clear explanation of what evidence is missing.", "retrieval_query": "A precise, standalone search query to fill the gap.", "severity": "CRITICAL | MAJOR | MINOR" } ] }
To adapt this template for your application, start by defining the source of [GENERATED_ANSWER] and [RETRIEVED_EVIDENCE]. The evidence should be passed as raw text chunks with their source identifiers prepended (e.g., [Source A] ...). The [MAX_QUERIES] placeholder is a critical safety valve; set it based on your latency budget for the retry loop—typically between 3 and 5. For high-stakes domains like healthcare or finance, you should route outputs with CRITICAL severity gaps to a human review queue before any new retrieval is executed. The overall_grounding_score can be used as a circuit breaker: if it falls below a threshold like 0.4, it may be more cost-effective to regenerate the answer from scratch with stricter instructions than to attempt a piecemeal fill.
Prompt Variables
Required inputs for the Evidence Gap Identification and Fill Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to confirm the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[GENERATED_ANSWER] | The full answer text that may contain evidence gaps | The Acme 3000 supports 4K streaming and has a 2-year warranty. | Must be non-empty string. Check for minimum length of 20 characters. Truncate if over token budget for gap analysis. |
[RETRIEVED_SOURCES] | Array of source documents or passages used to generate the answer | [{"id":"doc-1","text":"Acme 3000 supports 4K streaming."}] | Must be valid JSON array. Each object requires id and text fields. Empty array triggers immediate retrieval expansion without gap analysis. |
[CITATION_MAP] | Mapping of which sources were cited for which claims in the answer | [{"claim":"4K streaming","source_id":"doc-1"}] | Must be valid JSON array. Each object requires claim and source_id. Null allowed if no citations exist. Missing citations trigger gap detection. |
[RETRIEVAL_TOOL_SCHEMA] | Definition of available retrieval tools for formulating gap-filling queries | {"name":"search_corpus","parameters":{"query":"string","filters":{}}} | Must be valid JSON schema. Tool name and parameters must match actual available tools. Schema mismatch causes query formulation failures. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for accepting a claim as adequately supported | 0.7 | Must be float between 0.0 and 1.0. Values below 0.5 produce excessive gap flags. Values above 0.95 may miss real gaps. Default 0.7 if not specified. |
[MAX_RETRIEVAL_QUERIES] | Upper limit on number of gap-filling queries to generate | 5 | Must be positive integer between 1 and 20. Exceeding 10 queries often indicates the answer should be regenerated from scratch rather than patched. |
[ABSTENTION_POLICY] | Instructions for when to abstain instead of attempting gap fill | Abstain if more than 40% of claims are unsupported. | Must be non-empty string. Should define percentage or count threshold. Vague policies cause inconsistent abstention behavior. Test with edge cases at threshold boundary. |
Implementation Harness Notes
How to wire the Evidence Gap Identification and Fill Prompt into a production RAG pipeline with validation, retries, and observability.
This prompt is designed to sit between a failed answer validation step and a re-retrieval step in your RAG pipeline. When your citation completeness check or grounding evaluator flags an answer as having insufficient evidence, this prompt takes the original question, the generated answer, and the previously retrieved context, then produces a structured gap analysis and a set of targeted retrieval queries. The output is machine-readable JSON that your application can parse to trigger additional retrieval calls before regenerating the answer.
Wire the prompt into your pipeline as a recovery node. The input payload should include the original user query, the full generated answer that failed validation, the list of retrieved passages with their metadata (source ID, retrieval score, chunk index), and the specific validation failure reasons from your upstream evaluator. Parse the output JSON to extract the gap_queries array and feed each query into your retrieval system—vector search, keyword search, or hybrid—with the same collection scope but potentially relaxed similarity thresholds to capture broader evidence. Collect the new passages, deduplicate against the original context set, and append them to the context before calling your answer generation prompt again. Implement a retry budget: if after two gap-fill cycles the answer still fails citation completeness checks, escalate to a human reviewer or trigger an abstention response.
Add validation gates at each stage. Before executing the gap queries, validate that the prompt output contains the required fields: identified_gaps (array of objects with claim, missing_evidence_type, and search_terms), gap_queries (array of strings), and abstention_recommended (boolean). If abstention_recommended is true, skip retrieval and route directly to your abstention handler. After retrieval, run a deduplication check to avoid re-feeding the model with passages it already saw. Log every cycle—original validation failure, gap analysis output, queries executed, new passages retrieved, and regeneration result—to your observability platform so you can measure recovery success rates and identify patterns that require prompt or retrieval tuning. For high-stakes domains, insert a human review step before the regenerated answer is surfaced to the user, especially when the gap-fill cycle introduces sources with lower relevance scores than the original set.
Expected Output Contract
Fields, format, and validation rules for the Evidence Gap Identification and Fill Prompt output. Use this contract to parse, validate, and route the model response before triggering re-retrieval or regeneration.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
gap_analysis | Array of objects | Must be a non-empty array. Each object must contain gap_description, gap_severity, and target_queries fields. | |
gap_analysis[].gap_description | String | Must be a non-empty string describing a specific evidence gap. Must reference a concrete claim from [ORIGINAL_ANSWER] that lacks support. | |
gap_analysis[].gap_severity | Enum: critical, high, medium, low | Must match one of the four enum values. Critical gaps indicate unsupported factual claims. Low gaps indicate minor context omissions. | |
gap_analysis[].target_queries | Array of strings | Must contain 1-5 retrieval query strings. Each query must be a self-contained search string suitable for the [RETRIEVAL_SYSTEM]. Empty array is invalid. | |
overall_sufficiency_score | Number (0.0 to 1.0) | Must be a float between 0.0 and 1.0. Score below [SUFFICIENCY_THRESHOLD] should trigger re-retrieval. Parse as float and validate range. | |
abstention_recommended | Boolean | Must be true or false. If true, the answer should not be regenerated without additional evidence. Validate as strict boolean, not string. | |
abstention_rationale | String or null | Required if abstention_recommended is true. Must explain why evidence is insufficient. Null allowed when abstention_recommended is false. | |
re_verification_required | Boolean | Must be true or false. If true, the regenerated answer must pass a source-to-claim alignment check before release. Validate as strict boolean. |
Common Failure Modes
Evidence gap identification fails in predictable ways. These cards cover the most common failure modes and how to guard against them in production.
Over-Identification of Gaps
What to watch: The prompt flags every minor uncertainty as a critical evidence gap, triggering unnecessary re-retrieval loops that waste compute and increase latency. The model treats stylistic hedging or cautious language as factual insufficiency. Guardrail: Set explicit gap severity thresholds in the prompt. Require the model to distinguish between 'missing core fact,' 'missing supporting detail,' and 'stylistic softening.' Only trigger retrieval for core fact gaps. Add a minimum confidence delta before a gap is actionable.
Vague or Unretrievable Gap Queries
What to watch: The prompt identifies a real gap but formulates a retrieval query that is too broad, too narrow, or phrased in a way that doesn't match the retrieval index. The re-retrieval returns irrelevant or empty results, wasting a retry cycle. Guardrail: Require the prompt to output both the gap description and the exact retrieval query. Validate query specificity before execution. Include query rewriting rules that map gap types to query patterns. Log gap-to-query pairs for offline tuning.
Gap-Fill Hallucination Under Retrieval Pressure
What to watch: After re-retrieval returns weak or partial evidence, the model fills the remaining gap with plausible-sounding but unsupported content rather than admitting the evidence is still insufficient. The pressure to 'fill the gap' overrides the abstention instinct. Guardrail: Add an explicit post-fill verification step that checks each filled claim against the newly retrieved evidence. Require the model to mark claims as 'filled from evidence,' 'partially supported,' or 'still unsupported.' Set a hard rule: if evidence is insufficient after one retry, abstain rather than fabricate.
Context Window Exhaustion from Repeated Retrieval
What to watch: Each retry cycle adds more retrieved passages to the context window. After two or three cycles, the combined original context plus new evidence exceeds the model's effective context limit, causing truncation, lost citations, or degraded reasoning on earlier claims. Guardrail: Implement a context budget that reserves space for retry evidence. Before each re-retrieval, summarize or compress the existing context. Set a maximum number of retry cycles based on token budget, not just attempt count. Monitor context utilization in production traces.
Gap Drift Across Retry Cycles
What to watch: The initial gap identification is accurate, but after re-retrieval and regeneration, the answer shifts focus. New gaps appear that are unrelated to the original question, triggering cascading retries that drift further from the user's intent with each cycle. Guardrail: Anchor every retry cycle to the original user question. Include the original question in each retry prompt and require the model to explain how each identified gap relates to answering that specific question. Set a drift detector that aborts retries if new gaps are semantically distant from the original query.
Silent Gap Masking in Confident Tone
What to watch: The model generates an answer with high confidence markers and fluent prose, but the evidence gap identification step fails to detect missing support because the model's own generation confidence overrides its gap-detection objectivity. The output reads well but contains unsupported claims. Guardrail: Separate gap identification from answer generation into distinct prompt calls or distinct sections with explicit role framing. Use a verification-only pass that treats the generated answer as untrusted input. Cross-check claim presence against evidence presence with a structured alignment table before releasing the answer.
Evaluation Rubric
Criteria for evaluating the quality of evidence gap identification and fill outputs before integrating into a production RAG pipeline. Each criterion should be tested with a representative sample of answers containing known evidence gaps.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Gap Coverage | All unsupported factual claims in [ORIGINAL_ANSWER] are identified as gaps; no supported claims are incorrectly flagged | Missing a known unsupported claim or flagging a claim that has clear source support in [RETRIEVED_EVIDENCE] | Compare gap list against a pre-annotated answer with known supported and unsupported claims; measure recall and precision |
Query Relevance | Each generated retrieval query in [GAP_QUERIES] directly targets a specific identified gap and uses terminology from the gap description | Query is generic, repeats the original user question verbatim, or targets a claim already supported by existing evidence | Manual review of query-to-gap mapping; verify each query addresses exactly one gap and uses gap-specific terms |
Query Specificity | Queries include key entities, constraints, or qualifiers from the gap claim to narrow retrieval scope | Query is overly broad, missing critical entities or temporal/quantitative constraints present in the gap claim | Check that each query contains at least one specific entity or constraint from the corresponding gap description |
No Hallucinated Gaps | Gap descriptions accurately reflect what is missing from [RETRIEVED_EVIDENCE] without inventing claims the original answer never made | Gap description references a claim not present in [ORIGINAL_ANSWER] or misstates what the answer actually said | Diff gap descriptions against the original answer text; flag any gap that cannot be traced to a specific sentence in the answer |
Gap-to-Query Cardinality | One query per gap unless a single gap requires multiple retrieval angles; no orphan queries without a corresponding gap | Multiple queries targeting the same gap without distinct retrieval angles, or queries with no mapped gap | Count gaps and queries; verify a 1:1 or 1:N mapping exists and that N>1 queries for a gap have distinct search intents |
Re-verification Readiness | Output includes a clear mapping between each gap, its query, and the expected evidence type needed to fill it, enabling downstream re-verification | Output provides queries without explaining what kind of evidence would satisfy each gap, making re-verification ambiguous | Check that each gap-query pair includes an evidence expectation field or description that a verifier prompt could use |
Abstention Handling | When [RETRIEVED_EVIDENCE] is empty or entirely irrelevant, the output correctly identifies all answer claims as gaps rather than fabricating queries for unsupported claims | Output generates queries for claims when no evidence exists to support any claim, or fails to flag all claims as gaps when evidence is absent | Test with an empty evidence set and an answer containing multiple claims; verify all claims are flagged as gaps |
Output Schema Compliance | Output strictly matches [OUTPUT_SCHEMA] with all required fields present and correctly typed | Missing required fields, extra fields not in schema, or type mismatches that would break downstream parsing | Validate output against the JSON schema; check field presence, types, and enum values |
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 retrieval pass and manual gap review. Remove the [REQUERY_LIMIT] constraint and skip structured output validation. Focus on getting the gap-to-query mapping logic right before adding harness complexity.
Prompt modification
- Replace
[OUTPUT_SCHEMA]with a simple markdown table:| Gap | Missing Evidence | Targeted Query | - Set
[REQUERY_LIMIT]to 1 and ignore[CONFIDENCE_THRESHOLD] - Remove the
[RE-VERIFICATION_STEP]section entirely
Watch for
- Gaps described too vaguely to form a useful query
- The model inventing gaps that aren't actually missing from the evidence
- Queries that restate the original question instead of targeting the specific gap

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