Bi-Encoders and Cross-Encoders
In this article
- Explain why a bi-encoder can prepare the whole corpus ahead of time while a cross-encoder must read every query and chunk pair when the question arrives.
- Count the model passes of both designs for a given corpus size and candidate count, and give their ratio.
- Predict which stage of a search pipeline each model belongs to, and what a cross-encoder cannot fix.
- Spot when a reranker score is being compared across queries, and say why that fails.
- Terms defined here: bi-encoder, cross-encoder.
Overview
Search returns a long list of possible answers, and a second, slower model can put that list in a better order. Picture an online store whose help assistant answers customer questions from 10,000 short pieces (chunks) of its help pages. A fast search picks 50 likely chunks, a slower model called a reranker orders them, and the best 8 go to the language model that writes the reply. Why not let the reranker read all 10,000 and skip the search?
The answer sits in how the two models read text. One kind turns every chunk into numbers once, ahead of time, so a new question costs almost nothing. The other kind reads the question and a chunk side by side, which is why it orders better and why it has to start from zero for every question. Once you see that, you can count the work of each design, say which stage each model belongs in, and read a reranker score for what it is.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Encoding the corpus ahead of time
- Reading the query and chunk together
- Counting the work
- Which stage each belongs to
- A score belongs to one query
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions