Inferensys

Prompt

Source Date and Freshness Ranking Prompt

A practical prompt playbook for ranking retrieved passages by temporal relevance in production RAG workflows, with explicit handling of time-sensitive queries versus timeless knowledge.
Developer working on RAG retrieval system, document chunks visible on screen, technical workspace with code editor.
PROMPT PLAYBOOK

When to Use This Prompt

Identify the ideal scenarios, required inputs, and clear contraindications for deploying a freshness-weighted evidence ranking prompt in production RAG systems.

This prompt is for RAG system builders who need to rank retrieved passages by both relevance and recency before answer synthesis. It is designed for knowledge bases where document dates matter: product documentation with versioned releases, financial filings with reporting periods, legal databases with precedents that evolve, news archives, or technical documentation that changes across releases. The prompt produces a freshness-weighted ranking that explicitly distinguishes between queries where recency is critical ('latest security patch') and queries where it is irrelevant ('definition of a derivative'). Use this prompt when your retrieval step returns passages with associated dates and you need to surface the most temporally appropriate evidence before generating an answer.

Before wiring this into your pipeline, verify that your retrieval step reliably returns date metadata for each passage. The prompt expects a publication_date or last_modified field in ISO 8601 format. If your knowledge base lacks this, you will need a preprocessing step to extract or infer dates before invoking the ranking prompt. Additionally, calibrate your staleness thresholds: a security advisory might be stale after 30 days, while a tax regulation might remain current for years. The prompt template includes a [STALENESS_THRESHOLD] variable that lets you define domain-specific freshness windows. For high-stakes domains like legal or clinical RAG, always pair this prompt with a human review step when the ranking deprioritizes a source that a user might reasonably expect to see.

Do not use this prompt when your knowledge base lacks reliable date metadata, when all sources are equally current, or when the user query contains no temporal signal whatsoever. In those cases, a standard relevance-only ranking prompt will produce better results without introducing spurious recency bias. If you are unsure whether temporal signals exist in your queries, run an eval set that includes both time-sensitive and time-agnostic questions and measure whether the freshness weighting improves or degrades answer accuracy. Start with a low recency weight and increase it only when your eval data justifies the trade-off.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Source Date and Freshness Ranking Prompt delivers value, and where it introduces risk. Use these cards to decide if this prompt fits your retrieval pipeline before integrating it.

01

Good Fit: Time-Sensitive Knowledge Bases

Use when: your RAG system indexes news, financial reports, legal filings, product changelogs, or operational runbooks where information decays. Guardrail: define a domain-specific staleness threshold in the prompt harness and test it against known expired documents.

02

Bad Fit: Timeless Reference Corpora

Avoid when: your knowledge base contains stable reference material such as mathematical proofs, physical constants, or canonical literary works. Risk: the prompt may incorrectly penalize older authoritative sources. Guardrail: add a query classifier upstream that bypasses freshness ranking for timeless-domain queries.

03

Required Inputs

Must have: retrieved passages with parseable publication or revision dates, a user query with temporal intent signals, and a configured recency weight parameter. Guardrail: validate date extraction before ranking. If dates are missing or ambiguous, fall back to relevance-only ranking and log the gap.

04

Operational Risk: Date Extraction Failures

What to watch: inconsistent date formats across sources, missing metadata, or ambiguous timestamps that cause the ranking to silently degrade. Guardrail: implement a pre-ranking date normalization step with strict parsing and a confidence flag. Route unparseable dates to a human review queue if the domain is high-stakes.

05

Operational Risk: Recency Bias Override

What to watch: the prompt overweights recency and suppresses highly relevant but slightly older evidence, especially for queries with mixed temporal and timeless intent. Guardrail: expose a recency weight parameter that operators can tune per query type. Monitor ranking distributions for evidence age skew in production traces.

06

Variant: Version-Aware Source Comparison

Use when: multiple versions of the same document exist and the system must prefer the latest revision while acknowledging earlier versions. Guardrail: include version metadata in the passage schema and add a version-precedence rule in the prompt. Test with known document update scenarios to confirm correct version selection.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for ranking retrieved passages by temporal relevance and recency.

This prompt template is designed to be wired into your RAG pipeline after retrieval but before answer synthesis. It takes a user query, a set of retrieved passages with source dates, and a set of configurable constraints to produce a ranked list that balances topical relevance against temporal freshness. The template uses square-bracket placeholders for all dynamic inputs, making it safe to copy directly into your prompt management system or codebase without accidental token injection.

