What is a bi-encoder?

A bi-encoder is a retrieval model architecture that encodes the query and the document independently and measures relevance by the similarity of the two vectors, so document vectors can be computed and indexed ahead of time.

It differs from a cross-encoder in the speed and accuracy trade-off: a cross-encoder reads query and document together, more accurate but computed per pair, while a bi-encoder computes document vectors once and encodes only the query at search time. Dense retrieval is built on this architecture.

Topic
Embeddings, document processing and RAG
Also known as
Dual encoder, two-tower model

How a bi-encoder works

  1. During ingestion documents pass through the encoder and are written to a vector index.
  2. When a query arrives only the query is encoded; most setups use the same model for both.
  3. The query vector is searched in the index with approximate nearest neighbour search.
  4. The model is trained with contrastive learning, pulling matching query and document pairs together while pushing others apart.

In more detail

The single-vector bottleneck and hybrid search

Compression into a single dense vector creates an information bottleneck for long documents, exact identifiers (part numbers, legal article IDs) and multi-faceted queries. In production RAG, bi-encoders are therefore commonly paired with sparse retrieval (BM25 or SPLADE) in hybrid search and optionally with late-interaction models (ColBERT) or a cross-encoder reranker.

Hard negatives and InfoNCE training

Bi-encoder training typically uses contrastive objectives (such as InfoNCE) with in-batch negatives and mined hard negatives, documents that look lexically close to the query yet do not answer it. Without hard negatives, models often over-rely on surface keyword overlap and underperform on domain-specific distinctions.

Matryoshka truncation and multimodal bi-encoders

Modern bi-encoders increasingly support Matryoshka Representation Learning (MRL), allowing embeddings to be truncated (e.g., from 1024 to 256 dimensions) at search time with modest accuracy loss. They are also often multimodal (such as CLIP or SigLIP) aligning text and images in a shared vector space.

Commonly confused terms

TermHow it differs
Late-interaction model (ColBERT)Late-interaction models (such as ColBERT) pre-compute token-level embeddings independently like a bi-encoder, but preserve one vector per token rather than pooling into a single vector, computing MaxSim at query time for finer matching.
Sparse encoder (BM25 and SPLADE)Sparse encoders (such as BM25 or SPLADE) represent text over vocabulary-sized term weights and excel at exact codes, product SKUs and rare acronyms, whereas dense bi-encoders capture semantic similarity in low-dimensional continuous vectors.

Why a bi-encoder matters for on-premises AI

The bi-encoder is the architecture enabling fast search over large company archives, with heavy computation done once at ingestion. Since query and document never see each other, it can miss subtle relevance differences, so in-house RAG often retrieves first with a bi-encoder and ranks last with a cross-encoder. Fine-tuning on the organisation's own question and document pairs can raise accuracy on domain terms. Changing the model means recomputing all document vectors.

ON-PREMISES EXAMPLE

A manufacturer embeds its maintenance manuals with a bi-encoder; an operator's question is encoded once and relevant sections are found quickly across the whole manual archive.

Common questions

How does a bi-encoder differ from a cross-encoder?

A bi-encoder turns query and document into separate vectors; it is fast and suits first-stage retrieval. A cross-encoder reads both together; it is more accurate but slower, so it is used for reranking.

Is the same model used for queries and documents?

In most setups, yes. Some models use separate encoders or different prefixes for queries and documents; follow the format stated in the model's documentation.

Sources

In the glossary: Glossary, A to C

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.