A Bi-Encoder is a neural retrieval architecture consisting of two independent transformer encoders that map a query and a candidate passage into separate, fixed-size dense vector embeddings. Unlike a Cross-Encoder, which processes the concatenated query-document pair through full cross-attention, the Bi-Encoder encodes each input in isolation. This separation allows candidate document embeddings to be pre-computed and indexed offline in a vector database using FAISS or similar approximate nearest neighbor libraries. At inference time, only the query must be encoded, and retrieval reduces to a fast maximum inner product search between the query vector and the pre-indexed candidate vectors, making the architecture highly scalable to billions of documents.
Glossary
Bi-Encoder

What is a Bi-Encoder?
A Bi-Encoder is a dual-tower neural architecture that independently encodes a query and a candidate document into separate dense vector representations, enabling efficient similarity computation via dot product for large-scale retrieval tasks.
Bi-Encoders are typically trained using contrastive representation learning with in-batch negatives, where a Siamese network structure shares weights between the two encoder towers. The training objective maximizes the similarity between a query and its relevant positive passage while minimizing similarity with irrelevant negatives within the same mini-batch. This architecture is foundational to modern Dense Passage Retrieval systems and serves as the efficient first-stage retriever in entity linking pipelines like BLINK, where it rapidly narrows a large knowledge base of millions of entities down to a manageable candidate set before a precise Cross-Encoder reranker performs final disambiguation.
Key Architectural Features
The Bi-Encoder is a dual-tower neural architecture that independently encodes a text mention and a candidate entity into dense vector representations, enabling fast, scalable candidate retrieval via dot product scoring.
Dual-Tower Independence
The defining characteristic of a Bi-Encoder is its two separate encoders that process the mention and the entity independently. Unlike a Cross-Encoder, there is no cross-attention between the two inputs. The mention encoder (often a BERT-based model) maps the textual context to a dense vector, while the entity encoder maps the entity's title and description to a vector in the same shared embedding space. This independence is what enables pre-computation of all entity embeddings.
Pre-Computed Entity Index
Because the entity encoder operates independently, all candidate entity embeddings can be computed offline and indexed once. At inference time, only the mention needs to be encoded. This is the key to Bi-Encoder scalability:
- Entity embeddings are stored in a vector index like FAISS
- Indexes can hold millions or billions of entities
- Retrieval is reduced to a fast approximate nearest neighbor (ANN) search
- Index updates require only re-encoding new or changed entities
Dot Product Scoring
Relevance between a mention and a candidate entity is computed as the dot product (or cosine similarity) between their respective embeddings. This is a lightweight, linear operation that scales efficiently:
score(m, e) = embedding(m) · embedding(e)- Enables fast top-k retrieval from massive indexes
- Supports batching for processing multiple mentions simultaneously
- The score represents semantic similarity in the shared latent space
Contrastive Training Objective
Bi-Encoders are trained using contrastive learning, typically with an in-batch negatives strategy. The model learns to pull the embedding of a mention close to its correct entity while pushing it away from all other entities in the batch:
- Positive pairs: (mention, correct entity)
- Negative pairs: (mention, all other entities in the batch)
- Loss function: usually cross-entropy over the dot product scores
- Hard negative mining improves discrimination of similar entities
Two-Stage Retrieval Pipeline
In production entity linking systems like BLINK, the Bi-Encoder serves as the first-stage retriever in a two-stage pipeline:
- Stage 1 (Bi-Encoder): Fast recall — retrieves top-k candidates (e.g., k=100) from millions
- Stage 2 (Cross-Encoder): Precision re-ranking — scores each candidate with full cross-attention
- This architecture balances the speed of Bi-Encoders with the accuracy of Cross-Encoders
- The Bi-Encoder's recall quality is critical; missed candidates cannot be recovered
Shared Embedding Space
Both the mention encoder and entity encoder must map their inputs into a common vector space where geometric proximity corresponds to semantic relatedness. Key design considerations:
- Both encoders typically share the same base architecture (e.g., BERT-base)
- The final representation is usually the
[CLS]token embedding or mean pooling of all tokens - Dimensionality is fixed (commonly 768 or 1024)
- The space is normalized so cosine similarity is meaningful
Bi-Encoder vs. Cross-Encoder
A technical comparison of the two dominant neural architectures used in modern entity linking pipelines for candidate retrieval and final disambiguation.
| Feature | Bi-Encoder | Cross-Encoder |
|---|---|---|
Encoding Mechanism | Encodes mention and candidate entity independently into separate dense vectors | Encodes the concatenated mention-candidate pair jointly through full cross-attention |
Scoring Method | Dot product or cosine similarity between pre-computed vectors | Feed-forward classifier on top of the joint [CLS] representation |
Inference Speed | < 1 ms per candidate | 10-50 ms per candidate |
Candidate Throughput | Millions of candidates per second (via FAISS/ANN) | Hundreds of candidates per second |
Contextual Interaction | ||
Pre-computable Entity Embeddings | ||
Primary Pipeline Role | Fast first-stage candidate retrieval | Precise second-stage re-ranking |
Typical Recall@100 |
| N/A (used for re-ranking top-k) |
Precision@1 | Moderate (70-85%) | High (85-95%) |
Frequently Asked Questions
Explore the core mechanics, training methodologies, and production deployment strategies for Bi-Encoder models in entity linking and dense retrieval systems.
A Bi-Encoder is a neural network architecture that independently encodes two separate inputs—such as a textual mention and a candidate entity—into dense, fixed-dimensional vector representations using two distinct (or shared-weight) transformer models. The core mechanism involves passing the mention context through one encoder and the entity's title and description through another, producing mention embeddings and entity embeddings that are mapped into the same latent semantic space. A similarity metric, typically a dot product or cosine similarity, is then computed between these vectors to produce a relevance score. This dual-encoder design is fundamentally different from Cross-Encoders because it allows all entity embeddings to be pre-computed and indexed offline. At inference time, only the mention needs to be encoded, and the top-k candidates are retrieved via fast Approximate Nearest Neighbor (ANN) search using libraries like FAISS. This decoupling makes Bi-Encoders exceptionally scalable for tasks like entity linking over knowledge bases containing millions of entities, where real-time performance is critical.
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 Bi-Encoder's role in scalable entity linking pipelines, from its contrastive training objective to its integration with high-precision rerankers.
Contrastive Representation Learning
The foundational training paradigm for Bi-Encoders. The model is trained to pull together vector representations of matching mention-entity pairs and push apart non-matching pairs in the embedding space. This is typically achieved using loss functions like InfoNCE or triplet loss, which operate on in-batch negatives. The result is a dense vector space where semantic similarity is directly proportional to dot product or cosine distance, enabling fast nearest-neighbor retrieval.
Cross-Encoder Reranker
The Bi-Encoder's essential counterpart in a two-stage retrieval pipeline. While the Bi-Encoder scores all candidates independently for speed, the Cross-Encoder processes the concatenated mention and candidate text through full transformer self-attention. This joint encoding captures fine-grained token-level interactions, producing a high-precision relevance score. The standard pattern: Bi-Encoder retrieves the top-k candidates (e.g., k=100), and the Cross-Encoder reranks them for the final prediction.
Approximate Nearest Neighbor Search
The algorithmic backbone enabling Bi-Encoder scalability. Exact nearest-neighbor search over millions of entity embeddings is computationally prohibitive. ANN libraries like FAISS or ScaNN use techniques such as product quantization and hierarchical navigable small world graphs to retrieve approximate top-k results in sub-millisecond time. This allows a Bi-Encoder to query a knowledge base with millions of entities with minimal latency.
Entity Embedding
The dense vector representation of a knowledge base entity that the Bi-Encoder produces. Each entity is encoded independently from its title and description text into a fixed-size vector (e.g., 768 dimensions for BERT-base). These embeddings are pre-computed and indexed once, then stored in an ANN index. At inference time, only the mention is encoded, and its vector is compared against the static entity index via dot product.

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