This prompt is designed for RAG system builders who need a reliable, auditable bridge between retrieval and answer synthesis. Its primary job is to transform a raw, unordered set of retrieved passages into a ranked list, where each entry is paired with a pre-formatted, machine-readable citation metadata block. This is not a general-purpose ranking prompt; it is specifically for pipelines where downstream components require structured source attribution—including title, date, section, and a unique identifier—to generate cited answers or maintain audit logs. The ideal user is an AI engineer or backend developer integrating this step into a production application, where the output must be deterministic enough to be parsed by code and informative enough to be logged for debugging and compliance.
Prompt
Evidence Ranking with Citation Metadata Prompt

When to Use This Prompt
Defines the ideal insertion point, prerequisites, and boundaries for the Evidence Ranking with Citation Metadata prompt in a production RAG pipeline.
You should use this prompt when you already have a set of retrieved passages and their associated metadata from a search or vector database step. The prompt assumes the retrieval quality is a given; it does not re-execute queries, expand search terms, or fetch additional documents. It is most effective when the downstream answer generation prompt has a strict contract requiring pre-formatted citations, or when you need to log exactly which evidence was selected and why before an answer is generated. A concrete implementation would place this prompt after a retrieval and filtering step but before the final LLM call that synthesizes an answer. For example, a support copilot might retrieve 20 chunks from a knowledge base, use this prompt to rank the top 5 and attach citation JSON, and then inject that ranked JSON directly into the synthesis prompt's [CONTEXT] variable.
Do not use this prompt as a substitute for retrieval, deduplication, or answer generation. It will not correct for poor initial retrieval; if the input passages are irrelevant, the output will be a well-formatted list of irrelevant passages. It is also not designed for conversational state management or multi-turn context tracking—use a dedicated conversational RAG ranking prompt for those scenarios. In high-stakes domains like healthcare or legal, the metadata formatting is necessary but not sufficient; you must still implement human review and source-grounding checks on the final synthesized answer. The next step after reading this section should be to review the prompt template and its required input variables to ensure your retrieval pipeline can supply the necessary metadata fields.
Use Case Fit
Where the Evidence Ranking with Citation Metadata Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your RAG pipeline before wiring it into production.
Good Fit: Citation-Ready Answer Pipelines
Use when: Your downstream synthesis prompt or UI requires structured citation metadata (source title, date, section, unique ID) for every piece of evidence. Guardrail: Validate that the output JSON contains all required metadata fields before passing to the answer generation step.
Good Fit: Multi-Source Knowledge Bases
Use when: Retrieved passages come from heterogeneous sources (PDFs, web pages, internal docs) and you need consistent, machine-readable attribution across all of them. Guardrail: Normalize source identifiers upstream so the prompt receives clean, distinguishable source labels rather than ambiguous filenames.
Bad Fit: Latency-Sensitive Real-Time Chat
Avoid when: You need sub-second end-to-end response times and the ranking step adds unacceptable latency. This prompt trades speed for structured metadata completeness. Guardrail: Benchmark the ranking step in isolation. If it exceeds your latency budget, use a simpler relevance-only ranking prompt without metadata extraction.
Bad Fit: Single-Source or Known-Origin Retrieval
Avoid when: All passages come from one document with no ambiguity about provenance. The metadata extraction overhead adds complexity without value. Guardrail: Check whether your downstream system actually consumes citation metadata. If not, use a lighter passage ranking prompt.
Required Input: Clean Source Metadata
Risk: The prompt cannot fabricate accurate source titles, dates, or IDs from raw text chunks. Garbage metadata in produces garbage citations out. Guardrail: Ensure your retrieval pipeline attaches source metadata to each passage before it reaches this prompt. Validate metadata completeness at ingestion, not at ranking time.
Operational Risk: Metadata Format Drift
Risk: Source metadata schemas change over time (new fields, renamed keys, missing dates), causing the prompt to produce inconsistent or empty citation blocks. Guardrail: Add a schema validation step after ranking that checks for required fields and logs warnings when metadata is incomplete. Trigger a retry or fallback to a simpler ranking prompt when validation fails.
Copy-Ready Prompt Template
A production-ready prompt template for ranking retrieved passages with structured citation metadata, ready for copy-paste and variable substitution.
This section provides a complete, copy-ready prompt template for evidence ranking with citation metadata. The template is designed to be pasted directly into your system prompt or user message, with square-bracket placeholders that you replace with your actual data before sending to the model. It produces a ranked list of passages, each accompanied by pre-formatted citation metadata including source title, date, section identifier, and a unique reference ID. This structured output is designed for direct consumption by downstream answer synthesis prompts that need to generate inline citations or footnotes without additional metadata extraction steps.
codeYou are an evidence ranking specialist. Your task is to rank the provided passages by their relevance and credibility for answering the user's question, and to format each passage with complete citation metadata. ## INPUT **User Question:** [USER_QUESTION] **Retrieved Passages:** [RETRIEVED_PASSAGES] **Source Metadata:** [SOURCE_METADATA] ## CONSTRAINTS [CONSTRAINTS] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "ranked_passages": [ { "rank": 1, "passage_id": "string", "passage_text": "string", "relevance_score": 0.0, "relevance_justification": "string", "citation_metadata": { "source_title": "string", "source_date": "string", "source_section": "string", "source_id": "string", "page_or_chapter": "string" }, "exclusion_reason": null } ], "excluded_passages": [ { "passage_id": "string", "exclusion_reason": "string" } ], "ranking_summary": "string" } ## INSTRUCTIONS 1. Evaluate each passage for relevance to the user's question, factual density, and source credibility. 2. Assign a relevance score from 0.0 (completely irrelevant) to 1.0 (perfectly relevant). 3. Rank passages in descending order of relevance. 4. For each ranked passage, extract and format complete citation metadata from the provided source metadata. 5. If a passage is excluded, provide a clear exclusion reason (e.g., "duplicate content", "irrelevant topic", "outdated information", "insufficient factual content"). 6. If multiple passages are equally relevant, prioritize the one with higher source credibility or more recent publication date. 7. Include a brief ranking summary explaining your overall approach and any notable decisions. ## EXAMPLES [EXAMPLES] ## RISK LEVEL [RISK_LEVEL]
Adaptation guidance: Replace [USER_QUESTION] with the actual query string. [RETRIEVED_PASSAGES] should contain the full text of each retrieved chunk with a unique passage_id for traceability. [SOURCE_METADATA] must include a mapping from passage IDs to their source attributes—title, publication date, section heading, and a durable identifier like a document UUID or URL. The [CONSTRAINTS] placeholder lets you inject domain-specific rules such as "exclude passages older than 2 years" or "require at least 3 unique sources." Use [EXAMPLES] to provide one or two few-shot demonstrations of correct ranking and metadata formatting for your domain. Set [RISK_LEVEL] to low, medium, or high to control the model's conservatism—high-risk domains should trigger stricter exclusion criteria and lower confidence thresholds.
Before deploying this prompt, validate that your source metadata is complete and consistent. Missing metadata fields will cause downstream citation failures. Test the prompt with a golden dataset of known query-passage pairs where you have ground-truth relevance judgments and expected citation formats. Compare the model's output against your expected rankings using nDCG or precision-at-k metrics, and verify that every ranked passage includes all required citation fields with non-null values. For high-stakes applications, add a post-processing validation step that rejects outputs with incomplete metadata and triggers a retry with a more explicit instruction about required fields.
Prompt Variables
Inputs the Evidence Ranking with Citation Metadata Prompt needs to work reliably. Validate these before sending the prompt to the model.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[QUERY] | The user question or search intent that evidence must be ranked against. | What are the side effects of drug X based on recent clinical trials? | Must be non-empty string. Check for minimum 10 characters. Reject queries that are only stop words or punctuation. |
[RETRIEVED_PASSAGES] | Array of candidate passages from the retrieval step, each with text and source metadata. | [{"passage_id": "doc_12_chunk_4", "text": "...", "source_title": "...", "source_date": "...", "source_section": "..."}] | Must be valid JSON array with 1-50 objects. Each object requires passage_id, text, source_title, and source_date. Reject if text field is empty or null. |
[CITATION_FORMAT] | The required citation metadata schema for each ranked passage in the output. | {"fields": ["passage_id", "source_title", "source_date", "source_section", "relevance_score", "rank_position"]} | Must be valid JSON schema definition. Check that required fields include at minimum passage_id, source_title, and relevance_score. Reject schemas requesting fields not present in input passages. |
[MAX_PASSAGES] | Maximum number of ranked passages to return in the output. | 10 | Must be positive integer between 1 and 50. Default to 10 if not provided. Warn if value exceeds number of input passages. |
[RANKING_CRITERIA] | Ordered list of criteria for ranking passages, from most to least important. | ["relevance_to_query", "source_credibility", "information_density", "recency"] | Must be non-empty array of strings from allowed set: relevance_to_query, source_credibility, information_density, recency, source_diversity, fact_density. Reject unknown criteria values. |
[MIN_RELEVANCE_THRESHOLD] | Minimum relevance score a passage must meet to be included in ranked output. | 0.3 | Must be float between 0.0 and 1.0. Passages scoring below this threshold are excluded from output. Set to null to include all passages. Validate that threshold is not above 0.9 without explicit override flag. |
[SOURCE_AUTHORITY_MAP] | Optional mapping of source titles to authority weights for credibility scoring. | {"PubMed": 0.95, "arXiv": 0.7, "Blog": 0.3} | If provided, must be valid JSON object with string keys and float values between 0.0 and 1.0. Sources not in map receive default weight of 0.5. Null allowed if credibility scoring relies only on metadata. |
Implementation Harness Notes
How to wire the Evidence Ranking with Citation Metadata prompt into a production RAG pipeline with validation, retries, and logging.
This prompt is designed to be called after retrieval and before answer synthesis in a RAG pipeline. It expects a list of candidate passages and a user query, and it returns a ranked list with structured citation metadata. The output is machine-readable JSON, which means you should validate it before passing it to the next stage. A common integration pattern is: retrieval service → this ranking prompt → top-K selection → answer synthesis prompt. The ranking prompt can also serve as a logging checkpoint for observability into why certain passages were prioritized or dropped.
Wire the prompt into your application with a thin service wrapper that handles the API call, response parsing, and validation. Use a JSON schema validator to confirm that every ranked passage includes the required fields: rank, passage_id, relevance_score, citation_metadata (with source_title, date, section, and unique_id), and ranking_justification. If validation fails, implement a single retry with the error message injected into the prompt as additional context. For high-stakes domains, add a human review step when the top-ranked passage has a relevance score below a configurable threshold (e.g., 0.6) or when the ranking justification indicates source conflict. Log the full ranked list, the selected top-K, and any validation failures for downstream debugging and eval comparison.
Model choice matters here. Use a model with strong instruction-following and JSON output capabilities, such as GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro. Avoid smaller or older models that may drop required metadata fields or produce inconsistent ranking justifications. If you are using a local or open-weight model, run a calibration eval comparing its relevance scores against a human-labeled golden set before deploying. Do not pass the raw ranked output directly to users; it is an intermediate representation meant for programmatic consumption. The next step in your pipeline should select the top-K passages (where K is determined by your context window budget) and feed them into your answer synthesis prompt along with the pre-formatted citation metadata.
Common Failure Modes
Evidence ranking prompts fail in predictable ways. Here are the most common failure modes, why they happen, and how to guard against them before they reach users.
Metadata Hallucination in Citation Fields
What to watch: The model fabricates source titles, dates, section names, or identifiers that look plausible but don't exist in the retrieved passages. This happens most often when the prompt asks for metadata fields the context doesn't contain. Guardrail: Validate every citation metadata field against the source document before surfacing to users. Add a post-processing check that rejects citations with identifiers not present in the original retrieval set. Include explicit instructions to output null or "unavailable" for missing metadata rather than guessing.
Relevance-Confidence Mismatch
What to watch: The model assigns high relevance scores to passages that are topically related but don't actually answer the query, or low scores to passages that contain the answer but use different terminology. This creates a ranking that looks plausible but fails downstream synthesis. Guardrail: Include few-shot examples that distinguish topical similarity from answer-bearing relevance. Add an eval step that checks whether top-ranked passages contain the entities, values, or relationships the query asks about. Calibrate scores against human relevance judgments on a golden dataset.
Position Bias Toward Early Passages
What to watch: The model over-weights passages appearing first in the input list, assigning them higher relevance regardless of content. This is especially dangerous when retrieval order is arbitrary or when the best evidence appears later in the context window. Guardrail: Randomize passage order before sending to the ranking prompt, or run the prompt multiple times with different orderings and average the scores. Include explicit instructions to evaluate each passage independently of its list position.
Source Authority Override of Content Relevance
What to watch: The model ranks passages from authoritative-looking sources (official domains, known publications) higher than passages with better answer coverage from less recognizable sources. This causes the system to miss relevant evidence buried in internal docs or niche sources. Guardrail: Separate credibility scoring from relevance scoring in the prompt. Require the model to justify relevance based on content match to the query, not source reputation. Add a diversity check that flags when all top-ranked passages come from a single source or domain.
Citation Format Drift Across Batches
What to watch: The model produces citation metadata in inconsistent formats across different queries—sometimes JSON, sometimes markdown links, sometimes inline text—breaking downstream citation rendering and audit trails. This is common when the output schema is described in prose rather than enforced structurally. Guardrail: Use a strict JSON output contract with explicit field types and enum constraints. Add a schema validator in the pipeline that rejects malformed outputs and triggers a retry with the error message. Include format-compliance examples in the few-shot demonstrations.
Silent Passage Omission Without Exclusion Reasons
What to watch: The model drops relevant passages from the ranked output without documenting why, making it impossible to audit whether the omission was intentional (low relevance) or accidental (context window truncation, attention failure). This erodes trust in the ranking pipeline. Guardrail: Require the output to include an explicit exclusion list with reasons for any passage from the input set that doesn't appear in the ranked output. Add an eval check that verifies every input passage is accounted for in either the ranked list or the exclusion list.
Evaluation Rubric
How to test output quality before shipping. Run these checks on a golden dataset of at least 50 queries with known relevant passages.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Ranking Relevance | Top-3 passages match human-preferred evidence set for 90% of queries | Top-ranked passage is irrelevant to query intent in >10% of cases | Compare ranked list against golden relevance labels using NDCG@3 |
Citation Metadata Completeness | 100% of ranked passages include [SOURCE_TITLE], [SOURCE_DATE], and [CITATION_ID] | Any output passage missing a required metadata field | Schema validation: assert all required keys present and non-null for every passage object |
Metadata Format Compliance | [CITATION_ID] matches pattern | [CITATION_ID] is free-text or [SOURCE_DATE] is unparseable | Regex validation on each passage's metadata fields; fail if any violation detected |
Score Calibration | Relevance scores for top-5 passages correlate with human judgments at r >= 0.7 | High-scored passages are consistently rated irrelevant by human evaluators | Pearson correlation between model scores and human relevance ratings on 50-query sample |
Output Structure Validity | 100% of outputs parse as valid JSON matching the expected schema | JSON parse error or missing required top-level key | Automated JSON schema validation in CI; retry prompt once on failure, then flag |
Exclusion Justification | Every excluded passage from top-K has a non-empty | Excluded passages lack explanation or reason is generic placeholder text | Assert |
Source Diversity | At least 2 unique [SOURCE_TITLE] values appear in top-5 when retrieval set contains >=3 sources | Top-5 passages all from single source despite available alternatives | Count distinct [SOURCE_TITLE] in top-5; flag if diversity below threshold when retrieval set supports it |
Confidence Threshold Adherence | Passages with confidence below 0.3 are placed in | Low-confidence passage appears in ranked list | Assert all entries in |
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 simple JSON schema constraint and a small set of test passages. Focus on getting the ranking logic and metadata extraction correct before adding production harnesses. Remove strict token budgets and allow the model to explain its reasoning inline.
codeRank these passages by relevance to [QUERY]. For each passage, extract: title, date, section, and a unique identifier. Return JSON with ranked passages and a brief justification for each rank. Passages: [PASSAGES]
Watch for
- Metadata hallucination when source fields are missing from the input passages
- Inconsistent date formats across different source types
- Rankings that favor longer passages over more relevant shorter ones

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