code
You are a temporal evidence ranker for a retrieval-augmented generation system. Your job is to re-rank a set of retrieved passages by balancing their topical relevance to the user's query against their source date freshness.

[INPUT]
User Query: [QUERY]
Current Date: [CURRENT_DATE]
Retrieved Passages:
[PASSAGES]

[CONSTRAINTS]
- Time Sensitivity Classification: [TIME_SENSITIVITY]
- Staleness Threshold (days): [STALENESS_THRESHOLD]
- Recency Weight: [RECENCY_WEIGHT]
- Relevance Weight: [RELEVANCE_WEIGHT]
- Minimum Sources to Return: [MIN_SOURCES]
- Maximum Sources to Return: [MAX_SOURCES]

[OUTPUT_SCHEMA]
Return a JSON object with the following structure:
{
  "query_time_sensitivity": "high|medium|low|none",
  "staleness_threshold_applied_days": number,
  "ranked_passages": [
    {
      "passage_id": "string",
      "rank": number,
      "relevance_score": 0.0-1.0,
      "freshness_score": 0.0-1.0,
      "combined_score": 0.0-1.0,
      "source_date": "YYYY-MM-DD",
      "days_since_publication": number,
      "freshness_justification": "string explaining why this date matters or doesn't matter for this query",
      "relevance_justification": "string explaining topical match to query"
    }
  ],
  "excluded_passages": [
    {
      "passage_id": "string",
      "exclusion_reason": "stale|irrelevant|redundant|below_threshold",
      "detail": "string"
    }
  ],
  "ranking_methodology": "string summarizing how recency and relevance were balanced"
}

[EXAMPLES]
Example 1 - Time-Sensitive Query:
Query: "What are the latest COVID-19 booster recommendations?"
Current Date: 2025-06-15
Time Sensitivity: high
Expected behavior: Passages older than 90 days should be heavily penalized. A highly relevant passage from 2024 should rank below a moderately relevant passage from May 2025.

Example 2 - Timeless Query:
Query: "Explain the second law of thermodynamics."
Current Date: 2025-06-15
Time Sensitivity: none
Expected behavior: Source date should have negligible impact on ranking. A highly relevant passage from 2019 should outrank a tangentially relevant passage from 2025.

Example 3 - Mixed Sensitivity:
Query: "What are the best practices for Python async programming?"
Current Date: 2025-06-15
Time Sensitivity: medium
Expected behavior: Prefer passages from the last 2 years, but foundational explanations from older sources should still rank if they remain accurate and highly relevant.

[TOOLS]
No external tools are available. You must work only with the provided passages and their metadata.

[RISK_LEVEL]
Medium. Incorrect freshness ranking can surface outdated information for time-sensitive queries. For high-stakes domains such as medical or legal, human review of the final ranked set is required before answer synthesis.

Now, rank the passages according to the constraints above and return the JSON output.

To adapt this template for your pipeline, start by defining how your system classifies time sensitivity. You can either pass a pre-classified [TIME_SENSITIVITY] value from an upstream classifier prompt, or remove that field and let this prompt infer sensitivity from the query itself. The [STALENESS_THRESHOLD] should be set based on your domain: 30 days for news, 90 days for technical documentation, 365 days for academic literature, or null for timeless knowledge bases. The [RECENCY_WEIGHT] and [RELEVANCE_WEIGHT] values should sum to 1.0 and can be tuned per query type. For production use, always validate the JSON output against the schema before passing ranked passages to your synthesis prompt. Log exclusion reasons and freshness justifications to enable debugging when users report stale answers. If your system handles high-stakes domains, route passages flagged with high time sensitivity and low freshness scores to a human review queue before they reach the answer generation stage.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Source Date and Freshness Ranking Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to programmatically verify the input before execution.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or search string that requires temporal relevance assessment

What are the latest PCI DSS compliance requirements for cloud storage?

Non-empty string; check for temporal signals (e.g., 'latest', '2024', 'recent') to decide if freshness weighting should activate

[RETRIEVED_PASSAGES]

Array of passage objects with text, source metadata, and publication dates from the retrieval step

[{"id":"p1","text":"...","source":"NIST SP 800-53 Rev 5","pub_date":"2020-09-23","version":"5.0"}]

Must be a non-empty array; each object requires pub_date field in ISO 8601 format or null; validate array length against context window budget before assembly

[CURRENT_DATE]

The reference date for calculating passage age and staleness; typically the system clock at query time

2025-01-15

Must be ISO 8601 date string; validate it is not in the past relative to system clock by more than 24 hours; null not allowed

