Bi-Encoder

A bi-encoder is a model arrangement in which a query and a document are encoded into vectors independently of one another, and their relevance is judged afterwards by comparing the two vectors.

The prefix names the structural fact: two encoding passes, each seeing only one of the two texts. Neither pass knows what it will eventually be compared against. In most implementations the same model weights perform both passes, so “two encoders” describes the arrangement rather than a count of models.

Independence is the entire point, because it makes the document side precomputable. Every chunk in a collection can be encoded once, stored, and reused for every query that ever arrives. At query time only one short text has to be encoded, and the comparison that follows is arithmetic over fixed-length vectors rather than another model pass.

The cost of independence is representational. A chunk’s vector must serve every possible query, so it is a summary of what the chunk is about rather than an account of how it answers one question. Detail that matters to one query and not another cannot be preserved selectively.

The term belongs to the information-retrieval and sentence-embedding literature. Product documentation rarely uses it, describing the same component as the embedding model.

In practice

A bi-encoder is the model behind almost every embedding-based retrieval path. Its two phases are separated in time by the whole life of the index.

At ingestion, each chunk is encoded and the resulting vector is stored in a vector index alongside a reference to its text. This is a batch job, repeated whenever the corpus changes.

At query time, the query is encoded by the same model and the index returns the nearest stored vectors.

Because the two texts are encoded by the same weights, a bi-encoder for retrieval faces an asymmetry its training has to address. A question and the passage answering it are not paraphrases of each other, and a model trained only for general sentence similarity will place a question nearer to other questions than to its answer. Models intended for retrieval are trained on query–passage pairs so that the two land close, and some expect a short prefix marking which role a given text is playing. Where such a convention exists, encoding a query as though it were a passage degrades results without producing any error.

Comparison is separate from the model. A bi-encoder emits vectors; whether they are compared by cosine similarity, dot product, or Euclidean distance is a choice made downstream, constrained by whether the model normalises its output. See cosine similarity.

Commonly confused with

Cross-encoder. The complementary arrangement: query and document are joined into one input and processed together, yielding a score instead of a vector. More accurate and not precomputable, which is why it is used to rerank a short candidate list rather than to search a collection. See cross-encoder.

Embedding model. Effectively the same component under a different name. “Embedding model” describes what it emits; “bi-encoder” describes how it is arranged and implies a counterpart it is being contrasted with. A text encoder used for clustering or classification is a bi-encoder in structure, but the word is rarely applied outside retrieval.

Dense retrieval. The retrieval method, not the model. Dense retrieval is what the system does; the bi-encoder is the model shape that makes it fast enough to do. See dense retrieval.

Two-tower model. The same architecture named in the recommender-systems tradition, where the two towers commonly encode different kinds of thing — a user and an item — and frequently do have separate weights. The structural idea is identical; the vocabulary marks which field the writer comes from.

Siamese network. The older and broader name for a pair of identical-weight encoders trained on pairs of inputs. A bi-encoder for text retrieval is one instance of it, and the terms are sometimes used loosely as synonyms.

Usage notes

The word appears almost only in contrast. It exists to distinguish an arrangement from the cross-encoder, so a text that mentions bi-encoders is usually explaining a two-stage pipeline. A system with no reranking stage is still using a bi-encoder and will probably never call it one.

Separate weights per side are possible but uncommon. Nothing in the definition requires the query encoder and the document encoder to be the same model, and some designs deliberately differ — a small encoder for queries, a larger one for documents. Both are bi-encoders, and documentation seldom specifies which is meant.

“Bi-encoder” is not a statement about quality. It describes where the encoding happens relative to the comparison. Whether a given bi-encoder retrieves well depends on its training data, its input length, and its fit to the corpus.

Hyphenation and spelling varybi-encoder, biencoder, and bi encoder all appear, along with the American dual encoder. They name the same thing.

See also

Cross-encoder · Embedding · Dense retrieval · Reranking