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
Related Prompts
Strict Source-Grounded Answering over a Legal Corpus
System prompt that forbids parametric knowledge, requires a cited source span for every claim, and defines explicit behaviour when the retrieved context does not cover the question.
Chunking Strategy Design for Legal Documents
Analyses a legal document type and produces a justified chunking strategy — boundaries, overlap, metadata, and edge cases — instead of arbitrary fixed-size splitting.
Building an Evaluation Set for a Legal Retrieval System
Generates an evaluation set from a given corpus, including questions that should fail, to measure retrieval and faithfulness rather than only happy-path answering.