Inferensys

Prompt

Evidence Gap Detection Prompt for RAG Abstention

A practical prompt playbook for using Evidence Gap Detection Prompt for RAG Abstention in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise job-to-be-done, ideal user profile, required inputs, and critical anti-patterns for the Evidence Gap Detection prompt.

This prompt is for AI engineers building Retrieval-Augmented Generation (RAG) systems where a wrong answer carries a higher cost than no answer. Its job is not to generate a response, but to act as a pre-generation gate. It takes a user query and a set of retrieved context chunks and produces a structured 'gap report' that explicitly maps which parts of the query are supported by the provided evidence and which parts are not. The ideal user is an engineering lead or senior developer who needs to programmatically decide whether to proceed with answer synthesis, trigger a second retrieval pass with rewritten queries, or escalate to a human operator. You should use this prompt when your application operates in a high-stakes domain—such as clinical informatics, legal research, or financial compliance—where hallucination is unacceptable and the system must demonstrate a clear chain of evidence before speaking.

To use this prompt effectively, you must provide a specific user query and the raw, unsummarized text chunks retrieved from your vector store or search index. The prompt is designed to work as a deterministic filter in your inference pipeline: it expects a strict output schema that your application code can parse to make a binary or tiered routing decision. For example, if the gap report indicates that the context lacks information on a specific drug interaction, your harness can immediately block answer generation and route the query to a drug database API instead. Do not use this prompt as a general-purpose confidence scorer or to produce a numeric probability. It is a qualitative reasoning tool that produces a map of evidence coverage and missing entities, not a calibrated score. Using it for numeric confidence will lead to brittle, uncalibrated results.

Avoid using this prompt when the cost of abstention is higher than the cost of a partially correct answer, such as in casual chatbots or creative brainstorming tools. It is also a poor fit for real-time, low-latency applications where the overhead of an extra LLM call before every answer is prohibitive. The next step after reading this section is to examine the prompt template and adapt the output schema to match your routing logic. Before deploying, you must build a validation harness that checks the gap report against a golden dataset of queries with intentionally insufficient context to ensure the model correctly identifies missing information without hallucinating gaps where evidence actually exists.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Evidence Gap Detection prompt delivers value and where it introduces risk. Use this to decide if the prompt fits your RAG pipeline before integrating it into a production harness.

01

Good Fit: Pre-Generation Gate

Use when: You need a structured gap report before answer synthesis to decide whether to answer, retrieve more, or abstain. Guardrail: Wire the output into a routing decision—if evidence_sufficient is false, block generation and trigger re-retrieval or escalation.

02

Good Fit: Audit Trail for Abstention

Use when: You must log why the system refused to answer for compliance or debugging. Guardrail: Store the full gap report alongside the query and retrieved context. This creates an auditable record that proves the abstention was evidence-based, not arbitrary.

03

Bad Fit: Single-Shot Q&A Without Retrieval Control

Avoid when: Your system cannot re-retrieve or escalate after the gap is detected. A gap report without a downstream action is wasted latency. Guardrail: Only deploy this prompt when the calling system can act on the output—otherwise use a simpler binary abstention check.

04

Bad Fit: Open-Domain Chat Without Grounding

Avoid when: The model is expected to answer from parametric knowledge when retrieval fails. This prompt is designed to enforce evidence grounding, not to permit creative or general-knowledge responses. Guardrail: If fallback to parametric knowledge is allowed, use a separate policy prompt instead of gap detection.

05

Required Input: Retrieved Context with Source Metadata

Risk: The prompt cannot detect gaps without actual retrieved passages to evaluate. Guardrail: Always pass at least one retrieval result with source identifiers. If the retriever returns zero results, short-circuit to abstention before calling this prompt.

06

Operational Risk: Hallucinated Gap Claims

Risk: The model may claim evidence is missing when it is present but poorly chunked, or claim sufficiency when context is irrelevant. Guardrail: Run regression tests with intentionally sufficient and insufficient context sets. Monitor false-positive and false-negative gap claims in production logs.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template that produces a structured gap report identifying what retrieved context can and cannot address, without answering the user's question.

The prompt below is designed to be dropped into a RAG pipeline immediately before answer synthesis. It forces the model to act as an auditor, not an answer engine. The template accepts retrieved context and a user question, then outputs a structured JSON report that downstream code can parse to decide whether to answer, retrieve more, escalate, or refuse. Every placeholder is enclosed in square brackets—replace them with your actual inputs before sending the request.

