Inferensys

Prompt

Passage Re-Ranking Prompt with CoT Reasoning

A practical prompt playbook for using Passage Re-Ranking Prompt with CoT Reasoning in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Determines when auditable chain-of-thought re-ranking is the right tool versus simpler scoring or human review.

This prompt is for AI architects and retrieval engineers who need auditable, step-by-step reasoning behind passage re-ranking decisions. Use it when a black-box relevance score is not enough and downstream systems or human reviewers need to understand why specific passages were prioritized. The prompt forces the model to assess each passage against query intent, entity mentions, and factual coverage before assigning a rank. It is designed for RAG pipelines where transparency reduces hallucination risk and supports debugging.

Do not use this prompt when latency budgets are under 200ms or when the retrieval set exceeds 20 passages, as the chain-of-thought overhead becomes prohibitive. This prompt assumes you already have a candidate passage set from a first-stage retriever. It does not perform retrieval itself. The ideal user is someone who can inspect the reasoning traces, calibrate the eval criteria, and decide when the transparency gain justifies the token and latency cost.

Before adopting this prompt, verify that your downstream answer synthesis step actually consumes the reasoning output. If the synthesis prompt only needs the final ranked list, consider a lighter-weight scoring prompt instead. Reserve this CoT re-ranker for debugging phases, high-stakes domains, or compliance workflows where the reasoning trail is itself a required artifact.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Passage Re-Ranking Prompt with CoT Reasoning delivers value and where it introduces risk. Use these cards to decide if this prompt fits your production RAG pipeline.

01

Good Fit: Transparent Ranking Logic

Use when: You need auditable evidence selection decisions for compliance, debugging, or stakeholder review. Guardrail: The chain-of-thought reasoning provides a human-readable trace, but you must still log the raw prompt and response for offline analysis.

02

Bad Fit: Latency-Sensitive Retrieval

Avoid when: Your system requires sub-100ms re-ranking on large retrieval sets. Risk: CoT reasoning adds significant token generation overhead. Guardrail: Use a lightweight cross-encoder or embedding-based re-ranker for real-time paths, reserving this prompt for async or high-stakes batches.

03

Required Inputs: Structured Evidence Set

What to watch: The prompt assumes each passage has a unique ID, source metadata, and clean text. Guardrail: Validate that your retrieval pipeline injects passage_id, source_title, and text fields for every chunk before calling this prompt. Missing IDs break citation traceability.

04

Operational Risk: Reasoning vs. Ranking Drift

What to watch: The model may produce plausible-sounding reasoning that does not align with its final ranking order. Guardrail: Implement a post-hoc eval that extracts the ranked list and independently checks if the reasoning text supports the assigned positions. Flag mismatches for human review.

05

Operational Risk: Context Window Exhaustion

Avoid when: Your initial retrieval set plus the CoT reasoning output exceeds the model's context limit. Risk: Truncation can drop low-ranked passages or cut off reasoning mid-stream. Guardrail: Pre-filter to a safe top-N (e.g., 20-30 passages) and set a max_tokens limit on the reasoning output to prevent silent truncation.

06

Good Fit: Complex Multi-Factor Queries

Use when: Query intent depends on entity matching, temporal constraints, and factual coverage that simple similarity scoring misses. Guardrail: The CoT structure forces the model to weigh these factors explicitly, but you should still run a coverage check to ensure all query constraints were addressed in the reasoning.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt that re-ranks retrieved passages with explicit chain-of-thought reasoning, designed for direct integration into RAG pipelines.

This template provides a complete re-ranking prompt that forces the model to reason about each passage's relevance before producing a final ranking. The chain-of-thought (CoT) structure makes the ranking logic auditable, which is essential for debugging retrieval quality, calibrating confidence thresholds, and generating explainability traces for downstream users or evaluators. Use this prompt when you need transparent evidence selection, not just a sorted list.

text
You are a precise evidence-ranking specialist. Your task is to re-rank a set of retrieved passages by their relevance to a user query. You must reason step-by-step about each passage before assigning a final rank.

## INPUT

**User Query:**
[QUERY]

**Retrieved Passages:**
[PASSAGES]

