Inferensys

Prompt

Evidence Ranking with Source Metadata Prompt Template

A practical prompt playbook for ranking evidence passages using both content relevance and source metadata signals in production RAG and search pipelines.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user profile, required inputs, and explicit boundaries for the evidence ranking with source metadata prompt.

This prompt is designed for RAG pipeline engineers and search architects who have access to rich document metadata alongside retrieved passages. When your retrieval system returns passages with associated metadata such as publication dates, author credentials, document types, or domain authority scores, this prompt combines those trustworthiness signals with content relevance to produce a weighted, explainable ranking. Use this prompt when you need to prevent low-authority or outdated sources from outranking more credible evidence, and when downstream answer generation or citation selection depends on a calibrated evidence ordering rather than raw retrieval scores.

This prompt assumes you have already retrieved a candidate set of passages and their metadata. It does not perform retrieval itself, nor does it verify factual accuracy of passage content. It is a ranking and prioritization step that sits between retrieval and answer synthesis. You should provide the prompt with a query or claim, a list of passages with unique IDs, and structured metadata fields for each passage. The prompt expects metadata such as publication_date, author_credentials, document_type, domain_authority_score, and citation_count. If your retrieval pipeline does not produce these fields, you must enrich passages with metadata before invoking this prompt. The output is a ranked list with scores, tier assignments, and human-readable rationale for each ranking decision.

Do not use this prompt when your retrieval set lacks metadata, when passages are already pre-filtered by authority, or when you need strict factual verification rather than trust-weighted ranking. This prompt is also inappropriate for real-time streaming ranking where latency constraints preclude structured output generation. For high-stakes domains such as legal or clinical evidence ranking, always pair this prompt with human review of the ranked output before it feeds into answer generation. The ranking decisions are explainable but not infallible—metadata signals can be gamed, and authority is not a guarantee of accuracy. Wire this prompt into a pipeline that logs ranking decisions, tracks ranking stability across similar queries, and gates downstream synthesis on minimum confidence thresholds.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Evidence Ranking with Source Metadata prompt delivers value and where it falls short. Use these cards to decide if this template fits your production context before you invest in wiring it up.

01

Strong Fit: Curated Document Collections

Use when: your retrieval corpus has rich, structured metadata (publication date, author authority, document type, domain signals) that your team trusts. Why it works: the prompt can weight relevance and trustworthiness together, producing rankings that reflect both content match and source quality. Guardrail: validate metadata completeness before ranking—missing fields silently degrade weighting logic.

02

Poor Fit: Ad-Hoc Web Search Results

Avoid when: evidence comes from raw web search snippets with no consistent metadata schema. Risk: the prompt will hallucinate authority signals or apply uneven weighting based on whatever metadata happens to be present, producing rankings that look structured but are unreliable. Guardrail: use a simpler relevance-only ranking prompt for uncurated sources, or add a metadata extraction step before ranking.

03

Required Inputs: Metadata Schema Contract

Risk: the prompt assumes each passage carries fields like publication_date, author_authority_score, document_type, and domain_trust_tier. If your retrieval pipeline doesn't supply these, the prompt will either fail silently or invent values. Guardrail: define a strict metadata schema upstream, validate that every passage includes required fields, and configure the prompt's weighting parameters to match the fields you actually have.

04

Operational Risk: Stale Authority Signals

What to watch: author authority scores and domain trust tiers that were computed months ago may no longer reflect reality. Risk: the prompt will overweight outdated authority signals, suppressing newer but un-scored sources. Guardrail: attach a metadata_freshness_date to each passage and configure the prompt to penalize authority signals older than your freshness threshold, or re-score authority periodically.

05

Operational Risk: Weight Tuning Drift

What to watch: the prompt's balance between content relevance and source trustworthiness is controlled by configurable weights. Risk: as your corpus or user queries shift, the original weights may over-prioritize authority at the expense of relevance (or vice versa). Guardrail: log ranking decisions with the weights used, run periodic eval suites that measure ranking quality against human judgments, and adjust weights when precision or recall degrades.

06

Boundary: When Metadata Conflicts with Content

What to watch: a high-authority source may contain outdated or inaccurate content, while a lower-authority source may have the correct answer. Risk: the prompt's weighting logic may rank the wrong passage higher because authority dominates. Guardrail: include a conflict-resolution instruction that requires the prompt to flag cases where content evidence contradicts metadata signals, and escalate those cases for human review or a secondary content-only ranking pass.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt for ranking evidence passages by relevance and source trustworthiness using metadata signals.