text
You are an evidence auditor for a retrieval-augmented generation system. Your only job is to assess whether the provided context can address the user's question. Do not answer the question. Do not speculate beyond the context. Do not fabricate missing information.

## INPUT
User Question:
[USER_QUESTION]

Retrieved Context:
[RETRIEVED_CONTEXT]

## OUTPUT SCHEMA
Return a single JSON object with exactly these fields:
{
  "coverage_assessment": "FULL" | "PARTIAL" | "NONE",
  "addressed_aspects": ["list of specific claims or sub-questions the context CAN address, with exact quotes where possible"],
  "gap_aspects": ["list of specific claims or sub-questions the context CANNOT address"],
  "missing_entities": ["list of key entities, dates, figures, or concepts mentioned in the question but absent from the context"],
  "evidence_quality_notes": "brief assessment of source recency, authority, and internal consistency within the provided context",
  "recommendation": "ANSWER" | "RETRIEVE_MORE" | "REFUSE"
}

## CONSTRAINTS
- If the context is completely irrelevant to the question, set coverage_assessment to "NONE" and recommendation to "REFUSE".
- If the context partially addresses the question but leaves material gaps, set coverage_assessment to "PARTIAL" and recommendation to "RETRIEVE_MORE".
- Only set recommendation to "ANSWER" when coverage_assessment is "FULL" and all sub-questions are directly supported by explicit evidence.
- Never invent entities, dates, or facts to fill gaps. If something is missing, list it in missing_entities.
- Quote the context verbatim in addressed_aspects when showing support.
- If multiple sources conflict, note this in evidence_quality_notes and do not resolve the conflict.

Adaptation guidance: Replace [USER_QUESTION] with the end user's query and [RETRIEVED_CONTEXT] with your retrieval pipeline's output—typically concatenated chunks with source identifiers. If your system uses multiple retrieval rounds, wire this prompt after the first retrieval pass and use the recommendation field to trigger a second retrieval with expanded or rewritten queries. For regulated domains, add a [DOMAIN_RULES] placeholder containing jurisdiction-specific abstention triggers (e.g., "Never assess coverage for drug interaction questions"). The output schema is intentionally flat to simplify downstream parsing; avoid nesting unless your validator explicitly supports nested object traversal. Always validate the JSON structure before acting on the recommendation—malformed outputs should trigger a retry or fallback to a safe refusal.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Evidence Gap Detection Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of false-negative gap reports.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The original question or request that needs to be answered from retrieved context.

What are the side effects of Drug X in patients over 65?

Must be a non-empty string. Check for prompt injection patterns before insertion. Truncate to 2000 characters.

[RETRIEVED_CONTEXT]

The set of passages, documents, or chunks returned by the retrieval step that the model must evaluate for evidence coverage.

Passage 1: Drug X clinical trial showed... Passage 2: In elderly populations, common reactions include...

Must be a non-empty string. Validate that context is not identical to previous failed retrieval attempts. Check for minimum token count (>50 tokens).

[OUTPUT_SCHEMA]

The exact JSON schema the model must follow when returning the gap report, including required fields for covered claims, gaps, and confidence.

{ "covered_claims": [...], "evidence_gaps": [...], "overall_sufficiency": "PARTIAL" }

Must be a valid JSON Schema object. Parse and validate before prompt assembly. Include enum constraints for sufficiency field: FULL, PARTIAL, NONE.

[DOMAIN_CONSTRAINTS]

Domain-specific rules that define what counts as sufficient evidence, including required source types, recency thresholds, and authority requirements.

Clinical: requires peer-reviewed sources within 5 years. Legal: requires primary statute or case law citation.

Must be a non-empty string or null. If null, the model will use general-purpose sufficiency heuristics. Validate against allowed domain list.

[ABSTENTION_POLICY]

The policy text defining when the system must refuse to answer, including risk thresholds, prohibited claim types, and escalation triggers.

Abstain if: (1) no source directly addresses the query, (2) only a single low-quality source exists, (3) query requests a diagnosis.

Must be a non-empty string. Policy text should be tested for contradictions with DOMAIN_CONSTRAINTS. Version-control this variable separately.

[MAX_GAPS]

The maximum number of evidence gaps the model should report before truncating. Prevents unbounded output when context is severely insufficient.

5

Must be an integer between 1 and 20. Default to 5 if not specified. Higher values increase token usage and may encourage hallucinated gap claims.

[PRIOR_TURN_CONTEXT]

Optional conversation history or previous gap reports from the same session, used to prevent redundant gap reporting across turns.

