Inferensys

Prompt

Recency-Aware Passage Ranking Prompt

A practical prompt playbook for using Recency-Aware Passage Ranking Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Learn when recency-aware reranking solves a real problem and when simpler ranking or full temporal filtering is a better fit.

This prompt is for RAG system builders and search ranking engineers who need to rerank retrieved passages by combining semantic relevance with temporal freshness. Use it when your retrieval pipeline returns passages with publication dates and you need an ordered evidence list that prioritizes recent, authoritative sources without discarding highly relevant older content. The ideal user is operating a production RAG system in a domain where information decays predictably—financial reports, news, regulatory filings, technical documentation, or market intelligence—and needs an auditable ranking step before answer generation or citation selection.

This prompt belongs in the reranking stage of a RAG pipeline, after initial retrieval and before answer generation or citation selection. It assumes you already have a set of candidate passages, each with a relevance score, publication date, and source identifier. The prompt produces a ranked list with per-passage recency justifications, making evidence selection auditable and debuggable. You should wire it as a post-retrieval processing step: your retriever returns N candidates, this prompt reranks them into a final ordered list, and your answer generation prompt receives the top K passages. The recency justifications double as debugging artifacts when stakeholders question why certain sources were prioritized.

Do not use this prompt when your domain has no meaningful temporal decay (classic literature, stable scientific facts, mathematical proofs), when your retrieval set lacks reliable publication dates, or when you need strict date-range filtering rather than weighted reranking. If your use case requires excluding all passages outside a fixed window, use a time-bounded evidence selection prompt instead. If you need to detect whether individual passages contain stale claims regardless of publication date, pair this with a stale evidence detection prompt. This prompt is also not a substitute for retrieval—it reranks what it receives and cannot recover passages that retrieval missed due to poor temporal filtering upstream.

Before deploying, calibrate the decay function against your domain's actual information half-life. A financial earnings use case might use a 90-day half-life, while a legal precedent use case might use years. Test with human-annotated preference pairs where annotators rank passage sets for time-sensitive queries, and measure whether the prompt's ranking correlates with human preferences. Common failure modes include over-penalizing evergreen content that happens to be old, under-penalizing recent but low-authority sources, and producing justifications that parrot the publication date without explaining why recency matters for the specific query. Start with a small eval set of 50-100 query-passage groups before scaling to production traffic.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if a recency-aware ranking approach is the right fit for your retrieval pipeline.

01

Good Fit: Time-Sensitive RAG Pipelines

Use when: your retrieval corpus contains documents with clear publication dates and query intent is sensitive to recency (news, financial reports, regulatory filings). Guardrail: define domain-specific freshness windows before deploying the prompt to prevent arbitrary recency bias.

02

Bad Fit: Static or Time-Agnostic Corpora

