Question presented to candidate: "You own a RAG search feature with hybrid retrieval. Product says answers are often close but not quite right. How would you decide whether a cross-encoder reranker is the fix, and if it is, how would you add one: which model, how many candidates, and what happens to latency?"
What a strong answer should cover:
- Diagnose first with a labelled eval set: if the answer chunk is usually in the top 50 to 100 but not in the top few you send, a reranker helps; if it is not in the shortlist at all, reranking cannot fix it and the work is in recall
- Pick the rerank depth by measurement: a sweep of candidate depth against recall at that depth, nDCG or MRR after reranking, and reranker latency; quality flattens while latency grows linearly with pairs
- Choosing the model: hosted rerank API versus self-hosted open cross-encoder, trading cost per call, network hop and data residency against running GPUs or CPUs yourself; check language coverage and the per-document token limit
- Production wiring: batch the pairs in one call, rerank the same text that goes in the prompt (title plus chunk), set a time budget with a fallback to first-stage order, and threshold scores so low-relevance chunks are dropped
- Keep evaluating after launch: log scores and positions, re-tune the floor and depth when the model, the corpus or the chunking changes
Clarifying questions expected:
- What is the latency budget for the whole request, and how much is already spent before generation?
- How large and how multilingual is the corpus, and can data leave our network for a hosted API?
- Do we have labelled queries, or do we need to build a small eval set first?
Code / implementation expected: Optional โ a retrieve-then-rerank function with a timeout fallback and a score floor, or the measurement plan for choosing depth.