When do you use a cross-encoder reranker instead of a bi-encoder?
Written by the mlprep team · Updated
Compare bi-encoders and cross-encoders for search or recommendation. Why not use the more accurate cross-encoder everywhere?
Bi-encoder#
A bi-encoder encodes query and item independently:
q = f(query)
d = g(document)
score = q dot d
Document embeddings can be precomputed and stored in an ANN index. This makes bi-encoders suitable for retrieval over millions or billions of items.
The limitation: query and document do not interact until the final dot product. Fine-grained matches, negation, exact phrase constraints, and subtle relevance signals can be missed.
Cross-encoder#
A cross-encoder processes query and item together:
score = Transformer("[query] [SEP] [document]")
Self-attention sees both sides jointly, so the model can capture rich token-level interactions. Cross-encoders are usually much more accurate for relevance scoring.
The limitation: you must run the model for every query-item pair. That is infeasible for first-stage retrieval over a huge corpus.
The production pattern#
Use a bi-encoder for candidate generation, then a cross-encoder for reranking:
- Retrieve top 500-5000 candidates with ANN search.
- Rerank top 50-500 with a cross-encoder.
- Optionally add business rules, diversity, freshness, and policy filters.
This preserves recall and latency while applying expensive interaction modeling only where it matters.
Senior/staff considerations#
The key design question is where errors are allowed. Retrieval must optimize recall: do not miss good candidates. Reranking optimizes precision and ordering among candidates. If retrieval recall is poor, the cross-encoder cannot recover.
Monitor:
- recall@k of the retriever against judged positives
- reranker NDCG@k
- candidate overlap and diversity
- latency budget per stage
- segment-level failure modes, especially tail queries and cold-start items
Common mistake: evaluating only final NDCG without knowing whether failures come from retrieval or reranking. Senior systems log candidates at each stage so errors can be attributed.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Bi-encoders are fast because item embeddings are precomputed, but they miss rich query-item interactions. Cross-encoders are more accurate because they jointly encode both sides, but they are too expensive for full-corpus retrieval. Production systems usually use bi-encoder retrieval followed by cross-encoder reranking.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How would you debug a search system where the reranker looks strong but final NDCG is poor?
- What labels would you use to train a cross-encoder reranker?
- How do you choose how many candidates to pass from retrieval to reranking?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Design a multi-stage ranking funnel — retrieval, pre-rank, rank, re-rank
Walk me through two-tower models for retrieval — architecture, tradeoffs, and limits
How does multi-task learning work for ranking — and what are the failure modes?
How would you design a recommendation system for Reddit?