Inferensys

Prompt

Answerability Prediction Prompt Before Retrieval

A practical prompt playbook for using Answerability Prediction Prompt Before Retrieval 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

A pre-retrieval gate that predicts whether your knowledge base can answer a query before you pay for the search.

This prompt is for RAG system designers who need to reduce retrieval latency and cost without degrading answer quality. It acts as a pre-retrieval classifier: given a user query and a structured description of your knowledge base's scope, the model predicts whether retrieval is likely to return sufficient evidence. When the prediction is negative, the system can skip the retrieval call entirely and route directly to a refusal or clarification workflow. This is most valuable when retrieval is expensive—either in dollars per query, milliseconds of user-facing latency, or load on a rate-limited search backend—and when your knowledge base has clear, describable boundaries.

The prompt works best with well-scoped, structured knowledge bases such as product documentation for a single API, a company policy manual, or a domain-specific corpus like medical guidelines for a particular condition. You must provide a concise but accurate description of what the knowledge base contains and, critically, what it does not contain. The model uses this description, not the actual documents, to make its prediction. This means the quality of your knowledge base description directly determines the classifier's accuracy. A vague description produces unreliable predictions. A description that overstates coverage produces false positives that waste retrieval calls. A description that understates coverage produces false negatives that skip retrieval when answers exist.

Do not use this prompt when your knowledge base is too large, heterogeneous, or frequently updated to summarize accurately in a prompt. Do not use it when retrieval is so cheap and fast that the cost of a false negative—skipping retrieval when an answer exists—exceeds the cost of always running retrieval. Do not use it as a replacement for post-retrieval evidence sufficiency checks; this is a pre-filter, not a grounding verifier. Always pair this prompt with a post-retrieval evaluation step that confirms whether the retrieved passages actually support an answer. The pre-retrieval gate reduces unnecessary calls; the post-retrieval gate catches the ones that slip through.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Answerability Prediction Prompt delivers value and where it introduces risk. Use these cards to decide if pre-retrieval gating fits your RAG architecture.

01

Good Fit: High-Cost Retrieval Pipelines

Use when: your retrieval step is expensive in latency, compute, or API cost, and many queries are unanswerable. Guardrail: deploy the prediction prompt as a fast, cheap gate before invoking vector search, reranking, or LLM synthesis.

02

Bad Fit: Ambiguous or Underspecified Queries

Avoid when: user queries are short, vague, or depend on conversational context for meaning. Guardrail: route ambiguous queries to a clarification prompt first; do not use answerability prediction as a blunt refusal tool for poorly formed questions.

03

Required Input: Knowledge Base Description

What to watch: the model cannot predict answerability without understanding what the knowledge base contains. Guardrail: provide a structured description of the KB's domain, document types, temporal coverage, and known gaps in the system prompt or as a [KB_DESCRIPTION] variable.

04

Operational Risk: Prediction-Retrieval Mismatch

What to watch: the pre-retrieval prediction says 'answerable' but retrieval returns insufficient evidence, or vice versa. Guardrail: log every prediction alongside post-retrieval sufficiency scores; trigger a review queue when the mismatch rate exceeds a defined threshold over a rolling window.

05

Operational Risk: Over-Refusal Drift

What to watch: the prediction prompt becomes conservative over time, refusing queries the KB could actually answer. Guardrail: run a weekly eval set of known-answerable queries through the prediction gate and alert if the false-refusal rate rises above the product SLA.

06

Good Fit: Safety-Critical Answer Release Gates

Use when: you need a pre-release gate that prevents speculative answers from reaching users in regulated domains. Guardrail: combine the prediction prompt with a post-retrieval evidence sufficiency check; only release answers that pass both gates, and escalate borderline cases for human review.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready system prompt that predicts whether your knowledge base can answer a query before you spend tokens on retrieval.

This prompt is designed to act as a pre-retrieval gate in your RAG pipeline. By asking the model to predict answerability based solely on the user's question and a description of your knowledge base, you can avoid expensive and latency-inducing vector searches for queries that are likely to fail. This is most effective when your knowledge base has a clear, describable domain boundary, such as 'internal product documentation for the Acme API' or 'peer-reviewed articles on cardiovascular drug interactions.'

text
You are a pre-retrieval answerability classifier. Your task is to predict whether a knowledge base likely contains sufficient information to answer a user's question. You must make this prediction before any search is performed, based only on the question and a description of the knowledge base's contents.

<knowledge_base_description>
[KNOWLEDGE_BASE_DESCRIPTION]
</knowledge_base_description>

<user_question>
[USER_QUESTION]
</user_question>

