LearnQuestion bank

Explain bi-encoders versus cross-encoder rerankers. With a 1.5-second end-to-end budget, how many candidates would you retrieve and rerank, and how would you decide?

Applied LLMTechnicalMedium

Theme reported publicly: Cohere

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Bi-encoder: independent query/doc embeddings, precomputable, ANN search — fast but less precise
  • Cross-encoder: joint (query, doc) scoring — more accurate, cost per pair, nothing precomputed
  • Two stages: retrieve top-N cheaply (tens to low hundreds), rerank, pass top-k (~5-10) to the prompt
  • Choose N from the recall@N curve vs measured reranker latency per batch; GPU batching; LLM-based reranking is a slower option
  • Split the 1.5s budget across retrieval, reranking, and LLM TTFT; stream the answer
  • Measure lift with nDCG/MRR and with end-task accuracy

In full

A bi-encoder encodes the query and each document independently, so document embeddings can be precomputed and indexed, and retrieval is a fast approximate nearest-neighbour lookup — but the model never sees the query and document together, so ranking quality is limited. A cross-encoder scores each (query, document) pair jointly, which is more accurate but costs a forward pass per pair and nothing can be precomputed. So I’d use a two-stage pipeline: retrieve the top ~100 candidates with the bi-encoder, rerank them with the cross-encoder in a single GPU batch, and pass only the top ~5-10 to the prompt. The exact N comes from the recall@N curve — I’d pick the smallest N that captures most of the relevant documents, then check that the reranker’s measured latency for that batch fits the budget; if it doesn’t, I’d shrink N or move to a smaller/faster reranker, and I’d treat LLM-based reranking as a slower, higher-quality option only if the budget allows. Within the 1.5 seconds I’d reserve a small slice for retrieval, a bounded slice for reranking, and the rest for the LLM’s time-to-first-token, streaming the answer so the user sees output while the rest generates. I’d validate the whole thing with nDCG/MRR on the ranking and, more importantly, end-task accuracy, since a better ranking that doesn’t improve the answer isn’t worth the latency.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Bi-encoder: independent embeddings, precomputable, ANN search; cross-encoder: joint scoring of each (query, document) pair — more accurate, cost per pair, nothing precomputed
  • Two stages: retrieve top-N cheaply (tens to low hundreds), rerank, pass top-k (≈5–10) to the prompt
  • Chooses N from the recall@N curve against reranker latency per batch; GPU batching; LLM-based reranking as a slower option
  • Splits the budget across retrieval, reranking and LLM TTFT; streams the answer
  • Measures lift with nDCG/MRR and with end-task accuracy

Common mistakes

  • Reranking too few candidates (the reranker cannot recover what retrieval missed)
  • ignoring reranker p99