This prompt template is designed to be pasted directly into your system instructions for an evidence ranking step. It instructs the model to evaluate a set of retrieved passages against a user query, weighing both content relevance and source metadata—such as publication date, author authority, document type, and domain—to produce a weighted, explainable ranking. The goal is to move beyond simple vector similarity by explicitly incorporating trustworthiness signals that downstream answer generation and citation selection can depend on.

text
You are an evidence ranking specialist. Your task is to rank a set of retrieved passages for a given query. You must balance content relevance with source trustworthiness using the provided metadata.

## INPUT
- Query: [QUERY]
- Passages: [PASSAGES_JSON]
  Each passage object includes:
  - id: string
  - text: string
  - metadata:
    - publication_date: ISO 8601 string or null
    - author_authority: "high" | "medium" | "low" | "unknown"
    - document_type: string (e.g., "research_paper", "technical_doc", "blog_post", "internal_wiki", "news_article")
    - domain: string (e.g., "medical", "legal", "engineering", "general")
- Ranking Criteria: [RANKING_CRITERIA]
  A list of weighted dimensions, e.g., [{"dimension": "relevance", "weight": 0.5}, {"dimension": "recency", "weight": 0.2}, {"dimension": "authority", "weight": 0.2}, {"dimension": "specificity", "weight": 0.1}]
- Output Schema: [OUTPUT_SCHEMA]
  Define the expected JSON structure for the ranked list.
- Constraints: [CONSTRAINTS]
  e.g., "Return exactly the top 5 passages.", "Exclude any passage with author_authority 'low'."

## INSTRUCTIONS
1. For each passage, assess its relevance to the query based on semantic overlap and specificity.
2. Adjust the relevance score using the metadata:
   - **Recency**: Prefer more recent publication dates for time-sensitive queries. Apply a decay factor for older documents.
   - **Authority**: Boost passages from high-authority authors or reputable document types (e.g., research papers over blog posts). Penalize low or unknown authority.
   - **Domain**: Increase weight if the document's domain matches the query's implied domain.
3. Calculate a final weighted score for each passage based on the provided [RANKING_CRITERIA].
4. Sort passages by their final score in descending order.
5. For each ranked passage, provide a concise rationale explaining how its content and metadata contributed to its score.
6. Output the result strictly according to the [OUTPUT_SCHEMA].

## OUTPUT
Return a valid JSON object with a "ranked_passages" array. Do not include any text outside the JSON.

To adapt this template, replace the square-bracket placeholders with your actual data before sending it to the model. The [PASSAGES_JSON] should be a serialized JSON array of your retrieved documents with their metadata. The [RANKING_CRITERIA] array lets you tune the balance between relevance and trustworthiness for your specific use case—a legal research tool might weight authority at 0.4, while a news summarizer might push recency to 0.5. The [OUTPUT_SCHEMA] placeholder should be replaced with your exact expected JSON structure, including field names like rank, passage_id, final_score, and rationale. The [CONSTRAINTS] field is your lever for enforcing business rules like top-K limits or authority floors. After generating the ranking, always validate the output against your schema and run evaluation checks for common failure modes like position bias or authority overfitting before passing the ranked list to downstream answer generation.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder required by the Evidence Ranking with Source Metadata prompt. Wire these into your RAG pipeline or prompt assembly layer before calling the model. Validation notes describe how to catch missing or malformed values before they cause ranking failures.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or claim that evidence must support or refute

What is the efficacy of drug X for condition Y based on recent trials?

Must be non-empty string. Check length > 10 chars. Reject if only stopwords or punctuation.

[PASSAGES]

Array of retrieved evidence passages with associated metadata

[{"id":"p1","text":"...","source":"PubMed","date":"2024-03","authority":"high","doctype":"RCT"}]

Must be valid JSON array with at least 1 passage. Each passage requires id and text fields. Metadata fields optional but ranking quality degrades without them.

[METADATA_SCHEMA]

Definition of available metadata fields and their types for the ranking model

{"fields":["source","date","authority","doctype","citation_count"]}