<classification_instructions>
Analyze the user's question against the knowledge base description. Determine if the question falls within the topical, temporal, and structural scope of the described documents. A question is 'unanswerable' if it asks for information clearly outside the domain, requires real-time data the knowledge base would not contain, or demands a type of reasoning the documents cannot support.

Return a JSON object with the following schema:
{
  "prediction": "answerable" | "unanswerable",
  "confidence": 0.0-1.0,
  "rationale": "A concise, one-sentence explanation for the prediction."
}
</classification_instructions>

<constraints>
- Do not attempt to answer the user's question.
- Base your prediction strictly on the knowledge base description, not on your own world knowledge.
- If the question is ambiguous, predict 'unanswerable' and explain that clarification is needed.
</constraints>

To adapt this template, replace the [KNOWLEDGE_BASE_DESCRIPTION] placeholder with a static, high-level summary of your indexed documents. This description should be treated as a constant in your application configuration. The [USER_QUESTION] placeholder should be dynamically populated with the user's input at runtime. The output is a structured JSON object that your application can parse to decide whether to proceed with retrieval. For high-stakes applications, log the rationale field alongside the prediction to enable offline accuracy audits and calibration of the confidence score against post-retrieval ground truth.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be populated before the prompt is sent. Incomplete variables produce unreliable predictions. Validate all inputs against the rules below before calling the model.

PlaceholderPurposeExampleValidation Notes

[USER_QUERY]

The raw user question to evaluate for answerability before retrieval

What is the refund policy for international orders placed after January 2024?

Must be non-empty string. Check for minimum 10 characters. Reject queries that are purely greetings, profanity, or system commands. Log ambiguous single-word queries for review.

[KNOWLEDGE_BASE_DESCRIPTION]

A structured description of what the knowledge base contains, including document types, date ranges, and coverage gaps

Internal knowledge base: product documentation (2022-2025), support tickets (2023-2025), legal policies (2024 only). No financial records or customer PII.

Must be non-empty string. Should include explicit coverage boundaries and known gaps. Validate that description is updated within last 30 days. Stale descriptions produce false-positive answerability predictions.

[DOMAIN_CONSTRAINTS]

Domain-specific rules about what types of questions are in-scope versus out-of-scope for the knowledge base

In-scope: product features, pricing, shipping, returns, account management. Out-of-scope: legal advice, medical guidance, competitor comparisons, speculative forecasts.

Must be non-empty string. Should enumerate both in-scope and out-of-scope categories. Validate against product policy documentation. Missing out-of-scope definitions cause overconfident predictions on edge-case queries.

[ANSWERABILITY_CLASSES]

The classification labels the model must choose from, with definitions for each class

ANSWERABLE: KB likely contains sufficient evidence. UNANSWERABLE: KB lacks evidence or query is out-of-scope. UNCERTAIN: KB coverage is ambiguous for this query type.

Must include at least 2 classes. Each class must have a clear definition. Validate that UNCERTAIN class exists to prevent forced binary decisions on ambiguous queries. Test class definitions against edge cases before deployment.

[CONFIDENCE_REQUIREMENT]

The minimum confidence threshold for returning ANSWERABLE versus UNCERTAIN or UNANSWERABLE

0.85

Must be float between 0.0 and 1.0. Values below 0.7 produce excessive false positives. Values above 0.95 cause over-refusal. Calibrate against 100+ labeled query-KB pairs. Log all predictions where confidence is within 0.05 of threshold for human review.

[OUTPUT_SCHEMA]

The exact JSON structure the model must return, including field types and nullability rules

{"prediction": "ANSWERABLE|UNANSWERABLE|UNCERTAIN", "confidence": 0.0-1.0, "rationale": "string", "missing_evidence_types": ["string"] | null}

Must be valid JSON schema. Validate model output against schema before downstream consumption. Reject outputs with extra fields or missing required fields. missing_evidence_types must be null when prediction is ANSWERABLE, non-null array when UNANSWERABLE.

[FEW_SHOT_EXAMPLES]

2-4 labeled examples showing correct predictions with rationale for each class

[{"query": "How do I reset my password?", "prediction": "ANSWERABLE", "confidence": 0.92, "rationale": "KB contains account management docs including password reset procedures.", "missing_evidence_types": null}]

Must include at least one example per class. Examples must be drawn from real query-KB pairs, not fabricated. Validate that example rationales reference actual KB content. Update examples when KB description changes. Stale examples cause prediction drift.

[PRE_RETRIEVAL_INSTRUCTIONS]

System-level instructions defining the model's role, constraints, and refusal behavior for this prediction task

