Inferensys

Prompt

Multi-Turn Evidence Ranking Prompt with History

A practical prompt playbook for retrieval engineers who need to re-rank evidence when conversation context changes. Produces a relevance ranking that weights passages against both the current question and prior conversation state.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for multi-turn evidence ranking.

This prompt is for retrieval engineers and RAG pipeline builders who need to re-rank a set of retrieved passages when the user's follow-up question shifts the conversational context. The core job-to-be-done is producing a relevance-ordered list of evidence chunks that weights each passage against both the immediate query and the established conversation history. Without this step, a naive re-ranker will treat every turn as a fresh search, discarding the shared context that makes follow-ups coherent. The ideal user is someone integrating this into a retrieval pipeline—typically a backend engineer or AI architect—who already has a vector or keyword retrieval stage and needs a second-pass ranking that is conversation-aware.

Use this prompt when your application supports multi-turn chat or copilot interactions over a knowledge base, and when the user's current question cannot be answered well by treating it in isolation. It is appropriate for scenarios where prior turns have narrowed the domain (e.g., 'Tell me more about the second option'), introduced constraints ('Only show me results from 2024'), or established entities that should influence relevance. The prompt requires you to supply the conversation history, the current question, and a list of candidate passages with identifiers. It returns a ranked list with relevance scores and brief justifications, which your application can then threshold, truncate, or pass to a synthesis prompt.

Do not use this prompt for single-turn Q&A where no conversation history exists—a standard relevance ranking prompt will be simpler and cheaper. Avoid it when the history is extremely long and exceeds your context budget; in that case, apply a session summarization or history compression prompt first, then feed the compressed context into this ranker. This prompt is also not a substitute for initial retrieval. It assumes you already have a candidate set from a vector database, keyword index, or hybrid search. If your retrieval stage is returning zero results or entirely off-topic passages, fix that pipeline before adding a re-ranker. Finally, in high-stakes domains like clinical or legal Q&A, the ranking justifications should be logged and reviewed, not blindly trusted, because a ranking error can silently drop the most authoritative source.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Multi-Turn Evidence Ranking Prompt with History works, where it breaks, and what you must have in place before deploying it.

01

Strong Fit: Context-Dependent Retrieval

Use when: the relevance of a passage depends on prior conversation turns. This prompt excels at re-weighting evidence when a follow-up question shifts the meaning of 'relevant.' Guardrail: Always pass the full conversation history object, not just the last user message, to prevent the ranker from treating a follow-up as a standalone query.

02

Bad Fit: Single-Shot Retrieval Pipelines

Avoid when: every user query is independent and no conversation state exists. The history-weighting logic adds latency and token cost without benefit. Guardrail: Use a standard single-turn evidence ranking prompt instead. Gate this prompt behind a session-state check so it only activates when conversation history is non-empty.

03

Required Input: Structured Conversation History

What to watch: The prompt depends on a well-formed history object with turn boundaries, speaker roles, and timestamps. Free-text logs or unstructured chat dumps produce unreliable rankings. Guardrail: Validate the history schema before injection. Reject or repair history objects missing required fields like turn_id, role, or content.

04

Operational Risk: Stale Context Poisoning

What to watch: Old conversation turns can anchor the ranker to obsolete topics, causing it to down-rank evidence relevant to the user's current intent. Guardrail: Implement a context expiration policy that drops or down-weights turns older than a configurable threshold. Log when expired turns are pruned so operators can audit ranking shifts.

05

Latency Risk: Large History Windows

What to watch: Ranking over many evidence chunks with a long conversation history can blow out latency budgets, especially in synchronous chat UIs. Guardrail: Set a hard cap on the number of history turns and evidence passages passed to the ranker. Use a lightweight pre-filter to trim the candidate set before the full history-aware ranking step.

06

Eval Requirement: Context-Aware Relevance Scoring

What to watch: Standard retrieval metrics like NDCG don't capture whether the ranker correctly weighted passages against conversation context. A passage can be topically relevant but contextually wrong. Guardrail: Build eval sets with paired (history, question, passage) triples and human-annotated context-aware relevance labels. Run these evals on every prompt change before release.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for re-ranking retrieved evidence against both the current question and prior conversation state, with square-bracket placeholders for easy adaptation.