Previous turn: User asked about dosage. Gap reported: no pediatric data found.

Must be a string or null. If provided, validate that it does not exceed 4000 tokens. Strip any PII before inclusion.

PROMPT PLAYBOOK

Implementation Harness Notes

Wire this prompt as a pre-generation gate in your RAG pipeline to detect evidence gaps and trigger re-retrieval before answering.

This prompt is designed to operate as a pre-generation validation step in a RAG pipeline. After your initial retrieval call returns a set of documents, you call the model with this prompt, the user's original query, and the retrieved context. The model's job is not to answer the question but to produce a structured gap report. This report identifies which aspects of the query are covered by the context and which are not. The primary output is a JSON object containing covered_aspects, gap_aspects, and retrieval_suggestions. The presence of any items in gap_aspects is the signal to halt answer generation and initiate a corrective workflow.

To integrate this into an application, implement a post-retrieval router. After parsing the model's JSON output, check the gap_aspects array. If it is non-empty, do not proceed to the answer generation prompt. Instead, route the retrieval_suggestions to a re-retrieval module. This module should use the suggestions to rewrite the query or fetch additional documents from your knowledge base. After re-retrieval, concatenate the new context with the original context and call this gap detection prompt again. Implement a maximum retry limit of 2 re-retrieval attempts. If gaps persist after 2 retries, escalate the query, the final gap report, and the full context to a human review queue rather than generating a potentially incorrect answer.

A critical failure mode for this prompt is hallucinated gaps—the model claiming an aspect is missing when the context actually contains the information. You must implement a validator that cross-references each claimed gap against the provided context. A simple approach is to use a secondary, fast model call for each gap_aspect with a strict prompt: 'Is the information described by [GAP_ASPECT] present in the following context? Answer only YES or NO.' If the validator returns YES for any claimed gap, log a hallucinated_gap_detected warning, remove the false gap from the report, and proceed with the answer generation step. Log the full gap report, the validator results, and the final routing decision (proceed, re-retrieve, or escalate) for audit trails and to monitor the health of your retrieval pipeline over time.

IMPLEMENTATION TABLE

Expected Output Contract

The structured gap report fields, types, and validation rules that the Evidence Gap Detection Prompt must produce. Use this contract to build downstream parsers, validators, and retry logic.

Field or ElementType or FormatRequiredValidation Rule

gap_report

JSON object

Top-level key must exist and parse as valid JSON. Schema check: object, not array or scalar.

gap_report.query_summary

string

Non-empty string. Must contain a restatement of [USER_QUERY]. Length between 10 and 500 characters.

gap_report.answerable_questions

array of strings

Array must contain 0-10 items. Each string must be a question the context can answer. Null or empty array allowed if no questions are answerable.

gap_report.unanswerable_questions

array of objects

Array must contain 0-10 items. Each object must have 'question' (string) and 'missing_evidence' (string) keys. Null or empty array allowed if all questions are answerable.

gap_report.unanswerable_questions[].question

string

Non-empty string. Must be a question the context cannot answer. Must not duplicate any string in answerable_questions.

gap_report.unanswerable_questions[].missing_evidence

string

Non-empty string. Must describe what specific information is absent from [RETRIEVED_CONTEXT]. Must not hallucinate missing details not implied by the query.

gap_report.overall_sufficiency

string

Must be one of: 'sufficient', 'partial', 'insufficient'. Enum check required. 'sufficient' only allowed when unanswerable_questions is empty.

gap_report.recommendation

string

Must be one of: 'answer', 'retrieve_more', 'abstain'. Must align with overall_sufficiency: 'answer' requires 'sufficient', 'abstain' requires 'insufficient'.

PRACTICAL GUARDRAILS

Common Failure Modes

Evidence gap detection prompts fail in predictable ways. These are the most common production failure modes and the specific guardrails that prevent them.

01

Hallucinated Gap Claims

What to watch: The model invents missing information claims, asserting the context lacks something it actually contains, or fabricates a gap where none exists. This is most common with long contexts or when the model defaults to 'something is missing' patterns. Guardrail: Always require the model to quote the specific passage that should contain the missing information before declaring a gap. Add a validator that checks whether gap claims cite actual context passages.

02

False Sufficiency When Evidence Is Thin

