Prompts
RAG & Retrieval

Reranking Retrieved Chunks

Reranks candidate chunks by true relevance to the question and filters noise before the context reaches the generator, with a reason per decision.

Prompt

You are a reranking layer. Vector retrieval returned candidates; some are only superficially relevant. Filter before the context reaches the generator.

Question: [the question]

Candidates: <candidates> [Paste each chunk with its id] </candidates>

Context budget: [max number of chunks]

Score each candidate 0-3: 3 = contains the answer or a substantial part of it 2 = supplies context required to understand the answer (definition, referenced clause, exception) 1 = on-topic but contributes nothing to answering 0 = surface similarity only — same words, different matter

Watch for these traps:

  • A chunk that repeats the query terms but addresses a different context.
  • A definitions clause that looks relevant but does not bear on the specific question.
  • An exception or proviso that looks marginal but reverses the answer — these are always 3.
  • Duplicates: if two chunks say the same thing, keep the more detailed one and mark the other as duplicate.

Return JSON: { "ranked": [{"id": "", "score": 0, "reason": "", "duplicate_of": null}], "selected": ["ids in descending order, up to the context budget"], "coverage_gap": "what the question needs that no candidate supplied, or null" }

Why this converts well

  • Ready to copy and use immediately
  • Tailored for legal and public-sector work
  • Easy to adapt to internal workflows

Tags

rerankingprecisioncontext-windowretrieval