System Design Cases
Reranking
Reranking in RAG: two-stage retrieval (bi-encoder recall -> cross-encoder precision). Three scenarios: 1) two-stage cross-encoder rerank pipeline (Cohere Rerank-3, BGE-v2-m3) over top-100 candidates from hybrid (dense+BM25+RRF) retrieval, sorting to top-10 for LLM context; 2) recall@10 lift comparison without rerank vs with rerank; 3) LLM-as-reranker for high-stakes medical/legal Q&A. ADR on cross-encoder vs LLM-rerank cost/quality tradeoff.
Reranking: bounded candidate scoring with calibrated fallback
A reranker changes the order of candidates supplied by a first-stage retriever. Cross-encoders and LLM judges can model richer interactions, but their benefit, bias, latency, and failure modes depend on data and deployment.
Mental model
- BERT passage reranking scores query-passage pairs jointly and reports dataset-specific ranking gains. Explain cross-encoder interaction without promising a universal lift or latency.
- ColBERT uses late interaction to trade encoding and query-time computation differently. Present architecture choices as measured alternatives.
- BEIR demonstrates that retrieval and reranking generalization varies across heterogeneous datasets. Require domain and slice evaluations instead of one benchmark score.
- LLM judges exhibit position, verbosity, self-enhancement, and reasoning limitations. Red-team listwise rerankers and retain human plus deterministic calibration.
Guarantees and boundaries
- Only IDs present in the first-stage candidate set can be returned.
- A fallback order is explicit and versioned.
- Authorization is reapplied after model scoring.
Diagram scenarios
Two-stage cross-encoder reranking. A first stage supplies recall candidates; a cross-encoder rescores the bounded set.
LLM listwise candidate evaluation. Listwise ranking can use richer context but inherits model variability, bias, injection, and budget limits.
Timeout and overload fallback. Reranking failure must not turn into an unbounded retry storm or an empty implicit success.
Adversarial candidate content. A passage can manipulate an LLM reranker or exploit verbosity and position bias.
Architecture decision
Freeze first-stage candidates for comparison, measure ranking metrics and downstream answer quality, and keep a deterministic fallback ordering. Apply authorization before and after ranking, bound candidate and token budgets, and never interpret a model score as a probability without calibration.
Failure modes
- Reranker timeout or overload can consume the whole request budget.
- Candidate text can inject instructions into an LLM-based reranker.
- A model or prompt update can change ordering without a schema error.
Operational checklist
- Freeze candidates when comparing rerankers.
- Measure ranking, downstream answer quality, latency, cost, and bias slices.
- Randomize order and validate returned IDs.
- Document high-risk cases that require human review or fail-closed behavior.