This prompt template is designed for retrieval engineers who need to re-rank evidence when conversation context shifts. It takes the current user question, the conversation history, and a set of retrieved passages, then produces a relevance ranking that weights each passage against both the immediate query and the established conversational state. The output is a structured ranking with scores and explanations, suitable for downstream answer synthesis or evidence selection.

text
You are an evidence ranking system for a multi-turn conversational AI. Your job is to score and rank retrieved passages based on their relevance to the current user question, taking into account the conversation history for context.

## CONVERSATION HISTORY
[HISTORY]

## CURRENT QUESTION
[QUESTION]

## RETRIEVED PASSAGES
[PASSAGES]

## RANKING CRITERIA
1. Direct relevance to the current question (primary weight).
2. Consistency with or relevance to prior conversation turns (secondary weight).
3. Information novelty — prefer passages that add new, non-redundant information.
4. Temporal relevance — if the history or question implies a time frame, prefer passages that match.
5. Source authority — if source metadata is provided, prefer more authoritative or recent sources.

## OUTPUT FORMAT
Return a JSON object with the following structure:
{
  "ranked_passages": [
    {
      "passage_id": "string",
      "relevance_score": 0.0-1.0,
      "relevance_explanation": "Brief explanation of why this passage is relevant to the current question and conversation context",
      "key_facts": ["fact from passage relevant to question"]
    }
  ],
  "ranking_summary": "Brief summary of the ranking logic applied",
  "conversation_context_used": "How the conversation history influenced the ranking"
}

## CONSTRAINTS
- Score each passage independently, then rank by score descending.
- If a passage is irrelevant to both the question and conversation context, score it below 0.3.
- If the conversation history indicates a topic shift, deprioritize passages relevant only to the old topic.
- Do not fabricate facts. Only use information present in the passages.
- If no passages are relevant, return an empty ranked_passages array and explain why.

To adapt this template, replace [HISTORY] with the formatted conversation turns, [QUESTION] with the current user query, and [PASSAGES] with the retrieved evidence set including passage IDs and source metadata. For high-stakes domains, add a [RISK_LEVEL] parameter that adjusts the scoring threshold for inclusion and requires a human review flag when confidence is low. Wire the output into your evidence selection pipeline by filtering passages above a configurable relevance threshold before passing them to the answer synthesis step.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Multi-Turn Evidence 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

[CURRENT_QUESTION]

The user's latest question or query that requires evidence ranking

What are the side effects of the new firmware update?

Non-empty string check. Must differ from [PRIOR_QUESTION] when topic shift is expected. Reject if only whitespace or punctuation.

[PRIOR_QUESTION]

The previous user question from the conversation history, used to detect topic drift

How do I install the firmware update?

Nullable. If first turn in session, set to null. Otherwise must be a complete question string. Validate that it matches the last logged user turn.

[PRIOR_ANSWER_SUMMARY]

A condensed version of the system's previous answer, used to assess whether new evidence contradicts or extends prior claims

Firmware v2.4.1 installs via the admin console under Settings > System > Update. A reboot is required.

Required when [PRIOR_QUESTION] is not null. Must be a factual summary without hallucinated additions. Validate against the actual prior response log.

[RETRIEVED_PASSAGES]

The set of candidate passages retrieved for the current question, each with a unique ID and source metadata

[{"id":"p1","text":"Firmware v2.4.1 may cause battery drain on Model X devices.","source":"release-notes-2.4.1.pdf","date":"2025-03-01"}]

Must be a valid JSON array. Each object requires id, text, and source fields. Minimum 1 passage, maximum defined by context budget. Reject if any passage text is empty.

[CONVERSATION_STATE]

A structured summary of the session state including resolved topics, unresolved questions, and user corrections

{"resolved":["Installation steps"],"unresolved":[],"corrections":["User clarified they are on Model X, not Model Y"]}

Must be valid JSON with resolved, unresolved, and corrections arrays. Nullable for first turn. Validate that corrections reference actual prior user feedback.

[RANKING_CRITERIA]