Avoid when: your knowledge base has no reliable publication dates, or query intent is purely historical or conceptual (e.g., 'explain Newton's laws'). Guardrail: route queries through a time-sensitivity classifier first and skip recency weighting for time-agnostic requests.

03

Required Inputs

What you need: a retrieval set with per-passage publication timestamps, a query string, and optionally a domain-specific freshness window (e.g., 24 hours for breaking news, 90 days for quarterly earnings). Guardrail: validate that timestamps are in a consistent format (ISO 8601) before passing them into the prompt.

04

Operational Risk: Recency Override of Relevance

What to watch: the prompt may boost a recent but tangentially relevant passage over an older, highly authoritative source. Guardrail: implement a combined score threshold that prevents recency from overriding relevance when the semantic relevance gap is too large.

05

Operational Risk: Missing or Malformed Dates

What to watch: passages without publication dates may be silently dropped or incorrectly penalized. Guardrail: add a pre-processing step that assigns a conservative default date or routes undated passages to a separate handling path with explicit logging.

06

Variant: Configurable Decay Functions

What to watch: a single decay function (e.g., exponential) may not fit all domains. Guardrail: expose the decay function and half-life as configurable parameters in your prompt template, and A/B test different functions against human-annotated preference pairs before locking in production settings.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for reranking retrieved passages by combining relevance with publication date proximity and domain-specific freshness windows.

This prompt template is designed to be dropped directly into your RAG pipeline's reranking stage. It instructs the model to evaluate each passage against both semantic relevance to the query and temporal freshness relative to the query's time sensitivity. The template uses square-bracket placeholders that you must replace with your actual data before sending to the model. Each placeholder is documented so you know exactly what shape of data to provide.

text
You are a recency-aware passage ranking system. Your job is to rerank a set of retrieved passages by combining relevance to the query with temporal freshness. You will receive a query, a set of passages with metadata, and domain-specific freshness rules. You must produce an ordered list of passages with per-passage justifications.

## INPUT

### Query
[QUERY]

### Query Temporal Sensitivity
Classification: [TEMPORAL_SENSITIVITY_CLASSIFICATION]
Recommended freshness window: [FRESHNESS_WINDOW]

### Domain Freshness Rules
[DOMAIN_FRESHNESS_RULES]

### Retrieved Passages
[RETRIEVED_PASSAGES]

Each passage includes:
- passage_id: unique identifier
- text: the passage content
- publication_date: ISO 8601 date or null if unknown
- source_authority_score: 0.0 to 1.0 indicating source trustworthiness
- initial_relevance_score: 0.0 to 1.0 from the retriever

## OUTPUT SCHEMA

Return a JSON object with this exact structure:
{
  "ranked_passages": [
    {
      "passage_id": "string",
      "combined_score": 0.0,
      "relevance_score": 0.0,
      "freshness_score": 0.0,
      "recency_justification": "string explaining why this passage is temporally appropriate or not",
      "rank": 1
    }
  ],
  "ranking_methodology": "brief explanation of how scores were combined",
  "excluded_passages": [
    {
      "passage_id": "string",
      "exclusion_reason": "string"
    }
  ]
}

## CONSTRAINTS

1. For queries classified as 'real-time' or 'recent', heavily penalize passages older than the freshness window.
2. For 'historical' queries, do not penalize older passages; prioritize relevance and authority.
3. For 'time-agnostic' queries, freshness should have minimal weight.
4. If a passage has a null publication_date, assign a freshness_score of 0.5 and note the uncertainty in the justification.
5. Exclude passages that are clearly stale according to the domain freshness rules and explain why.
6. The combined_score must reflect a weighted combination of relevance_score, freshness_score, and source_authority_score.
7. All scores must be between 0.0 and 1.0.
8. Rank 1 is the best passage.

## EXAMPLES

### Example 1: Real-Time Query
Query: "What is the current stock price of AAPL?"
Temporal Sensitivity: real-time
Freshness Window: last 24 hours

Passage A: publication_date=2024-01-15, relevance=0.9, text="AAPL closed at $185.50 on January 15"
Passage B: publication_date=2024-01-16, relevance=0.7, text="AAPL trading at $187.20 in pre-market"

Expected: Passage B ranks higher despite lower relevance because Passage A is outside the 24-hour window.

### Example 2: Historical Query
Query: "What caused the 2008 financial crisis?"
Temporal Sensitivity: historical
Freshness Window: any

Passage A: publication_date=2009-03-15, relevance=0.95
Passage B: publication_date=2023-06-01, relevance=0.85

Expected: Passage A may rank higher if it has stronger relevance and authority, despite being older.

## INSTRUCTIONS

1. Read the query and its temporal sensitivity classification.
2. For each passage, compute a freshness_score based on how well its publication_date aligns with the freshness window and domain rules.
3. Compute a combined_score using relevance_score, freshness_score, and source_authority_score.
4. Sort passages by combined_score descending.
5. Write a recency_justification for each passage.
6. Identify and list any excluded passages with reasons.
7. Return the output in the exact JSON schema specified.

To adapt this template for your system, replace each bracketed placeholder with real data. [QUERY] should contain the user's original question. [TEMPORAL_SENSITIVITY_CLASSIFICATION] should be one of 'real-time', 'recent', 'historical', or 'time-agnostic', ideally produced by an upstream classification prompt. [FRESHNESS_WINDOW] should be a human-readable time range like 'last 24 hours' or 'Q4 2024'. [DOMAIN_FRESHNESS_RULES] should encode your business logic about when information becomes stale—for example, 'financial price data expires after 24 hours; earnings reports expire after one quarter.' [RETRIEVED_PASSAGES] should be a JSON array of passage objects matching the schema described in the prompt. Before deploying, validate that your upstream retriever consistently provides publication_date and source_authority_score fields, or adjust the template to match your available metadata. Test the prompt against a golden dataset of query-passage pairs with known correct rankings to calibrate the scoring weights before production use.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Recency-Aware Passage Ranking Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to verify the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or search string that triggered retrieval. Drives semantic relevance scoring.

What were Apple's Q4 2024 earnings?

Non-empty string. Check for minimum length of 3 characters. Reject empty or whitespace-only input.

[RETRIEVED_PASSAGES]

Array of passage objects from the initial retrieval step. Each object must include text, source, and publication_date fields.

[{"id":"p1","text":"Apple reported...","source":"SEC Filing","publication_date":"2024-10-31"}]

Must be a non-empty JSON array. Each object requires id (string), text (string, non-empty), source (string), and publication_date (ISO 8601 string or null). Reject if array is empty or any required field is missing.

[DOMAIN_FRESHNESS_WINDOW]

The maximum age in days that evidence can have before it is considered stale for this query domain. Controls the time-decay curve.

90

Must be a positive integer or null. If null, the prompt uses a default of 365 days. Reject negative values or non-numeric strings. Validate that the window is appropriate for the domain (e.g., 1 for breaking news, 365 for annual reports).

[SOURCE_AUTHORITY_MAP]

A mapping of source names to authority scores (0-1). Used to weight evidence from more authoritative sources higher.

{"SEC Filing": 0.95, "Press Release": 0.85, "Blog Post": 0.4}

Must be a valid JSON object with string keys and numeric values between 0 and 1 inclusive. Reject if any value is outside range or if the object is empty. Null allowed if authority weighting is disabled.

[CURRENT_DATE]

The reference date for calculating passage age. Typically the current date or the date of the query.

2025-01-15

Must be a valid ISO 8601 date string (YYYY-MM-DD). Reject malformed dates or dates in the future relative to system time. Required; no default.

[OUTPUT_SCHEMA]

The expected JSON schema for the ranked passage list. Defines the structure the model must produce.

{"type":"array","items":{"type":"object","properties":{"rank":{"type":"integer"},"passage_id":{"type":"string"},"combined_score":{"type":"number"},"recency_justification":{"type":"string"}},"required":["rank","passage_id","combined_score","recency_justification"]}}

Must be a valid JSON Schema object. Validate with a JSON Schema validator before prompt assembly. Reject if schema is malformed or missing required output fields.

[RANKING_CONSTRAINTS]

Additional rules for the ranking process, such as minimum score thresholds, tie-breaking logic, or exclusion criteria.

Exclude passages with combined_score below 0.3. Break ties by preferring higher source authority.

String or null. If provided, must be non-empty. Validate that constraints do not contradict the output schema (e.g., requiring fields not in the schema). Null allowed if no additional constraints.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Recency-Aware Passage Ranking Prompt into a production RAG pipeline with validation, retries, and observability.

This prompt is designed to sit between your retrieval system and your answer generation step. It accepts a list of passages—each with a passage_id, text, publication_date, and source_authority score—along with the user's query and a domain-specific freshness window. The output is a reranked list of passages with combined relevance-freshness scores and per-passage recency justifications. The implementation harness must enforce the input schema, validate the output structure, and handle failures before the ranked list reaches downstream components.

Input Validation and Schema Enforcement. Before calling the model, validate that every passage object contains the required fields: passage_id (string), text (string), publication_date (ISO 8601 string or null), and source_authority (float 0-1). Reject or sanitize inputs where publication_date is missing or unparseable—assign a default date far in the past with a low-confidence flag rather than silently passing null. The freshness_window_days parameter must be a positive integer; clamp unreasonable values (e.g., >10 years for news queries) and log a warning. The query_timestamp should default to the current UTC time if not provided, but make this explicit in logs to avoid silent timezone drift.

Model Choice and Tool Integration. This prompt works best with models that have strong instruction-following and structured output capabilities (e.g., GPT-4o, Claude 3.5 Sonnet). For high-throughput pipelines, consider using a smaller, fine-tuned model with the same output schema. If your retrieval system already provides relevance scores, pass them as an optional retrieval_score field per passage and instruct the model to incorporate them. Do not use this prompt as a standalone tool call—it should be a synchronous step in your RAG pipeline with a timeout (suggest 10-30 seconds depending on passage count) and a circuit breaker that falls back to retrieval-order ranking if the model call fails twice.

Output Validation and Retry Logic. Parse the model's JSON output immediately. Validate that: (1) the ranked_passages array contains the same number of items as the input, (2) every passage_id in the output matches an input passage_id, (3) the combined_score values are floats between 0 and 1, and (4) the recency_justification field is a non-empty string for each passage. If validation fails, retry once with a repair prompt that includes the validation error message. If the second attempt also fails, log the failure, fall back to a deterministic time-decay reranking function (e.g., exponential decay based on publication_date and freshness_window_days), and emit an alert. Never pass unvalidated rankings to the answer generation step.

Observability and Logging. Log the full prompt input, model response, validation results, and final ranked list for every call. Include metadata: model_id, latency_ms, token_count, validation_passed (boolean), and fallback_used (boolean). This data is essential for debugging ranking quality issues and for the eval harness described in the companion evaluation rubric. If your system serves user-facing answers, store the recency_justification strings alongside citations so users can inspect why a source was prioritized. For high-stakes domains like financial intelligence or medical literature, route a sample of ranked outputs to human review and compare against the eval rubric's preference pairs to detect drift.

What to Avoid. Do not use this prompt for real-time streaming scenarios where passage sets change faster than the model's inference latency—use a deterministic time-decay function instead. Do not pass more than 50 passages in a single call; if your retrieval set is larger, pre-filter by retrieval score or source authority before invoking the prompt. Do not skip output validation even if the model has been reliable in testing—schema drift and malformed JSON are the most common production failure modes for structured-output prompts.

PRACTICAL GUARDRAILS

Common Failure Modes

Recency-aware ranking introduces specific failure modes where temporal signals can overpower relevance, stale data masquerades as current, or the model fails to justify its temporal reasoning. These cards cover the most common production failures and how to guard against them.

01

Recency Overpowering Relevance

What to watch: The model ranks a recent but tangentially relevant passage above an older, highly authoritative source that directly answers the query. This happens when the recency boost drowns out semantic relevance scores. Guardrail: Apply a recency ceiling that caps the maximum temporal boost relative to the base relevance score. Test with query pairs where the correct answer comes from an older source.

02

Stale Data with Recent Timestamps

What to watch: A passage has a recent publication date but contains outdated information—common with republished content, aggregated feeds, or documents that inherit metadata timestamps from ingestion pipelines rather than original publication. Guardrail: Extract and verify the effective date of the information, not just the document metadata date. Cross-reference with a publication date extraction step before ranking.

03

Missing Temporal Justification

What to watch: The model produces a ranked list with recency scores but fails to explain why a passage's publication date matters for this specific query. Users and downstream systems cannot audit the temporal reasoning. Guardrail: Require a per-passage recency justification field in the output schema. Validate that justifications reference the query's temporal requirements, not just the passage date.

04

Domain Mismatch in Decay Functions

What to watch: A single decay function is applied across all domains—treating financial data (hours matter) the same as historical analysis (years are fine). This produces wrong rankings when the query domain doesn't match the decay curve. Guardrail: Classify the query's temporal sensitivity first, then select a domain-appropriate decay function. Maintain a configurable mapping of domain to half-life parameters.

05

Undetected Temporal Contradictions

What to watch: Two highly-ranked passages from different time periods report conflicting facts for the same event. The model ranks both highly without flagging the contradiction, producing a misleading evidence list. Guardrail: Add a post-ranking contradiction detection step that compares passages within the same entity-time window. Flag contradictions with severity levels before the evidence list reaches answer generation.

06

Silent Failure on Missing Dates

What to watch: Passages without extractable publication dates receive default or null recency scores and fall to the bottom of the ranking—even when they contain the best evidence. The model doesn't surface that date extraction failed. Guardrail: Require explicit date extraction confidence scores. When confidence is low, apply a neutral recency score and flag the passage for human review rather than silently deprioritizing it.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the recency-aware passage ranking output before integrating it into a production RAG pipeline. Each criterion targets a specific failure mode common in temporal relevance ranking.

CriterionPass StandardFailure SignalTest Method

Temporal Ordering

Passages with higher temporal relevance scores are ranked above less relevant ones when semantic relevance is comparable.

A passage from 2020 is ranked above a passage from 2024 for a query explicitly requiring recent information.

Pairwise comparison against a human-annotated preference dataset of 50 passage pairs with temporal conflicts.

Recency Justification Quality

The [RECENCY_JUSTIFICATION] field for each passage cites a specific date or time window from the passage and explains its relevance to the query.

The justification is generic, such as 'This passage is recent,' without referencing a specific publication date or temporal context.

LLM-as-judge evaluation using a 3-point rubric on a sample of 30 justifications, checking for specific date mentions and logical connection to the query.

Domain-Specific Freshness Compliance

The ranking respects the domain-specific freshness window defined in [FRESHNESS_WINDOW]. No passage outside this window is ranked in the top 3 unless explicitly justified.

A passage from last year is ranked first for a financial query where [FRESHNESS_WINDOW] is set to 'current quarter'.

Automated assertion check: for a test set of 20 queries with known freshness windows, verify that the top-ranked passage's publication date falls within the specified window.

Source Authority Weighting

When two passages have comparable recency, the one from a source listed in [AUTHORITY_SOURCE_LIST] is ranked higher.

A blog post from yesterday outranks a regulatory filing from yesterday for a compliance query.

Controlled A/B test: run the prompt on 10 query pairs where recency is identical but source authority differs, and measure the rank-order correlation with the expected authority-based ordering.

Combined Score Calibration

The [COMBINED_RELEVANCE_FRESHNESS_SCORE] is not dominated by either relevance or recency alone. A highly relevant but slightly stale passage should not score 0.99.

A passage with a perfect semantic match but a 5-year-old publication date receives a combined score above 0.9 for a time-sensitive query.

Distribution analysis: run the prompt on a 100-query benchmark and check that the combined score distribution does not cluster near 0 or 1 for mixed-quality passages. Flag scores with variance below 0.1 across the candidate set.

Stale Passage Flagging Completeness

Every passage whose publication date falls outside the [FRESHNESS_WINDOW] is included in the [STALE_ARTICLE_FLAGS] output with a specific deprecation reason.

A passage from 2018 is silently excluded from the ranked list without appearing in the stale flags or an explicit exclusion note.

Schema check: for a test set with 15 known-stale passages, assert that the count of items in [STALE_ARTICLE_FLAGS] equals the number of passages outside the freshness window, and that each flag includes a non-empty deprecation reason.

Output Schema Adherence

The output is valid JSON matching the expected schema, with all required fields present and correctly typed.

The [RANKED_PASSAGES] array is missing the [RECENCY_JUSTIFICATION] field, or the [COMBINED_RELEVANCE_FRESHNESS_SCORE] is a string instead of a float.

Automated JSON Schema validation run on every output. The CI pipeline should block any prompt version that produces schema-invalid outputs on more than 2% of a 200-sample golden dataset.

Edge Case: No Recent Passages

When no passage falls within the [FRESHNESS_WINDOW], the output includes an explicit [INSUFFICIENT_RECENT_EVIDENCE] flag set to true and does not fabricate recency justifications.

The prompt ranks all passages as if they were recent, or invents 'approximate' recency justifications for clearly stale passages.

Targeted test: run the prompt with a retrieval set where all passages are 5+ years old for a query requiring information from the last month. Assert that [INSUFFICIENT_RECENT_EVIDENCE] is true and no passage receives a [COMBINED_RELEVANCE_FRESHNESS_SCORE] above 0.3.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a small set of passages and a simple recency window. Replace the full eval rubric with a manual spot check of 10-15 ranking pairs. Drop the per-passage justification requirement and output only the ordered list with scores.

code
[PASSAGES]
[QUERY]
[REFERENCE_DATE]

Rank passages by combined relevance and recency. Output an ordered list with composite scores. Do not include justifications.

Watch for

  • Ranking inversion when relevance and recency conflict with no tiebreaker rule
  • Date parsing failures on relative timestamps like "last quarter"
  • Over-prioritizing very recent but marginally relevant passages
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.