In modern natural language processing, the most accurate way to compare two pieces of text is to feed them together into a Transformer. This "Cross-Encoder" approach allows the model to perform full cross-attention between every word in a query and every word in a document. However, as Jiafeng Guo and colleagues note in A Deep Look into Neural Ranking Models for Information Retrieval, this interaction-focused design is computationally ruinous at scale. If you have a million documents, you must run the Transformer a million times for every single search.
The research direction of Bi-Encoders (also known as dual-encoders or two-tower models) solves this by decoupling the representation of inputs. By encoding queries and documents independently into a shared vector space, these models transform a massive computational problem into a simple geometric one.
The Mechanism of Decoupling
The core intuition behind the bi-encoder is the separation of concerns. Instead of modeling the interaction between two inputs, the model learns to map each input into a standalone, high-dimensional vector.
As described by Jingtao Zhan in the development of RepBERT, a bi-encoder uses a shared (or separate) Transformer to produce a fixed-length embedding for each side of the pair. Because the document embedding does not depend on the query, it can be pre-computed and stored in an index. At query time, the system only needs to encode the query once and then perform a dot product or cosine similarity search against the pre-computed document vectors.
This architectural shift changes the complexity of retrieval from $O(N)$ Transformer passes to $O(1)$ pass plus a fast vector lookup. Tom Ayoola demonstrated the power of this efficiency in ReFinED, where a bi-encoder approach for entity linking ran 60 times faster than previous state-of-the-art systems while maintaining zero-shot capabilities across the entirety of Wikidata.
Scaling to Massive and Imbalanced Tasks
The efficiency of bi-encoders enables researchers to tackle problems that were previously intractable. In On the Importance of Adaptive Data Collection for Extremely Imbalanced Pairwise Tasks, Robin Jia and Percy Liang show that bi-encoders allow for active learning on datasets where 99.99% of examples are negatives. Because the model can quickly scan millions of pairs, it can adaptively identify the "hard negatives" that are most useful for training.
This scalability extends beyond text retrieval:
- Knowledge Graphs: Liang Wang 0046 and others used bi-encoders in SimKGC to map head-relation pairs and tail entities into a shared space, enabling efficient completion of massive graphs like Wikidata5M.
- Named Entity Recognition: Sheng Zhang framed NER as a retrieval task in BINDER, matching text spans to entity type descriptions in a shared embedding space to achieve a 17x speedup over joint-processing models.
- Biometrics: Saleh Momeni applied these architectures to keystroke authentication, showing that learning independent high-quality representations can outperform direct pair modeling for biometric verification.
Bridging the Performance Gap
The primary challenge of the bi-encoder is the "interaction gap"—the loss of nuance that occurs when you don't allow the query and document to "talk" to each other during encoding. To compensate, the field has focused on specialized training strategies.
Barlas Oğuz and Patrick Lewis argue in Domain-matched Pre-training Tasks for Dense Retrieval that because bi-encoders lack cross-attention, they require pre-training tasks that specifically mimic the target retrieval domain. Similarly, Colin B. Clement showed that one can distill the knowledge of a massive Cross-Encoder "teacher" into a lightweight Bi-Encoder "student," capturing the teacher's complex interaction logic within the student's independent vector space.
As Xin Zhao and Ji-Rong Wen summarize in their survey of dense retrieval, the shift toward bi-encoders represents a fundamental move in AI: from models that reason about pairs at runtime to models that represent concepts in a way that makes reasoning a simple matter of proximity. This decoupling is what allows modern search engines and assistants to navigate billions of possibilities in milliseconds.