The ordered list of factors the model should use to score passage relevance, such as topical match, recency, source authority, and contradiction with prior answers

  1. Direct relevance to current question
  2. Recency of source document
  3. Consistency with prior answer
  4. Source authority tier

Must be a non-empty ordered list. Each criterion must be a discrete, evaluable factor. Avoid vague criteria like 'quality'. Validate that criteria are mutually exclusive enough to produce distinct rankings.

[OUTPUT_SCHEMA]

The exact JSON schema the model must follow for ranked output, including fields for passage ID, relevance score, and ranking rationale

{"ranked_passages":[{"passage_id":"string","relevance_score":0.0-1.0,"rationale":"string","contradicts_prior":true|false}]}

Must be a valid JSON Schema or example structure. Validate that the schema includes a relevance score field with defined bounds and a contradiction flag. Reject schemas that allow free-text ranking without structured scores.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when ranking evidence across conversation turns and how to guard against it.

01

History Drift Overrides Current Query

What to watch: The model weights prior conversation context too heavily, ranking passages relevant to earlier turns above passages directly answering the current question. This produces answers that feel stuck in the past. Guardrail: Add an explicit instruction to prioritize the current query when scoring relevance, and include a recency weight parameter in the ranking schema that can be tuned per turn.

02

Stale Evidence Persists Across Turns

What to watch: Passages retrieved three turns ago remain in the ranked set even when the topic has shifted, causing the model to synthesize answers from outdated context. Guardrail: Implement a context expiration check that flags passages older than N turns for re-retrieval, and include a staleness penalty in the ranking prompt when the topic shift detector fires.

03

Ranking Collapses Under Long Histories

What to watch: As conversation history grows, the ranking model struggles to distinguish signal from noise, producing flat relevance scores where everything looks equally relevant or equally irrelevant. Guardrail: Compress dialogue history before ranking by extracting only unresolved questions, key facts, and active constraints. Test ranking discrimination with synthetic long-conversation traces.

04

Implicit Reference Resolution Fails

What to watch: The current question contains pronouns or anaphoric references ('it', 'that approach', 'the second one') that the ranking model fails to resolve against prior turns, causing it to rank irrelevant passages. Guardrail: Pre-process the current question with a reference resolution step that expands implicit references into explicit terms before passing to the ranking prompt. Log unresolved references for human review.

05

Contradictory Evidence Across Turns Goes Unflagged

What to watch: A passage ranked highly in the current turn directly contradicts evidence cited in a prior answer, but the ranking prompt doesn't surface the conflict. The user receives inconsistent information without warning. Guardrail: Add a cross-turn consistency check to the ranking output schema that compares newly ranked passages against previously cited evidence and flags contradictions with a severity label.

06

Over-Ranking Reinforces Prior Mistakes

What to watch: If the model gave a partially incorrect answer in a prior turn, the ranking prompt may boost passages that support that incorrect answer to maintain consistency, compounding the error. Guardrail: Include a correction-awareness flag in the ranking context. When the user has corrected a prior answer, apply a penalty to passages that support the incorrect claim and boost passages that align with the correction.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the multi-turn evidence ranking prompt before deploying it. Each criterion targets a specific failure mode common in context-aware re-ranking.

CriterionPass StandardFailure SignalTest Method

Context-Aware Relevance

Rankings shift correctly when [CONVERSATION_HISTORY] changes the user's intent, even if the [CURRENT_QUESTION] text is identical.

Rankings remain static regardless of history; passages relevant to a prior turn are ranked above passages relevant to the current intent.

Run the prompt with two different [CONVERSATION_HISTORY] inputs for the same [CURRENT_QUESTION]. Assert that the top-3 ranked passages differ.

History Weighting Discipline

The prompt weights [CURRENT_QUESTION] relevance higher than [CONVERSATION_HISTORY] relevance unless the question is explicitly a follow-up.

A passage that matches a keyword in the history but is irrelevant to the current question is ranked first.

Inject a distractor passage that matches the history topic but not the current question. Assert it is ranked in the bottom half of the list.

Stale Context Handling

Passages that were relevant to a resolved prior turn are deprioritized in favor of evidence for the new question.

Resolved topics from earlier turns continue to dominate the top rankings.

Simulate a conversation where the user explicitly closes a topic and starts a new one. Assert that passages for the closed topic are not in the top-3.

