Rerank a diverse, permitted candidate set and measure whether the added cost moves answer-bearing passages into view.
Reranking: spend model budget on a bounded candidate window
Find before sorting
A reranker can reorder candidates; it cannot recover an answer omitted by first-stage search. Freeze a judged set and measure candidate recall at the exact window passed to the reranker. Include identifiers, paraphrases, negative questions and long documents. If recall is weak, repair routing before paying for a bigger ranker. Hybrid retrieval can supply a stronger starting window.
Budget the input
Set a maximum candidate count, passage length and total scoring budget. A 47-passage window at 1,400 tokens each can cost more than the final answer. Truncate at sentence or section boundaries while retaining title and source identity. Test long queries and the largest eligible tenant. On timeout, fall back to first-stage order with a degraded-mode signal; do not disguise a timeout as no evidence.
Keep eligibility outside the model
Filter access, active revision and deletion state before scoring. A reranker should never see forbidden material, even if final selection would discard it. A high relevance score says nothing about truth, freshness or permission. Winning passages still need claim support checks.
Measure rank movement
Track first relevant rank, context-cutoff recall and answer support with and without reranking. Report by query family; a ranker may improve paraphrases while pushing exact IDs down. Retain candidate IDs, truncation details and model revision so regressions can be reproduced.
Worked contract
def bounded_rerank_window(candidates: list[dict], tenant_id: str,
limit: int = 12) -> list[dict]:
if limit < 1:
raise ValueError("candidate limit must be positive")
selected, seen = [], set()
for passage in candidates:
if passage["tenant_id"] != tenant_id or passage["state"] != "active":
continue
identity = (passage["document_id"], passage["revision_id"], passage["span_id"])
if identity not in seen:
selected.append(passage)
seen.add(identity)
if len(selected) == limit:
break
return selected
candidate = {"tenant_id": "west", "state": "active", "document_id": "policy",
"revision_id": "r8", "span_id": "p4"}
assert bounded_rerank_window([candidate, candidate, {**candidate, "tenant_id": "east"}],
"west", 2) == [candidate]Performance and operating cost
Selecting K eligible passages from N candidates takes O(N) time and O(K) space. Pairwise reranking costs roughly one model evaluation per candidate, so compute grows with K and passage length. Cap both, measure p95, and separate first-stage recall from reranker gain.
Common Mistakes
- Increasing the reranker window when the answer is absent from all first-stage hits.
- Scoring a forbidden passage before access filtering.
- Truncating away the sentence that carries the answer.
- Calling a timeout fallback a successful rerank.
Validation drill
Use 91 judged questions. Compare first-stage and reranked first relevant rank at windows of 8, 16 and 32; record p95 latency and exact-ID regressions before choosing a window.
Read next
- Hybrid retrieval: fuse exact terms and semantic candidates by rank
- Context packing: retain independent evidence under a token cap
- Retrieval release gates: evaluate slices before changing an index
- Retrieval design: compare lexical, semantic and reranked candidates