You are a pre-retrieval answerability classifier. Do not answer the user query. Only predict whether the knowledge base contains sufficient evidence. If the query is out-of-scope per domain constraints, predict UNANSWERABLE. Do not speculate about KB content beyond the description provided.

Must be non-empty string. Must explicitly forbid answering the query. Must reference DOMAIN_CONSTRAINTS and KNOWLEDGE_BASE_DESCRIPTION placeholders. Validate that instructions do not leak sensitive KB content. Test against prompt injection attempts that try to bypass classification role.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the answerability prediction prompt into a RAG pipeline with validation, logging, and fallback behavior.

The answerability prediction prompt acts as a pre-retrieval gate. Instead of immediately executing an expensive vector search, your application first asks the model to predict whether the knowledge base is likely to contain sufficient evidence. This decision point must be wired into your RAG pipeline with clear branching logic: if the prediction is UNANSWERABLE, skip retrieval entirely and return a refusal or clarification response. If ANSWERABLE, proceed to retrieval and answer generation. The harness must treat the prediction as a probabilistic signal, not a deterministic rule—a false negative here means a question that could have been answered gets refused, while a false positive wastes retrieval compute on a question that will ultimately fail grounding checks.

Implement this as a lightweight pre-flight check with strict latency and cost budgets. Use a fast, inexpensive model (e.g., GPT-4o-mini, Claude Haiku, or a fine-tuned small model) rather than your primary generation model. The prompt should return structured JSON with at minimum an answerability field (ANSWERABLE | UNANSWERABLE | UNCLEAR) and a rationale string. Validate the output shape immediately: if the model returns malformed JSON or an unexpected enum value, default to UNCLEAR and proceed with retrieval to avoid blocking legitimate queries. Log every prediction alongside the eventual post-retrieval ground truth—did retrieval actually find sufficient evidence? This log becomes your evaluation dataset for measuring prediction accuracy, false-positive rate, and false-negative rate over time.

For production hardening, implement a circuit breaker: if the prediction model returns errors or exceeds a latency threshold (e.g., 500ms), bypass the gate and proceed directly to retrieval. Never let the pre-retrieval check become a single point of failure. Store predictions in your observability stack with trace IDs that link the pre-retrieval decision to the downstream retrieval results and final answer. This traceability lets you answer critical operational questions: 'Are we refusing questions we could answer?' and 'Are we wasting retrieval on questions we ultimately can't ground?' Use these metrics to tune the prediction threshold and decide when to retrain or replace the prediction prompt. If your application operates in a regulated domain, ensure the prediction rationale is preserved in audit logs alongside the final answer or refusal.

IMPLEMENTATION TABLE

Expected Output Contract

The model must return a JSON object matching this schema. Validate before branching your pipeline logic.

Field or ElementType or FormatRequiredValidation Rule

answerability_prediction

string enum: [ANSWERABLE, UNANSWERABLE, UNCLEAR]

Must be exactly one of the three enum values. Reject any other string.

confidence_score

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive. Parse and check range.

rationale

string

Must be a non-empty string with at least 20 characters. Check length after trimming.

likely_missing_information

array of strings

If present, each element must be a non-empty string. Null or empty array is allowed.

suggested_retrieval_queries

array of strings

If present, each element must be a non-empty string. Null or empty array is allowed.

recommended_action

string enum: [PROCEED_WITH_RETRIEVAL, REFUSE_EARLY, CLARIFY_QUERY]

Must be exactly one of the three enum values. Reject any other string.

query_ambiguity_flag

boolean

Must be true or false. Reject string representations like 'true' or 'false'.

prediction_timestamp

string (ISO 8601)

If present, must match ISO 8601 datetime format. Validate with date parsing.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when you predict answerability before retrieval, and how to guard against each failure mode in production.

01

Overconfident False Positives

What to watch: The model predicts the knowledge base can answer a question, but post-retrieval evidence is insufficient or irrelevant. This wastes retrieval costs and produces hallucinated answers downstream. Guardrail: Log every prediction alongside post-retrieval sufficiency ground truth. Set a precision target (e.g., 90%) and trigger a human review or fallback retrieval when the prediction confidence is below a calibrated threshold.

02

Premature Refusal on Answerable Queries

What to watch: The model refuses to retrieve because it underestimates the knowledge base coverage, blocking valid answers. This degrades user trust and system recall. Guardrail: Maintain a holdout set of known-answerable queries and measure the false-refusal rate. If it exceeds 5%, lower the refusal threshold or add few-shot examples of queries that appear unanswerable but are actually covered.

03

Domain Shift Between Prediction and Retrieval