Output Schema Compliance

Every ranked passage includes the required fields: passage_id, rank, relevance_score, and rationale.

Missing rationale field; rank values are not sequential integers starting from 1; passage_id does not match input.

Validate the JSON output against the [OUTPUT_SCHEMA]. Assert all required fields are present, rank is a unique integer, and passage_id exists in the input set.

Ranking Rationale Quality

The rationale field explicitly references specific content from both the [CURRENT_QUESTION] and the passage, not just generic statements.

Rationale is boilerplate text like 'This passage is relevant to the query' with no specific evidence.

Parse the rationale field for each top-3 passage. Assert it contains at least one direct quote or specific entity from the passage and one from the question.

Full Passage Set Coverage

All input passages from [RETRIEVED_PASSAGES] appear in the ranked output exactly once.

Passages are missing from the output, duplicated, or hallucinated passages appear.

Count the number of unique passage_id values in the output. Assert it equals the count in [RETRIEVED_PASSAGES] and all IDs match.

Temporal Sequence Awareness

When [CONVERSATION_HISTORY] contains time-sensitive language like 'latest' or 'most recent', passages with newer timestamps are ranked higher.

An older, less relevant passage with a keyword match is ranked above a newer, more relevant passage.

Use a test set where [RETRIEVED_PASSAGES] includes timestamps. Assert that the relevance_score for newer passages is higher when the history includes recency cues.

Conflict Transparency

When two passages contradict each other and both are relevant, the prompt ranks both highly and notes the conflict in the rationale.

The prompt arbitrarily picks one passage and ignores the other, or ranks the contradictory passage last without explanation.

Inject two passages with directly contradictory facts. Assert both appear in the top-5 and at least one rationale mentions the contradiction.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the multi-turn evidence ranking prompt into a production RAG pipeline with validation, retries, and conversation state management.

This prompt is designed to sit between your retrieval system and your answer generation step. It expects a structured payload containing the current user question, a compressed or full conversation history, and a batch of retrieved passages. The output is a ranked list of passages with relevance scores and a brief justification for each ranking decision. In a production harness, you should call this prompt after every retrieval event in a multi-turn session—not just on the first turn—because the relevance of previously retrieved passages can shift dramatically as the conversation evolves.

Wire the prompt into your application as a stateless ranking service. Construct the input payload by merging the latest user utterance with a conversation history summary (use the Session Summarization Prompt for Long Conversations if the history is large) and the top-N passages from your retriever. Validate the output against a strict schema: each ranked passage must include a passage_id, a relevance_score (float 0-1), and a justification string. If the model returns malformed JSON or missing fields, retry once with a repair prompt that includes the raw output and the expected schema. Log every ranking event—including input context, raw model output, parsed rankings, and any validation errors—so you can debug relevance drift and model inconsistencies later.

For high-stakes domains, insert a human review step when the top-ranked passage's score falls below a configurable threshold (e.g., 0.6) or when the ranking justification indicates the model is uncertain about context relevance. This prevents the downstream answer generator from synthesizing a response from weak evidence. Before deploying, build an eval harness that tests the ranker against conversation scenarios where the topic shifts, the user corrects a prior answer, or the retriever returns partially stale passages. Measure whether the ranker correctly deprioritizes passages that were relevant two turns ago but are now off-topic. Avoid calling this prompt on every keystroke or partial utterance—batch it on complete user turns to control latency and cost.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base ranking prompt and a small set of 3-5 passages per turn. Use a simple relevance scale (1-5) without requiring justification strings. Skip conversation history weighting for the first iteration—just concatenate the last [N_TURNS] of dialogue as plain text before the current question.

code
Rank the following passages by relevance to the current question.

Conversation so far:
[HISTORY_TEXT]

Current question: [QUESTION]

Passages:
[PASSAGE_LIST]

Return a JSON array of passage IDs ordered by relevance (most relevant first).

Watch for

  • Ranking that ignores conversation context entirely and treats every turn as a fresh query
  • Over-ranking passages that match keywords from earlier turns but not the current question
  • No handling of ties—two passages may be equally relevant but the model picks arbitrarily without signaling it
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.