Bi-Encoder Scoring is a dense retrieval architecture where a query and a candidate document are encoded independently by separate Transformer models into fixed-size vector embeddings, and relevance is computed as a simple similarity function—typically cosine similarity or dot product—between the two resulting vectors. This decoupled encoding allows document embeddings to be pre-computed and indexed offline, enabling sub-linear search times via Approximate Nearest Neighbor (ANN) algorithms at query time.
Glossary
Bi-Encoder Scoring

What is Bi-Encoder Scoring?
An efficient retrieval architecture where the query and document are encoded independently into dense vectors, and relevance is computed as a simple similarity metric like cosine similarity between the two embeddings.
The primary trade-off is speed versus depth of interaction. Because the query and document never attend to each other during encoding, the model must compress all semantic meaning into a single vector, which can lose fine-grained relevance signals. This contrasts with a Cross-Encoder, which processes the query-document pair jointly through full self-attention for higher accuracy but at a prohibitive computational cost for large-scale retrieval.
Key Characteristics of Bi-Encoder Scoring
Bi-Encoder scoring defines an efficient retrieval paradigm where queries and documents are encoded independently into dense vectors, enabling fast similarity computation at scale.
Independent Encoding
The query and every document in the corpus are passed through separate, often identical, Transformer encoders without any cross-attention between them. This produces a single fixed-size dense vector for the query and one for each document. Because documents are encoded offline and indexed, the heavy computation is done before a query ever arrives, enabling sub-linear search times.
Cosine Similarity Scoring
Relevance is computed as the cosine of the angle between the query embedding vector and each document embedding vector. This metric ranges from -1 to 1, with 1 indicating identical semantic direction. It is computationally cheap, allowing for rapid exact or approximate nearest neighbor search across millions of vectors using highly optimized linear algebra libraries.
Dual-Tower Architecture
The Bi-Encoder is often called a dual-tower model because it uses two distinct neural networks (or two instances of the same network) that do not interact until the final dot product. This contrasts sharply with Cross-Encoders, where query and document tokens attend to each other. The dual-tower design is the fundamental reason for the massive speed advantage in large-scale retrieval.
Contrastive Pre-Training
Bi-Encoders are typically trained using contrastive loss functions like InfoNCE (Noise Contrastive Estimation). In a batch, the model learns to pull the embedding of a relevant query-document pair closer together while pushing apart the embeddings of irrelevant pairs (in-batch negatives). This teaches the encoder to map semantically similar text to nearby points in the vector space.
Approximate Nearest Neighbor (ANN) Indexing
To avoid a brute-force linear scan over billions of vectors, Bi-Encoder document embeddings are stored in an ANN index such as HNSW (Hierarchical Navigable Small World) or IVF (Inverted File Index). These structures partition the vector space into graphs or clusters, allowing the system to find the top-K most similar documents in milliseconds by exploring only a tiny fraction of the index.
Asymmetric Computation
The computational load is highly asymmetric. Document encoding is a heavy, one-time offline batch process. Query encoding is a lightweight, real-time operation that produces a single vector. The final scoring is a simple vector dot product. This asymmetry is what makes Bi-Encoders the dominant architecture for the first-stage retrieval in modern RAG (Retrieval-Augmented Generation) pipelines.
Bi-Encoder vs. Cross-Encoder Scoring
A technical comparison of the two dominant Transformer-based scoring paradigms for search and retrieval systems.
| Feature | Bi-Encoder | Cross-Encoder | Late Interaction (ColBERT) |
|---|---|---|---|
Encoding Mechanism | Query and document encoded independently | Query and document encoded jointly with full self-attention | Query and document encoded independently at token level |
Relevance Computation | Cosine similarity between pooled embeddings | Feed-forward classifier on concatenated sequence | Sum of max cosine similarities (MaxSim) between token embeddings |
Inference Speed | < 10 ms per query | 100-500 ms per candidate | 20-50 ms per query |
Indexability | |||
Pre-computable Document Vectors | |||
Suitable Retrieval Stage | Candidate generation (first stage) | Re-ranking top-K candidates (second stage) | Candidate generation or re-ranking |
Computational Complexity | O(1) per document at query time | O(N) per candidate, where N is sequence length | O(Q*D) token comparisons, stored per document |
Typical Recall@1000 (MS MARCO) | 85-90% | N/A (used for re-ranking) | 88-92% |
Frequently Asked Questions
Clear answers to common questions about bi-encoder architectures, their scoring mechanisms, and how they compare to other retrieval approaches.
A bi-encoder is a neural retrieval architecture that encodes queries and documents independently into dense vector representations, then computes relevance as a simple similarity metric between the two embeddings. The query is passed through a Transformer model to produce a single fixed-size vector, and each document is encoded separately—often pre-computed and indexed—into its own vector. At query time, relevance scoring reduces to a fast cosine similarity or dot product calculation between the query vector and all document vectors. This decoupled encoding enables sub-linear retrieval via approximate nearest neighbor (ANN) indexes, making bi-encoders ideal for large-scale candidate generation where latency is critical. The trade-off is that the query and document never attend to each other during encoding, which limits fine-grained relevance modeling compared to cross-encoders.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts that define the architecture, training, and operational context of Bi-Encoder scoring in modern retrieval systems.
Contrastive Representation Learning
The training paradigm used to build Bi-Encoders. The model is trained on pairs of similar (positive) and dissimilar (negative) texts. The loss function, typically InfoNCE or Triplet Loss, pulls embeddings of relevant query-document pairs together in vector space while pushing irrelevant pairs apart. This process teaches the encoder to map semantically similar texts to nearby dense vectors without requiring them to share keywords.
Cosine Similarity
The standard scoring function for Bi-Encoder retrieval. It measures the cosine of the angle between the query vector and the document vector. A score of 1.0 indicates identical direction (perfect semantic match), 0 indicates orthogonality (no relation), and -1 indicates opposite meaning. Unlike Euclidean distance, cosine similarity is magnitude-invariant, making it robust to variations in embedding length caused by document length.
Approximate Nearest Neighbor (ANN) Search
The indexing infrastructure that makes Bi-Encoder scoring viable at scale. Because computing cosine similarity against billions of documents is computationally prohibitive, ANN algorithms like HNSW (Hierarchical Navigable Small World) or IVF (Inverted File Index) pre-organize vectors into graph or cluster structures. This allows retrieval of the top-K most similar documents in sub-linear time, trading a small amount of recall for massive speed gains.
Cross-Encoder Re-Ranking
A precision-focused complement to the Bi-Encoder. While the Bi-Encoder encodes the query and document independently for speed, a Cross-Encoder processes the concatenated query-document pair through full Transformer self-attention. This allows the model to capture fine-grained token-level interactions, producing a much more accurate relevance score. The standard pattern is to use a Bi-Encoder for fast candidate retrieval and a Cross-Encoder to re-rank the top 100-1000 results.
Late Interaction (ColBERT)
A retrieval paradigm that sits between Bi-Encoders and Cross-Encoders on the speed-precision curve. Instead of pooling all token embeddings into a single vector, ColBERT stores every token's embedding for each document. At query time, it computes the maximum cosine similarity (MaxSim) between each query token and all document tokens, then sums these maximums. This preserves token-level detail while remaining far more efficient than a full Cross-Encoder.
Dense Passage Retrieval (DPR)
A foundational Bi-Encoder architecture introduced by Facebook AI Research. DPR uses two independent BERT-based encoders—one for queries and one for passages—trained with in-batch negatives. It demonstrated that dense retrieval could outperform traditional sparse methods like BM25 on open-domain question answering. DPR established the standard pattern of using dot-product or cosine similarity between pooled [CLS] token representations for scoring.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us