## RE-RANKING INSTRUCTIONS

For each passage, perform the following reasoning steps before producing the final ranked list:

1. **Query Intent Analysis:** Identify the core entities, relationships, temporal constraints, and information needs expressed in the user query.
2. **Passage-by-Passage Assessment:** For each passage, evaluate:
   - **Entity Match:** Does the passage mention the key entities from the query?
   - **Intent Alignment:** Does the passage address the user's actual information need, or only surface-level keyword overlap?
   - **Factual Coverage:** What specific facts, claims, or data points in the passage directly bear on the query?
   - **Information Density:** Does the passage contain substantive, non-redundant information, or is it mostly filler?
   - **Credibility Signals:** Based on [CREDIBILITY_CRITERIA], does the passage appear authoritative, recent, and well-sourced?
3. **Comparative Ranking:** After assessing all passages individually, compare them head-to-head. Resolve ties by prioritizing passages that provide unique, complementary information. Flag any passages that contradict each other.
4. **Exclusion Justification:** For any passage you exclude from the final ranking, state a clear reason (e.g., irrelevant, redundant, outdated, low credibility).

## OUTPUT FORMAT

Return a JSON object with the following structure:

{
  "query_intent": "A concise summary of the user's core information need.",
  "passage_assessments": [
    {
      "passage_id": "[ID]",
      "entity_match_score": 0.0-1.0,
      "intent_alignment_score": 0.0-1.0,
      "factual_coverage_notes": "Specific facts relevant to the query.",
      "information_density": "high|medium|low",
      "credibility_notes": "Brief assessment based on provided criteria.",
      "relevance_rationale": "Concise explanation of why this passage is or is not relevant."
    }
  ],
  "ranked_passages": [
    {
      "rank": 1,
      "passage_id": "[ID]",
      "relevance_score": 0.0-1.0,
      "ranking_rationale": "Why this passage earned this rank relative to others."
    }
  ],
  "excluded_passages": [
    {
      "passage_id": "[ID]",
      "exclusion_reason": "Clear reason for exclusion."
    }
  ],
  "contradictions_flagged": [
    {
      "passage_id_a": "[ID]",
      "passage_id_b": "[ID]",
      "conflict_description": "What specific claims conflict."
    }
  ]
}

## CONSTRAINTS

- Do not fabricate facts not present in the passages.
- If no passage is sufficiently relevant, return an empty ranked_passages array and explain why in the query_intent field.
- Preserve all original passage IDs exactly as provided.
- [ADDITIONAL_CONSTRAINTS]

To adapt this template, replace [QUERY] with the user's question or search string. [PASSAGES] should be a JSON array of objects, each containing at minimum an id and text field. [CREDIBILITY_CRITERIA] is a critical placeholder: populate it with your domain-specific rules for source trustworthiness, such as publication date thresholds, author authority indicators, or document type preferences. The [ADDITIONAL_CONSTRAINTS] field lets you inject task-specific rules like token budgets, required source diversity, or domain terminology preferences without modifying the core reasoning structure.

Before deploying this prompt, validate that your passage objects include stable, unique IDs that survive your retrieval pipeline. The output JSON schema is designed for direct consumption by a downstream synthesis prompt or an evaluation harness. If you are operating in a regulated domain, route outputs where contradictions_flagged is non-empty or relevance_score falls below a calibrated threshold to a human reviewer. Test the prompt against a golden dataset of query-passage pairs with known relevance judgments to calibrate your scoring expectations before production use.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Passage Re-Ranking Prompt with CoT Reasoning. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed and safe.

PlaceholderPurposeExampleValidation Notes

[QUERY]

The user question or search intent that passages are ranked against

What are the side effects of drug X in elderly patients?

Check: non-empty string, length <= 2000 chars. Reject if contains only stop words or appears to be a system instruction injection attempt

[PASSAGES]

Array of candidate passages to re-rank, each with a unique identifier and full text

[{"id":"p1","text":"Elderly patients showed increased sensitivity to drug X..."}, {"id":"p2","text":"Drug X is contraindicated in patients with renal impairment..."}]

