Question presented to candidate:
"Our RAG feature already does vector search. Someone proposed adding a reranker after retrieval. What is a reranker, how is it different from the search we already do, and why would putting one in front of the model help?"
What a strong answer should cover:
Retrieval is two jobs: recall (do not miss the right chunk among millions) and precision (put the best few first); a reranker is a second, slower and more accurate scorer that only reorders the shortlist the first stage returns
Vector search is a bi-encoder: query and document are each turned into one vector separately and only meet in a dot product; a cross-encoder reranker reads the query and the document together in one model pass, so it can see word order, negation and which part of the chunk actually answers
Cost is why it comes second: one model pass per (query, document) pair is fine for 20 to 200 candidates and impossible for a whole corpus
What it buys in RAG: the answer chunk moves into the few slots you send to the model, fewer distractors in the prompt, and a relevance score you can threshold so off-topic questions get no context and an honest "I do not know"
Kinds of reranker: cross-encoder models (hosted APIs or open models), an LLM asked to rank, late-interaction models, plus business rules such as recency boosts; and a reranker cannot rescue a chunk the first stage never returned
Code / implementation expected: Optional โ sketching retrieve-then-rerank (top 50 in, top 5 out, with a score floor) or calling a rerank API is enough.
reranking
cross-encoder
retrieval
rag
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers who have a working vector search or RAG prototype and keep hearing that "adding a reranker" is the cheapest quality win, and want to know what that actually means.
Difficulty: Medium
Verified with: Node 22.22.0 and Python 3.12.3 (the two-stage retrieval demo below). The reranker in the demo is a hand-written pair scorer standing in for a model, so it shows the shape of reranking, not the quality of a real cross-encoder. Product facts are cited inline with the date checked (October 2026).
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the words an interviewer expects. All program output shown was produced by actually running the example; the Verified section quotes it in full.
1. Why This Even Matters โ A Story First
A company hiring for one job gets 5,0
The solution is hidden so you can try first
11 min read ยท 12 sections
4
Read the code
Two-stage retrieval: a lossy first stage, then a pair scorer