[STALENESS_THRESHOLD_DAYS]

Maximum age in days before a passage is considered stale for time-sensitive query types

365

Integer >= 1; validate against query type (e.g., 90 for regulatory, 730 for foundational knowledge); null triggers default of 365

[TIME_SENSITIVITY_CLASS]

Explicit classification of whether the query requires fresh information, set by upstream intent detection

high

Must be one of enum: ['high','medium','low','none']; validate before prompt assembly; 'none' disables freshness weighting entirely

[SOURCE_AUTHORITY_WEIGHTS]

Optional map of source domains or names to authority multipliers for credibility adjustment

{"nist.gov":1.0,"wikipedia.org":0.6,"arxiv.org":0.8}

Valid JSON object; keys must match source identifiers in [RETRIEVED_PASSAGES]; null allowed if authority weighting is not used; validate no negative values

[VERSION_AWARENESS_FLAG]

Boolean controlling whether the prompt should compare document versions and prefer superseding revisions

Must be true or false; when true, prompt includes version comparison logic; when false, each passage is treated independently regardless of version lineage

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Source Date and Freshness Ranking Prompt into a production RAG pipeline with validation, retries, and observability.

This prompt is designed to sit between retrieval and answer synthesis in a RAG pipeline. It expects a list of retrieved passages with associated date metadata and a user query. The output is a ranked list with freshness scores, staleness flags, and explicit reasoning about why temporal relevance matters for this specific query. The harness must handle cases where date metadata is missing, ambiguous, or conflicting, and must enforce the output schema before passing results downstream.

Input Assembly: Before calling the model, assemble the [RETRIEVED_PASSAGES] array with each passage containing id, text, publication_date (ISO 8601), and optional last_updated and content_type fields. The [USER_QUERY] should be passed verbatim. Add a [TEMPORAL_CLASSIFICATION] field if you have a pre-classifier that tags queries as time_sensitive, time_aware, or timeless—this helps the prompt calibrate its freshness weighting. If dates are missing, inject a date_confidence field set to null and let the prompt's explicit handling rules decide how to treat undated sources rather than guessing.

Output Validation: The prompt returns a JSON object with a ranked_passages array. Each entry must contain passage_id, freshness_score (0.0–1.0), relevance_score (0.0–1.0), combined_score, rank, staleness_flag (boolean), and rationale. Implement a post-processing validator that checks: all input passage IDs appear exactly once in the output, scores are within bounds, ranks are sequential and unique, and the staleness_flag is consistent with any configured threshold (e.g., passages older than [STALENESS_THRESHOLD_DAYS] should be flagged unless the query is classified as timeless). Reject and retry malformed outputs up to [MAX_RETRIES] times, escalating to a fallback ranking (chronological or retrieval-score-only) after exhaustion.

Model Choice and Latency: This is a ranking and reasoning task that benefits from strong instruction-following models. Use Claude 3.5 Sonnet, GPT-4o, or equivalent for production. For high-throughput pipelines, consider a smaller model (Claude 3 Haiku, GPT-4o-mini) with stricter output validation and a higher retry budget. Cache the prompt prefix (system instructions and output schema) to reduce latency and cost. If your retrieval set exceeds ~20 passages, pre-filter to the top-N by retrieval score before invoking this prompt to stay within context window limits.

Observability and Eval: Log every invocation with: input passage count, query temporal classification, output ranking distribution, staleness flag count, validation pass/fail, retry count, and latency. Run periodic eval suites comparing model-assigned freshness scores against ground-truth temporal relevance judgments. Watch for drift patterns: over-prioritizing recency on timeless queries, ignoring recent updates to older documents, or inconsistent staleness flagging across similar date gaps. If your application is in a regulated domain (legal, financial, clinical), route staleness-flagged passages to a human review queue before they reach answer synthesis, and log the reviewer's decision for future calibration.

Integration Point: Wire the validated output directly into your answer synthesis prompt by passing the ranked_passages array as [RANKED_EVIDENCE]. Include the staleness_flag and rationale fields so the synthesis prompt can adjust its certainty language (e.g., 'According to a 2019 source...' vs. 'Recent guidance from 2024 indicates...'). Do not silently drop staleness-flagged passages—let the synthesis prompt decide whether to include them with appropriate caveats or exclude them based on your product's freshness policy.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the Source Date and Freshness Ranking Prompt output. Use this contract to parse, validate, and integrate the ranked evidence list into downstream RAG components.

Field or ElementType or FormatRequiredValidation Rule

ranked_sources

Array of objects