Check: valid JSON array, 2-50 passages, each with non-empty id and text fields. Reject if duplicate ids detected or text fields exceed 4000 tokens each

[RANKING_CRITERIA]

Ordered list of factors to weigh when assessing passage relevance

["Query intent match", "Entity overlap", "Factual coverage", "Recency", "Source authority"]

Check: non-empty array of strings, 2-7 criteria. Each criterion must be a recognizable ranking dimension. Reject if criteria are contradictory or duplicate

[OUTPUT_SCHEMA]

Expected JSON structure for the re-ranked output including reasoning fields

{"ranked_passages":[{"id":"string","rank":"integer","relevance_score":"float","reasoning":"string"}],"excluded_passages":[{"id":"string","exclusion_reason":"string"}]}

Check: valid JSON schema draft. Must include ranked_passages array with id, rank, relevance_score, and reasoning fields. Must include excluded_passages array. Reject if schema allows ambiguous ranking ties without resolution rules

[MAX_PASSAGES]

Maximum number of passages to include in the final ranked output

10

Check: integer between 1 and 50. Must be less than or equal to the number of input passages. Reject if negative, zero, or exceeds context window budget

[REASONING_DEPTH]

Instruction controlling how detailed the chain-of-thought reasoning should be

detailed

Check: enum value from ["brief", "detailed", "comprehensive"]. Reject if not in allowed set. Brief = one sentence per passage. Detailed = entity and intent analysis. Comprehensive = full evidence walkthrough with counterfactuals

[SOURCE_METADATA]

Optional metadata for each passage including date, author, domain, and credibility signals

{"p1":{"date":"2024-03","authority":"high","domain":"clinical_trial"},"p2":{"date":"2023-11","authority":"medium","domain":"case_report"}}

Check: if provided, must be valid JSON object with keys matching passage ids. Each value must have date and authority fields. Null allowed if no metadata available. Reject if metadata contradicts passage content on inspection

[CONSTRAINTS]

Hard rules the ranking must follow, such as minimum source diversity or recency thresholds

["Include at least 3 distinct sources", "Exclude passages older than 2020 unless no recent evidence exists", "Never rank a passage with authority=low above authority=high without explicit justification"]

Check: non-empty array of constraint strings. Each constraint must be testable. Reject if constraints are mutually contradictory or impossible to satisfy given the input passages

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when using a passage re-ranking prompt with chain-of-thought reasoning, and how to guard against it.

01

Reasoning Justifies a Bad Ranking

What to watch: The model produces fluent, plausible-sounding reasoning that masks an incorrect ranking. The chain-of-thought becomes a confident rationalization for a poor selection rather than a faithful trace of the decision process. Guardrail: Evaluate reasoning validity independently from ranking accuracy. Use a separate LLM judge prompt that checks whether the stated reasons factually support the assigned rank, flagging cases where reasoning contradicts the passage content.

02

Position Bias Toward Early Passages

What to watch: The model over-weights passages that appear first in the input list, assigning them higher relevance scores regardless of actual content. This is especially common when the retrieval system already does a coarse ranking. Guardrail: Randomize passage order before sending to the re-ranker. Run the same query with shuffled input order and compare rankings. Flag sessions where rank correlation drops below a threshold as evidence of position bias.

03

Entity Matching Overrides Semantic Relevance

What to watch: The model ranks passages highly because they share entity names with the query, even when the passage context is irrelevant. A passage mentioning "Apple" the company gets ranked for a query about apple fruit cultivation. Guardrail: Include explicit entity disambiguation instructions in the prompt. Add a reasoning check that requires the model to state which entity sense it is using. Test with entity-overlap adversarial queries where surface-level keyword matches should not win.

04

Verbose Passages Crowd Out Concise Evidence

What to watch: Longer passages with more tokens dominate the ranking because the model confuses length with informativeness. A short, fact-dense passage that perfectly answers the query gets ranked below a long, loosely relevant passage. Guardrail: Normalize relevance scores by passage length in post-processing. Add a "fact density" evaluation criterion that checks whether the ranking order changes when controlling for passage length. Flag cases where the top-ranked passage is significantly longer than higher-quality alternatives.