Must be valid JSON object with fields array. Each field should map to keys present in [PASSAGES] metadata. Warn if schema declares fields absent from passages.

[RANKING_CRITERIA]

Ordered list of criteria with weights for scoring evidence

["relevance:0.4","authority:0.25","recency:0.2","specificity:0.15"]

Weights must sum to 1.0 within 0.01 tolerance. Reject if criteria names don't match [METADATA_SCHEMA] fields or built-in dimensions like relevance and specificity.

[TEMPORAL_DECAY_CONFIG]

Configuration for how passage age affects ranking score

{"half_life_months":6,"floor_weight":0.3,"reference_date":"2025-01"}

half_life_months must be positive number. floor_weight must be between 0 and 1. reference_date must parse as ISO date. Null allowed if recency not in [RANKING_CRITERIA].

[OUTPUT_SCHEMA]

Expected JSON structure for ranked output

{"ranked_passages":[{"id":"string","score":"number","tier":"string","rationale":"string"}]}

Must be valid JSON Schema or example structure. Validate that output conforms before passing downstream. Include tier enum values if gating on tier.

[CONSTRAINTS]

Hard limits and behavioral rules for the ranking

{"max_passages":5,"min_score_threshold":0.3,"require_rationale":true,"conflict_flagging":true}

max_passages must be positive integer. min_score_threshold between 0 and 1. require_rationale is boolean. conflict_flagging enables contradiction detection output.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when ranking evidence with source metadata in production, and how to guard against each failure.

01

Metadata Overfitting

What to watch: The model overweights a single metadata signal (e.g., recency or author authority) and ignores content relevance, ranking a recent but irrelevant passage above an older, perfectly matching one. Guardrail: Add explicit ranking criteria weights in the prompt and validate with a golden set where content relevance should beat metadata signals.

02

Missing or Null Metadata Collapse

What to watch: When source metadata fields are empty, null, or malformed, the model either drops those passages entirely or assigns them arbitrary low scores, silently discarding valid evidence. Guardrail: Include a **Metadata Handling Rule:** in the prompt that instructs the model to treat missing metadata as neutral (not negative) and rank on content alone when metadata is absent.

03

Position Bias in Ranking Output

What to watch: The model favors passages appearing first in the input list regardless of their actual relevance, producing rankings that mirror input order rather than evidence strength. Guardrail: Randomize passage order before sending to the model and run a position-bias eval that checks whether ranking correlates with input position.

04

Authority Signal Amplification

What to watch: High-authority sources (e.g., official documentation, peer-reviewed journals) dominate rankings even when their content is tangential, while lower-authority sources with directly relevant content are buried. Guardrail: Add a **Relevance-First Rule:** requiring that content relevance gates authority weighting—authority should only break ties among equally relevant passages.

05

Temporal Decay Misapplication

What to watch: Recency weighting penalizes foundational or evergreen content that remains accurate, or fails to decay fast enough for rapidly changing domains, producing rankings that are either stale or unjustifiably biased toward new content. Guardrail: Make temporal decay domain-aware by including a **Recency Policy:** that specifies which query types require freshness and which accept timeless sources.

06

Score Calibration Drift Across Batches

What to watch: The model assigns inconsistent relevance scores across different retrieval batches, making downstream gating thresholds unreliable—a score of 0.7 in one batch may not mean the same as 0.7 in another. Guardrail: Include a calibration anchor in the prompt (e.g., a fixed reference passage with a known score) and run score-distribution checks across batches to detect drift.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test ranking quality before shipping to production. Run these checks on a golden dataset of 50-100 queries with known-good passage rankings.

CriterionPass StandardFailure SignalTest Method

Ranking Stability

Top-3 passages remain identical across 5 repeated runs with temperature=0

Top-3 order changes or passages drop out between runs

Run ranking 5x per query; measure Jaccard similarity of top-3 set and Kendall tau on top-5 order

Position Bias Resistance

Passage position in input list does not predict rank; correlation coefficient < 0.2

First or last passages in input consistently receive higher ranks regardless of content

Shuffle input passage order 10x per query; compute Spearman correlation between input position and output rank

Length Bias Check

Passage character length does not predict relevance score; correlation coefficient < 0.3

Longer passages systematically outrank shorter but equally relevant passages

Compute Pearson correlation between passage length and assigned rank across golden dataset; flag queries where length explains >30% of rank variance