Array length must be >= 1. If no sources meet the freshness threshold, return an empty array and set [NO_FRESH_SOURCES] flag to true.

ranked_sources[].source_id

String

Must match a [SOURCE_ID] from the input context. Non-matching IDs trigger a retry or repair step.

ranked_sources[].rank

Integer

Sequential integer starting at 1. No gaps or duplicates. Rank 1 is the most relevant after freshness weighting.

ranked_sources[].freshness_score

Number (0.0-1.0)

Float between 0.0 and 1.0. Score of 1.0 indicates the source date is within the [FRESHNESS_WINDOW_DAYS] for this query type. Score must decrease monotonically with age.

ranked_sources[].relevance_score

Number (0.0-1.0)

Float between 0.0 and 1.0. Must be consistent with the relevance justification text. Score below [RELEVANCE_THRESHOLD] should trigger exclusion unless freshness overrides are active.

ranked_sources[].composite_score

Number (0.0-1.0)

Float between 0.0 and 1.0. Must equal (freshness_score * [FRESHNESS_WEIGHT]) + (relevance_score * (1 - [FRESHNESS_WEIGHT])). Round to 4 decimal places.

ranked_sources[].source_date

ISO 8601 date string (YYYY-MM-DD)

Must be a valid date. If the source has no date, set to null and set freshness_score to [UNDATED_PENALTY]. Future dates trigger a warning flag.

ranked_sources[].staleness_flag

Enum: [FRESH, AGING, STALE]

FRESH if source_date is within [FRESHNESS_WINDOW_DAYS]. AGING if within 2x the window. STALE if older. STALE sources with relevance_score below [RELEVANCE_THRESHOLD] must be excluded.

ranked_sources[].exclusion_reason

String or null

Required if a source was considered but excluded. Use controlled vocabulary: [BELOW_RELEVANCE_THRESHOLD, EXCEEDS_STALENESS_LIMIT, REDUNDANT_WITH_HIGHER_RANK, DATE_PARSE_FAILURE].

query_temporality_class

Enum: [TIME_SENSITIVE, RECENCY_IMPORTANT, TIMELESS]

Must match the classification derived from [QUERY]. TIME_SENSITIVE queries use [FRESHNESS_WEIGHT] >= 0.7. TIMELESS queries use [FRESHNESS_WEIGHT] <= 0.2.

freshness_window_applied_days

Integer

The actual window in days used for this ranking. Must match the window selected based on query_temporality_class. Log if different from default [FRESHNESS_WINDOW_DAYS].

PRACTICAL GUARDRAILS

Common Failure Modes

Source date and freshness ranking fails in predictable ways. These are the most common production failure modes and how to guard against them before they reach users.

01

Treating All Queries as Time-Sensitive

What to watch: The prompt applies recency penalties to timeless queries like 'Explain Newton's second law' or 'Define habeas corpus,' burying authoritative older sources in favor of recent but shallow content. Guardrail: Add a pre-ranking classification step that labels each query as time_sensitive, time_aware, or timeless. Apply freshness weighting only to the first two categories. For timeless queries, default to authority and relevance ranking.

02

Missing or Malformed Source Dates

What to watch: Retrieved passages lack parseable date metadata, causing the ranking prompt to either ignore freshness entirely or hallucinate dates from content mentions. A 2023 article referencing 2019 events gets ranked as 2019. Guardrail: Implement a pre-processing harness that extracts and normalizes source dates from metadata fields before the prompt runs. If no date is found, assign an explicit unknown_date token and apply a configurable default staleness penalty rather than skipping the passage.

03

Recency Bias Overriding Relevance

What to watch: A barely-relevant document from last week outranks a highly authoritative source from six months ago. The prompt overweights recency and underweights relevance, producing answers that are current but wrong. Guardrail: Use a weighted scoring formula with tunable parameters for recency weight and relevance weight. Test with a golden dataset of queries where the correct answer comes from an older source. If recency is overriding relevance in those cases, reduce the recency coefficient.

04

Staleness Thresholds That Don't Match Domain Reality

What to watch: A single staleness threshold of 90 days is applied across all domains. Legal documents from 6 months ago are flagged stale while breaking news from 2 hours ago is treated identically to news from 2 days ago. Guardrail: Implement domain-aware staleness thresholds. Map query domains to expected freshness windows: breaking news (hours), product docs (weeks), legal precedents (years), scientific fundamentals (decades). Pass the domain-specific threshold as a prompt variable.

05

Version Conflicts Across Source Updates