05

CoT Reasoning Hallucinates Passage Content

What to watch: The chain-of-thought reasoning fabricates details not present in the passage to justify its ranking decision. The model claims a passage contains specific data or claims that it does not, making the reasoning trace unreliable for audit. Guardrail: Run a factuality check on the reasoning text itself. Extract every factual claim in the CoT and verify it against the original passage. If any claim is unsupported, flag the entire ranking decision for human review or automatic re-rank without CoT.

06

Query Intent Drift Across Long Contexts

What to watch: When re-ranking many passages, the model gradually shifts its interpretation of the query intent. Early passages are ranked against the original query, while later passages are ranked against a distorted or narrowed version of the intent. Guardrail: Re-state the query intent explicitly before each passage evaluation block in the prompt. Add a consistency check that compares the reasoning for the first and last ranked passages to detect intent drift. If drift is detected, split the re-ranking into smaller batches with intent re-anchoring.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of the Passage Re-Ranking Prompt with CoT Reasoning before shipping. Each criterion targets a specific failure mode common in re-ranking systems, from reasoning validity to ranking calibration.

CriterionPass StandardFailure SignalTest Method

Reasoning Validity

Chain-of-thought reasoning references specific query entities and passage content without hallucinated claims

Reasoning mentions entities not present in the query or passage; reasoning contradicts the passage text

Human review of 50 random reasoning traces; automated entity overlap check between reasoning and source passage

Ranking Calibration

Top-ranked passages are judged more relevant than bottom-ranked passages by human evaluators in >85% of pairwise comparisons

Bottom-ranked passages consistently rated more relevant than top-ranked passages; random ranking distribution

Pairwise human preference test on 100 query-passage pairs; Kendall's tau correlation between model rank and human relevance score

Output Schema Compliance

JSON output matches the defined [OUTPUT_SCHEMA] exactly with all required fields present and correctly typed

Missing required fields; wrong data types; extra unrequested fields; malformed JSON that fails parsing

Automated JSON Schema validation against the contract; parse check on 100% of outputs in test suite

Citation Grounding

Every factual claim in the reasoning is traceable to the source passage text

Reasoning includes claims like 'this passage discusses X' when X is absent from the passage; fabricated statistics or dates

Claim extraction from reasoning followed by string-match verification against source passage; spot-check 30 samples

Tie Handling

Passages with genuinely equal relevance receive identical or adjacent ranks with explicit justification for the tie

Arbitrary ordering of equally relevant passages without explanation; inconsistent tie-breaking across similar queries

Test with synthetic passage sets containing known duplicates; check rank variance across 5 repeated runs

Query Intent Alignment

Reasoning explicitly addresses the query's core intent, entity constraints, and temporal or comparative requirements

Reasoning focuses on keyword overlap while ignoring query semantics; misinterprets comparative queries as single-entity

Curated test set of 20 queries with annotated intent types; manual review of reasoning alignment

Confidence Discrimination

Clear separation between high-confidence and low-confidence passages in both scores and reasoning language

All passages receive similar confidence scores despite varying relevance; hedging language applied uniformly

Score distribution analysis across 100 queries; check for variance collapse; human review of reasoning language for uncertainty markers

Context Window Awareness

Ranking accounts for token budget when [MAX_TOKENS] constraint is provided; excludes low-value passages when budget is tight

Ignores token budget entirely; ranks passages without considering cumulative token cost; includes redundant passages

Test with varying [MAX_TOKENS] values; verify output token count stays within budget; check that exclusions are justified

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base CoT re-ranking prompt but relax the output schema. Accept a simple ordered list with one-sentence justifications instead of full chain-of-thought traces. Use a smaller model (e.g., GPT-4o-mini, Claude Haiku) for faster iteration. Skip the reasoning-validity eval step initially.

code
Rank these passages by relevance to [QUERY]. Return an ordered list with a one-line reason for each position.

Passages:
[PASSAGE_LIST]

Watch for

  • Rankings that look plausible but have circular or contradictory justifications
  • Over-reliance on keyword overlap without semantic understanding
  • Missing entity-coverage checks when passages share similar vocabulary
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.