Authority Calibration

High-authority sources (per [AUTHORITY_SIGNALS]) rank above low-authority sources for same relevance tier

Low-authority source outranks high-authority source when both passages are equally relevant to query

Create 20 query pairs where relevance is matched but authority differs; measure whether authority direction predicts rank direction in >=85% of pairs

Temporal Decay Correctness

For time-sensitive queries, newer passages rank above older passages with equal relevance

Outdated passage outranks recent passage for query explicitly requiring current information

Construct 15 time-sensitive queries with matched-relevance passage pairs at different dates; verify recency wins in >=90% of pairs

Relevance Score Discrimination

Score gap between relevant and irrelevant passages is >=0.3 on normalized scale

Relevant and irrelevant passages cluster within 0.1 score range, making threshold gating unreliable

Compute mean score difference between human-labeled relevant and irrelevant passages; measure overlap in score distributions

Metadata Signal Utilization

Ranking changes when [SOURCE_TYPE], [PUBLICATION_DATE], or [AUTHORITY_TIER] metadata is modified for same content

Identical rankings produced regardless of metadata differences that should affect trust weighting

Run ranking with metadata intact vs metadata stripped; measure rank correlation delta; expect meaningful reordering for >=60% of queries

Edge Case: Empty Retrieval Set

System returns empty ranking or explicit insufficient-evidence signal without error

System hallucinates rankings, returns error, or produces non-empty output from empty input

Submit query with zero passages; verify output is empty list or contains only an insufficiency flag with no fabricated entries

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Evidence Ranking with Source Metadata prompt into a production RAG pipeline with validation, retry, and observability.

This prompt is designed to sit between your retrieval step and your answer generation step in a RAG pipeline. It consumes a set of retrieved passages with their associated metadata and produces a ranked list. The implementation harness must treat this prompt as a deterministic component: same inputs should produce a stable ranking, and any deviation should be logged and flagged. The harness is responsible for assembling the [PASSAGES] array with consistent metadata fields, invoking the model, validating the output schema, and passing only the top-K ranked passages to the downstream answer generation prompt. Do not skip validation here—a malformed ranking silently degrades answer quality and citation accuracy downstream.

Start by defining a strict output contract. The prompt expects a JSON array of ranked passages, each with passage_id, rank, composite_score, and ranking_rationale. Your harness should validate this schema immediately after model response. Use a JSON Schema validator (e.g., ajv for Node.js, pydantic for Python) to check required fields, types, and value ranges. If validation fails, implement a retry loop with a maximum of two additional attempts, appending the validation error message to the prompt context so the model can self-correct. After three total failures, log the full input, output, and errors to your observability platform, then fall back to a simpler ranking heuristic (e.g., recency-only or vector similarity score) to keep the pipeline running. For high-stakes domains like legal or medical, route failed rankings to a human review queue instead of falling back to a heuristic.

Observability is non-negotiable. Log every ranking request with: a unique trace_id, the query, the number of input passages, the model used, the latency, the output ranking, and a hash of the ranked passage IDs. This lets you detect ranking drift when you change models or update the prompt. Add a lightweight eval check that compares the top-ranked passage against a baseline (e.g., the passage with the highest vector similarity score). If the top-ranked passage changes by more than a configurable threshold, emit a warning metric. For cost control, cache rankings for identical [QUERY] + [PASSAGES] combinations with a short TTL, but invalidate the cache when any passage metadata changes. Finally, wire the ranked output into your answer generation prompt by injecting only the top-K passages (where K is determined by your context budget) along with their composite_score and ranking_rationale, so the downstream model can weight evidence appropriately.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small retrieval set of 5-10 passages with known metadata. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with default temperature. Skip strict schema enforcement initially—accept markdown or bulleted rankings to validate ranking logic before hardening the output contract.

Replace [SOURCE_METADATA_SCHEMA] with a simple flat object: {"date": "YYYY-MM-DD", "authority": "high|medium|low", "type": "document_type"}. Set [WEIGHT_CONFIG] to equal weights (relevance=0.4, recency=0.3, authority=0.3) and tune from there.

Watch for

  • Recency bias drowning out highly relevant older sources
  • Authority signals that are too coarse to discriminate
  • Ranking ties where the model refuses to break them
  • Metadata fields that are present in some passages but missing in others causing inconsistent weighting
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.