What to watch: Two versions of the same document exist in the retrieval index—v1 from January and v2 from March. The prompt ranks both highly, producing contradictory evidence in the final answer without surfacing the version conflict. Guardrail: Add a deduplication step that detects same-source version pairs, keeps only the most recent version, and optionally flags the exclusion in trace logs. If version history matters for the query, surface the change rather than silently dropping the older version.

06

Date Extraction from Unstructured Content

What to watch: The prompt attempts to extract publication dates from body text when metadata is missing, pulling out dates from examples, historical references, or copyright footers. A document published in 2024 that mentions 'the 2020 election' gets dated to 2020. Guardrail: Never rely on the ranking prompt to extract dates from unstructured content. Use a separate date extraction step with strict rules: prefer structured metadata fields, validate extracted dates against reasonable ranges, and flag ambiguous extractions for human review or conservative default treatment.

IMPLEMENTATION TABLE

Evaluation Rubric

Test criteria for the Source Date and Freshness Ranking Prompt. Use this rubric to verify that the prompt correctly balances recency against relevance, handles time-sensitive vs. timeless queries, and surfaces staleness risks before the ranking reaches downstream synthesis.

CriterionPass StandardFailure SignalTest Method

Date Extraction Accuracy

All extractable dates from [SOURCE_METADATA] are parsed into a normalized ISO-8601 format in the output

Missing dates for sources with known publication timestamps; dates parsed in wrong century or timezone

Run against a golden set of 20 sources with known dates; assert 100% extraction rate and zero format errors

Recency Weighting for Time-Sensitive Queries

When [QUERY_TYPE] is time-sensitive, sources published within [FRESHNESS_WINDOW] days receive at least 2x the weight of sources older than the window

Older sources outrank recent sources without explicit justification; stale sources appear in top-3 for breaking-news queries

Test with 5 time-sensitive queries against a mixed-age source set; verify top-3 sources are within the freshness window unless justified by relevance override

Timeless Query Handling

When [QUERY_TYPE] is timeless, recency contributes less than 20% of the total ranking score and no source is penalized solely for age

Foundational older sources are excluded or ranked below low-quality recent sources for queries about established facts

Test with 5 timeless queries; verify that classic references appear in the ranking and that age-penalty scores are below threshold

Staleness Flag Accuracy

Sources exceeding [STALENESS_THRESHOLD] days are flagged with staleness=true and a human-readable staleness reason in the output

Stale sources are not flagged; false-positive staleness flags on sources within the acceptable window

Run against a source set with known ages spanning 0 to 5 years; assert staleness flag matches threshold boundary with no off-by-one errors

Version-Aware Comparison

When multiple versions of the same source exist, the output identifies the latest version and notes whether older versions are superseded or still relevant

Older versions ranked above newer versions without explanation; version lineage not mentioned in output

Test with 3 source families each having 3 versions; verify latest version is identified and version relationship is noted in the ranking justification

Relevance-Recency Tradeoff Justification

Every ranking decision that deprioritizes a more recent source in favor of an older source includes an explicit justification in the output

Older sources outrank newer ones with no explanation; justification field is empty or generic

Review 10 ranking outputs where recency and relevance conflict; assert 100% have non-empty, specific justification strings

Confidence Score Calibration

Freshness confidence scores correlate with actual date precision: sources with exact dates score higher than sources with estimated or missing dates

Sources with vague dates receive high confidence scores; exact-date sources receive low confidence

Test with a mixed set of exact, month-only, year-only, and undated sources; verify confidence scores decrease as date precision decreases

Output Schema Compliance

Every output record includes all required fields: source_id, publication_date, freshness_score, relevance_score, combined_score, rank_position, staleness_flag, staleness_reason, version_note, and justification

Missing required fields; extra fields not in schema; field types mismatch the [OUTPUT_SCHEMA] contract

Validate 50 output records against the JSON schema; assert 100% field completeness and type correctness

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a simple date extraction regex. Use a single staleness threshold in days and a basic relevance-vs-recency weighting formula. Skip formal schema validation during early testing.

code
Rank passages by combining relevance_score * 0.6 + freshness_score * 0.4.
Consider any source older than [STALENESS_THRESHOLD_DAYS] as stale unless the query explicitly asks for historical information.

Watch for

  • Date parsing failures on ambiguous formats (MM/DD/YY vs DD/MM/YY)
  • Missing publication dates treated as either infinitely fresh or infinitely stale
  • Over-penalizing timeless content (math, physics, programming fundamentals)
  • No handling of versioned documents where older versions are still authoritative
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.