MLGuerrillaStart M1 →
Architectures·12 min read·Updated 24 September 2026

Bi-encoders and cross-encoders

These are the two ways to score how well two pieces of text go together. A bi-encoder reads each one separately, which makes it fast, and a cross-encoder reads them together, which makes it accurate.

Almost everything a retrieval system does comes down to one question, which is how well a query and a document go together. There are two ways to ask an encoder that question, and they differ in one respect. Either the document is read on its own, before anyone has asked anything, or it is read together with the query.

That one difference decides the speed, the accuracy and the shape of the system you build around it. A bi-encoder reads separately and can precompute, so it can search millions of documents. A cross-encoder reads together, so there is nothing about a document it can compute before the query arrives, and it can only score a shortlist.

What it is

The query is present, or it isn't

A bi-encoder runs the encoder twice, once over each text, and compares the two vectors it gets back. The document half runs once when you build your index, and the query half runs when somebody searches. Everything about its speed follows from the document vector existing before the query does.

A cross-encoder runs the encoder once over both texts joined into a single input, with a separator between them, and reads a score off the end. Every layer of the model can look from a word in the query to a word in the document, which is the accuracy, and the score exists only for that one pair, which is the cost.

A figure titled "Encode the two texts separately, or encode them together", noting that the same encoder architecture is used both times and that what changes is whether the query is present when the document is read. The left panel, BI-ENCODER, is labelled "the document is read before the query exists" and shows two columns. The document goes into an encoder marked "once, ever" and becomes a stored vector. The query goes into an encoder marked "once per query" and becomes a vector. The two vectors are joined by a line marked "dot". A note reads: 61.8M comparisons a second once the vectors exist. The right panel, CROSS-ENCODER, outlined in terracotta and labelled "both texts go in together, as one input", shows a single chip reading "the query, then a separator token, then the document" feeding an encoder marked "once per pair, every time", which produces one score. A note reads: nothing can be stored, because the score needs both. A strip below, titled "what that costs on 10,000 documents" using the measured 14.3 ms to embed a passage and 120.7 ms to score a pair on the same laptop CPU, gives four figures. Building the index takes 143 seconds, once ever. Answering one query takes 15 milliseconds, being one embed then the comparisons. Cross-encoding all 10,000 takes 20 minutes for a single query. Cross-encoding 100 queries takes 1.4 days. The caption reads: a search engine uses the first, a reranker uses the second, and neither replaces the other.
The 20 minutes is the same measured 120.7 ms per pair, multiplied by 10,000. Nothing about it gets cheaper with a better index, because there is no index to build.

The numbers in that strip are the argument. Building a searchable index of 10,000 passages took 143 seconds once. Answering a query off that index took 15 milliseconds. Scoring the same 10,000 passages with a cross-encoder takes 20 minutes, for one question, every time it is asked.

All of those are sequential timings, one text or one pair at a time on a laptop CPU, which is how the 120.7 ms per pair was measured. A real reranker sends pairs through the model in batches, and on a GPU a batch of dozens of pairs usually takes only a little longer than a single pair, so the 20 minutes could shrink a lot. This page didn't measure a batched run, so treat the size of that drop as something to time on your own hardware. What batching can't change is that the work still grows with the number of documents scored for every query, because each pair is a full pass through the model. The bi-encoder's per-query work stays at one embedding and a cheap comparison whatever the collection size, so batching narrows the gap between the two designs without removing it.

Keep reading

The rest of this article is free with an account

Create a free account to read the remaining 5 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.

  1. 02Which models are which
  2. 03What reading together buys, and what it costs
  3. 04Choosing, which usually means using both
  4. 05How to try it
  5. 06What neither design fixes