What to watch: The pre-retrieval prediction prompt was tuned on one knowledge base but deployed against another with different coverage, terminology, or depth. Prediction accuracy collapses silently. Guardrail: Recalibrate the prediction prompt on a representative sample from the target knowledge base before deployment. Monitor prediction-vs-retrieval agreement drift weekly and retrain thresholds when distribution shifts.

04

Ambiguous Query Misclassification

What to watch: The model cannot determine answerability because the query is underspecified, but it guesses instead of flagging ambiguity. This produces noisy predictions that downstream systems treat as confident signals. Guardrail: Add an explicit ambiguity detection instruction in the prompt. Require the model to output AMBIGUOUS when the query lacks enough specificity to assess answerability, and route ambiguous cases to clarification before retrieval.

05

Prediction Latency Exceeding Retrieval Savings

What to watch: The pre-retrieval prediction call takes as long as a cheap retrieval call, eliminating the cost benefit. This happens with large prompts, slow models, or unnecessary reasoning steps. Guardrail: Benchmark prediction latency against your fastest retrieval path. If prediction exceeds 30% of retrieval latency, simplify the prompt, use a smaller model for the prediction step, or cache predictions for repeated query patterns.

06

Missing Knowledge Base Description Drift

What to watch: The prediction prompt includes a stale description of the knowledge base scope, so the model makes answerability decisions based on outdated coverage assumptions. Guardrail: Generate the knowledge base description programmatically from metadata, document counts, or topic summaries rather than hardcoding it. Version the description alongside the knowledge base index and validate prediction accuracy after each index update.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a labeled dataset before shipping. Your dataset should include queries with known retrieval outcomes.

CriterionPass StandardFailure SignalTest Method

Answerability prediction accuracy

Prediction matches post-retrieval ground truth for >= 90% of test queries

Prediction says 'answerable' but retrieval returns zero relevant passages, or prediction says 'unanswerable' but retrieval returns sufficient evidence

Run prompt on labeled dataset with known retrieval outcomes; compute precision, recall, and F1 for both classes

Early refusal recall

= 95% of truly unanswerable queries are predicted as unanswerable before retrieval

Unanswerable query passes the pre-retrieval gate and triggers expensive but futile retrieval

Measure recall on the subset of test queries where post-retrieval ground truth confirms zero sufficient evidence

False refusal rate

<= 5% of truly answerable queries are incorrectly predicted as unanswerable

Answerable query is blocked before retrieval, preventing a valid response from being generated

Measure false-positive rate on the subset of test queries where post-retrieval ground truth confirms sufficient evidence exists

Prediction confidence calibration

Confidence score correlates with actual retrieval success: high-confidence predictions are correct >= 85% of the time

High-confidence 'answerable' predictions frequently fail to retrieve evidence, or low-confidence predictions are frequently wrong

Bucket predictions by confidence score; compute accuracy per bucket; check monotonic relationship between confidence and accuracy

Ambiguous query handling

Ambiguous queries are flagged with confidence <= 0.5 or classified as 'uncertain' rather than forced into binary answerable/unanswerable

Ambiguous query receives high-confidence binary prediction that is effectively a coin flip

Curate a set of deliberately ambiguous queries; verify predictions fall into low-confidence or uncertain categories

Latency overhead

Pre-retrieval prediction adds <= 200ms median latency to the request pipeline

Prediction step takes longer than a fast retrieval call, negating the cost-saving purpose

Benchmark prediction prompt latency across 100+ queries; measure p50 and p99 against latency budget

Cost savings validation

Pre-retrieval refusal prevents retrieval for >= 80% of truly unanswerable queries, reducing total retrieval costs measurably

Prediction prompt cost plus false-positive retrieval costs exceed the cost of always running retrieval

Calculate total cost (prediction tokens + retrieval tokens) vs. baseline always-retrieve cost on production traffic sample

Domain shift robustness

Prediction accuracy on out-of-domain queries degrades by <= 10 percentage points vs. in-domain test set

Prompt overfits to training-domain phrasing and fails on queries from adjacent domains or new terminology

Test on held-out domain dataset; compare accuracy, recall, and false-refusal rate against in-domain baseline

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt\nUse the base prompt with a single frontier model call. Skip the retrieval step entirely for initial testing—mock the knowledge base description and query complexity. Focus on whether the model can produce a coherent `answerable`/`unanswerable`/`uncertain` prediction with a rationale.\n\n### Watch for\n- Overly optimistic predictions when the model hasn't seen the actual retrieval set\n- Missing output schema enforcement—add a simple JSON schema validator early\n- The model conflating its own knowledge with what the knowledge base likely contains\n- No baseline accuracy measurement against post-retrieval ground truth

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.