This prompt is for RAG system builders who retrieve more candidate passages than can fit in a single context window. Its job is to act as a relevance filter and ranking engine: given a user query and a set of retrieved documents, it selects the most pertinent passages, ranks them by evidentiary value, and provides a concise rationale for each selection. The ideal user is an AI engineer or technical decision maker integrating this into a production retrieval pipeline where context budgets are tight and hallucination risks must be minimized through explicit evidence selection.
Prompt
Evidence Ranking and Selection Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Evidence Ranking and Selection Prompt.
Use this prompt when your retrieval step returns a noisy candidate set—for example, a vector search that pulls back 20 chunks but your generation step can only accommodate 5. It is appropriate for fact-checking, question answering, and any workflow where downstream accuracy depends on the quality of the evidence passed to a synthesis model. The prompt forces the model to justify its selections, which creates an audit trail and helps catch ranking errors before they propagate. It is not a replacement for a retrieval system; it assumes you already have a candidate set. Do not use it when you have only one or two passages, when latency constraints prohibit an intermediate ranking step, or when the evidence is so domain-specialized that a general-purpose model cannot reliably assess relevance without fine-tuning.
Before deploying, calibrate the prompt against two known failure modes: position bias, where the model over-ranks passages at the beginning or end of the input list, and recency bias, where it favors passages with recent-sounding language even when older sources are more authoritative. Your evaluation harness should shuffle passage order across test runs and include deliberately stale but relevant passages to measure these biases. If the ranking task is high-stakes—such as legal, medical, or financial verification—always route the final ranked set to a human reviewer and log the model's selection rationale alongside the original candidate set for auditability.
Use Case Fit
Where the Evidence Ranking and Selection Prompt works, where it fails, and the operational preconditions required before deploying it in a production RAG pipeline.
Good Fit: High-Volume Retrieval Pipelines
Use when: your RAG system retrieves more passages than the context window allows and you need a reliable, repeatable method to select the most relevant evidence. Guardrail: Always log the full retrieved set alongside the ranked output to audit for selection bias.
Bad Fit: Single-Source or Trivial Retrieval
Avoid when: only one or two documents are retrieved, or the total token count is well within the model's limit. Ranking adds latency and cost without improving quality. Guardrail: Implement a token-count gate that skips the ranking step when total context is below a defined threshold.
Required Inputs: Structured Evidence with Metadata
Risk: Ranking quality collapses if passages lack source identifiers, retrieval scores, or publication dates. The model cannot weigh authority or recency without metadata. Guardrail: Enforce a strict input schema requiring passage_id, source, retrieval_score, and date for every evidence chunk before calling the ranking prompt.
Operational Risk: Position and Recency Bias
What to watch: Models disproportionately favor the first and last passages in a list, and may overweight recently published sources regardless of authority. Guardrail: Randomize passage order before ranking, and include explicit recency-weighting instructions in the prompt with domain-specific staleness thresholds.
Operational Risk: Silent Evidence Dropping
What to watch: The ranking prompt may omit relevant but lower-ranked passages entirely, creating an evidence gap that downstream answer generation cannot detect. Guardrail: Always output a discarded_passages list with explicit drop reasons, and run a coverage check against the original claim set.
Scale Limit: Cost and Latency at High QPS
What to watch: Ranking prompts add a full model round-trip per query, which can double latency and cost in high-throughput systems. Guardrail: Use a smaller, faster model for ranking (cross-encoder or lightweight LLM) and reserve full-model ranking only for high-stakes or low-confidence retrieval sets.
Copy-Ready Prompt Template
A reusable prompt for ranking and selecting the most relevant evidence passages from a retrieved set, with explicit selection rationale.
This template is designed for RAG systems that retrieve more candidate passages than can fit in the model's context window. Instead of silently truncating results or using a simple vector-similarity cutoff, this prompt instructs the model to explicitly rank passages by relevance and select the top subset. The output includes a rationale for each selection, which is critical for debugging retrieval quality and preventing position bias from influencing the final answer generation step.
textYou are an evidence ranking specialist. Your task is to evaluate a set of retrieved passages against a user query and select the most relevant passages for answering that query. ## INPUT **User Query:** [QUERY] **Retrieved Passages:** [PASSAGES] ## CONSTRAINTS - Select exactly [TOP_K] passages. - Do not select passages that are irrelevant, redundant, or contain only background information. - Prefer passages that directly address the query with specific facts, data, or authoritative statements. - If multiple passages contain the same information, select the most complete and well-sourced version. - If fewer than [TOP_K] passages are relevant, select only the relevant ones and leave the remaining slots empty. - Do not modify, summarize, or paraphrase the passage text in your output. ## OUTPUT FORMAT Return a JSON object with the following structure: { "selected_passages": [ { "passage_id": "string (the identifier from the input)", "relevance_score": number (0.0 to 1.0), "rationale": "string (one sentence explaining why this passage is relevant to the query)", "passage_text": "string (the full original passage text)" } ], "discarded_passages": [ { "passage_id": "string", "discard_reason": "string (one of: 'irrelevant', 'redundant', 'insufficient_detail', 'outdated', 'low_authority')" } ], "selection_summary": "string (brief explanation of the overall selection strategy and any notable trade-offs)" } ## EXAMPLE **Query:** What is the capital of France? **Passages:** [1] Paris is the capital and most populous city of France. [2] France is a country in Western Europe. [3] The Eiffel Tower is located in Paris. [4] Lyon is a major city in France known for its cuisine. **Output:** { "selected_passages": [ { "passage_id": "1", "relevance_score": 1.0, "rationale": "Directly states that Paris is the capital of France, exactly answering the query.", "passage_text": "Paris is the capital and most populous city of France." } ], "discarded_passages": [ {"passage_id": "2", "discard_reason": "irrelevant"}, {"passage_id": "3", "discard_reason": "irrelevant"}, {"passage_id": "4", "discard_reason": "irrelevant"} ], "selection_summary": "Only passage 1 directly answers the query. The remaining passages provide context about France or Paris but do not address the specific question about the capital." }
To adapt this template, replace [QUERY] with the user's original question, [PASSAGES] with your formatted retrieval results (each passage must include a unique identifier), and [TOP_K] with the number of passages your downstream context window can accommodate. The passage format you provide should include both an ID and the full text. If your retrieval system returns metadata like source URLs or publication dates, include those in the passage objects so the model can use them for authority and recency judgments. For production use, add a [RISK_LEVEL] field that triggers additional validation when ranking is used for high-stakes decisions, and consider adding [DOMAIN] to adjust relevance criteria for specialized fields like medicine or law.
Prompt Variables
Inputs the Evidence Ranking and Selection Prompt needs to work reliably. Wire these placeholders into your retrieval pipeline before calling the model.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The original user question or search intent that triggered retrieval | What is the efficacy of drug X compared to placebo for condition Y? | Must be non-empty string. Truncate to 2000 chars. Log original query for traceability. |
[RETRIEVED_PASSAGES] | Array of candidate passages from vector search, keyword search, or hybrid retrieval | [{"id":"doc1_p3","text":"In a double-blind trial...","source":"NEJM 2024","date":"2024-03-15"}] | Validate array length > 0. Each object must have id and text fields. Source and date are optional but recommended for recency-aware ranking. |
[RANKING_CRITERIA] | Ordered list of factors to weight when ranking evidence: relevance, authority, recency, directness |
| Must be explicit ordered list. Avoid vague criteria like 'quality'. Test that criteria produce different rankings than random ordering. |
[OUTPUT_SCHEMA] | Expected JSON structure for ranked results including rank, passage_id, relevance_score, and rationale | {"rank":1,"passage_id":"doc1_p3","relevance_score":0.92,"rationale":"Directly addresses efficacy with RCT data","selected":true} | Validate schema before prompting. Include required fields: rank, passage_id, relevance_score, rationale. Optional: selected flag for top-K cutoff. |
[TOP_K] | Number of top passages to select after ranking for inclusion in final context window | 5 | Must be positive integer. Validate TOP_K <= len([RETRIEVED_PASSAGES]). Test that model returns exactly TOP_K selected passages when passages exceed TOP_K. |
[CONTEXT_WINDOW_BUDGET] | Maximum token budget available for selected evidence in the downstream prompt | 4000 | Must be positive integer. Use tokenizer to verify selected passages fit within budget. Implement truncation fallback if model selection exceeds budget. |
[POSITION_BIAS_CONTROLS] | Instructions to mitigate position bias where earlier passages receive higher relevance scores regardless of content | Randomize passage order before ranking. Require comparative justification for top-ranked passage over lower-ranked alternatives. | Validate that shuffling passage order produces consistent top-K selections within 80% overlap. Flag if first-passage selection rate exceeds 40%. |
[RECENCY_THRESHOLD] | Domain-specific recency cutoff where older sources are deprioritized or flagged | 2022-01-01 for medical claims; null for historical claims | Allow null for domains where recency is irrelevant. When set, validate that passages before threshold receive explicit recency penalty in rationale. Test with deliberately stale passages. |
Common Failure Modes
Evidence ranking prompts fail in predictable ways under production load. These are the most common failure modes, why they happen, and the specific guardrails to add before shipping.
Position Bias Skews Top Ranks
What to watch: Models overweight the first or last passages in the context window, ranking them higher regardless of relevance. This is especially severe when passages are long or the evidence list exceeds 10 items. Guardrail: Randomize passage order before ranking, run multiple ranking passes with shuffled order, and average the scores. Log rank variance per passage to detect position-dependent scoring.
Recency Bias Overrides Relevance
What to watch: When passages contain dates or timestamps, the model may rank newer content higher even when older passages are more relevant to the claim. This breaks verification for historical claims or when source recency is not the primary signal. Guardrail: Strip or normalize dates before ranking when recency is not a ranking criterion. Add explicit recency-weighting instructions only when timeliness matters, and test with date-inverted evidence sets.
Plausible-Sounding Passages Outrank Authoritative Ones
What to watch: Models confuse fluency and internal coherence with evidentiary weight. A well-written but irrelevant passage can outrank a terse, authoritative source. This is common with LLM-generated or marketing content in the evidence pool. Guardrail: Include source authority metadata in the ranking prompt and instruct the model to weigh authority over prose quality. Validate rankings against a golden set where authoritative-but-ugly passages should win.
Ranking Collapses with Near-Duplicate Passages
What to watch: When multiple retrieved passages are semantically similar, the model may assign identical or near-identical scores, losing discrimination. This produces useless flat rankings where no clear winner emerges. Guardrail: Pre-deduplicate passages with a similarity threshold before ranking. When near-duplicates remain, instruct the model to break ties using specificity, source authority, or quote precision. Log tie-rate as a ranking quality metric.
Selection Rationale Is Hallucinated
What to watch: The model generates plausible-sounding reasons for selecting a passage that do not match the passage content. It may claim a passage contains a specific fact when it does not, making the rationale misleading for downstream verification. Guardrail: Require the rationale to include a direct quote from the selected passage. Validate that quoted spans exist in the source text using string-matching or embedding comparison. Flag rationales without verifiable quotes for human review.
Empty or Irrelevant Evidence Sets Produce Confident Rankings
What to watch: When retrieval returns zero results or only tangentially related passages, the model may still produce ranked output with high confidence scores rather than signaling insufficient evidence. This silently corrupts downstream verification. Guardrail: Add a pre-ranking gate that checks if any passage meets a minimum relevance threshold. If not, short-circuit ranking and return an explicit 'insufficient evidence' signal. Test with empty and fully irrelevant retrieval sets.
Evaluation Rubric
Use this rubric to test the Evidence Ranking and Selection Prompt before shipping. Each criterion targets a known failure mode in relevance ranking, including position bias, recency bias, and hallucinated rationale.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Position Bias Resistance | Top-ranked evidence is selected by semantic relevance, not by its index in the input list. The most relevant passage wins even when placed last. | The first or last passage in the input list is consistently ranked highest regardless of content. The rationale references position rather than content. | Run 10 test cases with the same evidence set in reversed order. Pass if the top-3 ranking correlation between runs is >0.8. |
Recency Bias Resistance | Publication date is considered only when [DOMAIN] requires timeliness. Older authoritative evidence is not penalized for age alone. | Newer passages are consistently preferred even when older passages are more relevant or authoritative. Rationale cites recency as a primary factor for evergreen topics. | Test with a mix of old-authoritative and new-irrelevant passages on a historical topic. Pass if old-authoritative passages rank above new-irrelevant ones. |
Relevance Rationale Accuracy | Every ranking rationale references specific content from the passage that matches the [CLAIM]. No hallucinated or vague justifications. | Rationale contains phrases like 'this passage is relevant because it discusses the topic' without quoting or referencing specific passage content. | Spot-check 20 rationales against source passages. Pass if >90% contain at least one verifiable content reference from the passage. |
Confidence Calibration | Confidence scores correlate with evidence strength. High-confidence selections have direct, unambiguous support. Low-confidence selections are hedged. | All passages receive high confidence scores regardless of relevance. Confidence scores are uniformly 0.9+ even for tangentially related passages. | Compare confidence scores against human relevance judgments on 50 passage-claim pairs. Pass if Spearman correlation is >0.6. |
Null Evidence Handling | When no passage is sufficiently relevant, the output explicitly states 'no sufficient evidence found' rather than ranking irrelevant passages as top results. | Irrelevant passages are ranked and assigned moderate confidence scores instead of returning a null or insufficient-evidence result. | Test with 5 claims where all provided passages are off-topic. Pass if all 5 return explicit insufficient-evidence signals. |
Output Schema Compliance | Output matches the [OUTPUT_SCHEMA] exactly. All required fields are present, types are correct, and arrays are properly ordered. | Missing fields, extra fields, wrong types, or malformed JSON that fails schema validation. | Validate output against [OUTPUT_SCHEMA] using a JSON schema validator. Pass if 100% of test outputs pass validation on first attempt. |
Selection Count Adherence | The number of ranked passages returned matches [TOP_K] or fewer when insufficient evidence exists. No arbitrary padding with irrelevant passages. | Output returns exactly [TOP_K] passages even when fewer than [TOP_K] are relevant. Irrelevant passages are included to meet the count. | Test with evidence sets containing only 1 relevant passage and [TOP_K]=5. Pass if output returns 1 passage with appropriate confidence, not 5. |
Source Identifier Preservation | Every ranked passage retains its original [SOURCE_ID] exactly as provided. No truncation, modification, or hallucination of identifiers. | Source identifiers are truncated, renumbered, or hallucinated. Identifiers in output do not match any input [SOURCE_ID]. | Cross-reference all output [SOURCE_ID] values against input identifiers. Pass if 100% match exactly. |
Implementation Harness Notes
How to wire the Evidence Ranking and Selection Prompt into a production RAG pipeline with validation, retries, and bias mitigation.
The Evidence Ranking and Selection Prompt is designed to sit between your retrieval step and your answer generation step in a RAG pipeline. It receives a set of candidate passages and a user query, then returns a relevance-ranked list with explicit selection rationale. This is not a standalone prompt—it is a middleware component that must be integrated into a broader workflow. The primary integration points are: (1) a retrieval system that produces more passages than your context window can hold, (2) a ranking harness that calls this prompt and parses its structured output, and (3) a downstream generator that consumes only the top-N ranked passages. The harness must handle validation of the ranked output, retry logic for malformed responses, and mitigation of known ranking biases such as position bias (favoring first-retrieved passages) and recency bias (favoring passages with recent dates regardless of relevance).
To wire this into an application, build a ranking service that accepts a query string and a candidates array of passage objects (each with id, text, source, and optional date fields). The service should randomize the input order of candidates before sending them to the model to reduce position bias—do not pass passages in retrieval-score order. Call the prompt with a structured output schema requiring a ranked list of passage IDs with relevance scores and a one-sentence rationale per passage. Parse the response with a JSON schema validator. If validation fails, retry once with the error message appended to the prompt. If the second attempt fails, log the failure and fall back to the original retrieval order as a degraded ranking. For high-stakes verification workflows, route outputs with low confidence scores or conflicting rationales to a human review queue before they reach the answer generator.
Model choice matters here. Ranking tasks benefit from models with strong comparative reasoning. Use a capable instruction-following model (such as Claude 3.5 Sonnet or GPT-4o) rather than a lightweight model. Set temperature=0 for deterministic rankings. If your candidate set is large (more than 20 passages), consider a two-stage approach: first use a fast embedding-similarity filter to reduce candidates to a manageable top-K, then apply this prompt for fine-grained ranking. Log every ranking output with the input candidates, the model's ranked order, and the downstream usage (which passages were actually fed to the generator). This trace data is essential for debugging hallucination incidents—you can determine whether the generator hallucinated despite having good evidence ranked highly, or whether the ranker failed to surface the right passage.
Bias testing should be part of your harness, not an afterthought. Periodically run eval sets where you deliberately place the most relevant passage at the beginning, middle, and end of the candidate list to measure position bias. Similarly, test with passages that have varying publication dates to detect recency bias. If you observe systematic bias toward certain positions or dates, add explicit instructions to the prompt template to counteract it (e.g., 'Evaluate each passage independently of its position in the list' or 'Do not prefer recent passages unless recency is relevant to the query'). Store these eval results alongside your prompt version so you can detect regressions when you update the prompt or switch models.
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\nStart with the base prompt and a small set of 5-10 retrieved passages. Use a lightweight model call without strict output validation. Focus on whether the ranking order passes a manual spot check before investing in schema enforcement.\n\nReplace the [OUTPUT_SCHEMA] placeholder with a simple JSON array of ranked objects containing only `rank`, `passage_id`, and `relevance_score`. Skip rationale fields initially.\n\n### Watch for\n- Position bias: the model may rank the first passage highest regardless of content\n- Recency bias: passages at the end of the context window may be over-weighted\n- Missing tie-breaking logic when multiple passages are equally relevant\n- The model inventing passage IDs that don't exist in your input set

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