What to watch: The model declares evidence sufficient and proceeds to answer when the retrieved context is vague, outdated, or only tangentially related. This is the most dangerous failure mode in high-stakes domains because it produces confident-sounding wrong answers. Guardrail: Implement a two-stage check: first assess sufficiency with a strict threshold, then generate the answer only if the sufficiency score exceeds the threshold. Calibrate thresholds against a golden dataset of known-insufficient contexts.

03

Over-Refusal on Borderline Queries

What to watch: The model refuses to answer queries where partial or caveated answers would be useful and safe. This erodes user trust and system utility, especially when the context contains relevant but incomplete information. Guardrail: Add explicit instructions distinguishing 'complete answer possible' from 'partial answer with caveats possible' from 'must refuse.' Test against a borderline query dataset and monitor refusal rates by query category.

04

Gap Report Drift Across Context Lengths

What to watch: The same query produces different gap assessments when context length varies, even when the relevant evidence is identical. Longer contexts dilute attention and cause the model to miss evidence that was visible in shorter contexts. Guardrail: Normalize context length in eval suites and test gap detection at multiple context sizes. Consider chunking strategies that keep relevant evidence within the model's high-attention window.

05

Entity Confusion in Gap Identification

What to watch: The model conflates similar entities, claiming evidence is missing for Entity A when the context actually addresses Entity B, or vice versa. This is common in domains with similar product names, drug names, or legal entities. Guardrail: Require the gap report to explicitly name the entity being checked and quote the closest matching passage. Add entity-level validation that cross-references gap claims against the original query entities.

06

Temporal Staleness Misinterpreted as Evidence Gap

What to watch: The model flags evidence as missing when the context contains relevant but dated information, without distinguishing 'no evidence' from 'old evidence.' This causes unnecessary refusals when the information is still valid or when staleness should be disclosed rather than treated as a gap. Guardrail: Add a temporal check dimension to the gap report: 'evidence present but dated' vs. 'evidence absent.' Include source date metadata in the context and require the model to note recency when flagging potential gaps.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the Evidence Gap Detection Prompt reliably distinguishes answerable from unanswerable queries before shipping. Each criterion targets a known failure mode in RAG abstention systems.

CriterionPass StandardFailure SignalTest Method

Correct Gap Identification

Prompt correctly identifies all missing entities or facts when context is insufficient

Prompt claims evidence is sufficient when key entities are absent from retrieved context

Run against 20 intentionally insufficient context sets; require 100% gap detection rate

No Hallucinated Gaps

Prompt reports zero gaps when all requested information is present in context

Prompt claims evidence is missing for facts that are explicitly stated in the provided passages

Run against 20 fully sufficient context sets; require 0% false gap rate

Gap Specificity

Each reported gap names the specific missing entity, fact, or relationship rather than vague categories

Gap report contains generic statements like 'more information needed' without specifying what is missing

Parse gap report fields; require each gap entry to contain at least one named entity or fact reference

Evidence Sufficiency Signal Accuracy

Sufficiency flag is true when context contains all required facts and false when it does not

Sufficiency flag is true for queries requiring facts outside context or false when all facts are present

Binary classification test against 50 labeled query-context pairs; require F1 score above 0.95

Missing Entity Enumeration

Gap report lists every entity from the query that has zero mentions in the retrieved context

Entities present in the query but absent from context are omitted from the gap report

Entity recall test: extract all query entities, check each against gap report; require 100% recall

Partial Evidence Handling

Prompt correctly distinguishes fully supported claims from partially supported claims with explicit boundary markers

Partially supported claims are reported as either fully sufficient or fully missing with no gradation

Run 15 partial-coverage scenarios; require explicit partial-support flag and boundary description in each output

Output Schema Compliance

Every output field in [OUTPUT_SCHEMA] is present and populated with the correct type

Missing required fields, null values in non-nullable fields, or type mismatches in structured output

Schema validation pass against 50 varied outputs; require 100% structural compliance

Abstention Trigger Consistency

Same query-context pair produces the same gap assessment across 5 repeated runs

Gap report flips between sufficient and insufficient across repeated identical inputs

Run 10 borderline cases 5 times each; require identical sufficiency decision in all runs

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single model call. Use a simple JSON schema with evidence_gaps, sufficiency, and recommendation fields. Skip retries and validation beyond basic parse checks. Accept string enums like "sufficient" | "insufficient" | "partial" without strict normalization.

Watch for

  • Model inventing gaps that don't exist in the context (hallucinated gap claims)
  • Inconsistent enum values across runs (e.g., "partially_sufficient" vs "partial")
  • Overly verbose gap descriptions that bury the signal
  • Missing recommendation field when context is clearly insufficient
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.