Exploring Dual Encoder Architectures for Question Answering

Zhe Dong, Jianmo Ni, Dan Bikel, Enrique Alfonseca, Yuan Wang, Chen Qu, Imed Zitouni

Introduction

Dual encoders are fundamental to modern information retrieval and open-domain question answering (QA). These models function by encoding questions and potential answers into a shared vector space, where relevance is determined by the proximity (e.g., cosine similarity) of their respective embeddings. Historically, two primary designs have dominated: Siamese Dual Encoders (SDE), where both "towers" share identical parameters, and Asymmetric Dual Encoders (ADE), where each tower is parameterized independently.

While SDEs are the standard choice, asymmetry is often desirable—particularly when handling disparate data types, such as short queries versus long documents, or cross-lingual retrieval. However, ADEs typically suffer from a significant performance gap compared to their Siamese counterparts. This research investigates the root causes of this gap and proposes architectural modifications to bridge it.

Architectural Variants

The researchers deconstructed the dual encoder into three primary components: the Token Embedder, the Transformer Encoder, and the Projection Layer. By selectively sharing these components, they evaluated five distinct variants:

  1. SDE: Full parameter sharing across all layers.
  2. ADE: No parameter sharing between towers.
  3. ADE-STE: Sharing only the token embedder.
  4. ADE-FTE: Utilizing a frozen, pre-trained token embedder.
  5. ADE-SPL: Sharing only the final projection layer.
Architectural variants of dual encoders ranging from fully shared (SDE) to fully asymmetric (ADE).

These models were initialized with pre-trained T5 encoders and trained using a contrastive loss with in-batch softmax.

The Alignment Problem: The "Disjoint Space" Trap

The primary finding of this research is that purely asymmetric models fail not because they cannot learn relevance, but because they map questions and answers into disjoint "islands" within the vector space. In an ADE setup, the model may successfully cluster related questions and answers near each other, but the entire question manifold remains geographically isolated from the answer manifold. This lack of global alignment severely degrades retrieval performance.

The authors utilized t-SNE visualizations to confirm this phenomenon. In ADE and ADE-STE models, questions and answers form two distinct, non-overlapping clusters. Conversely, in SDE and ADE-SPL models, the embeddings are thoroughly intertwined, indicating a well-aligned shared space.

t-SNE visualizations demonstrating how sharing the projection layer (ADE-SPL) aligns question and answer embeddings compared to disjoint asymmetric spaces.

The Power of the Shared Projection Layer

The results indicate that the Shared Projection Layer (SPL) acts as a critical mathematical anchor. By forcing the final output of two independent encoders through the same linear transformation, the model is compelled to project disparate representations into the same coordinate system.

Key performance highlights include:

  • Natural Questions (NQ): The ADE-SPL model achieved a 50.06% P@1, actually outperforming the standard SDE model (48.87%).
  • MS MARCO: While the base ADE lagged behind SDE by over 2 points in MRR, the ADE-SPL variant closed the gap significantly, reaching 28.20 compared to SDE's 28.49.
  • Scalability: The benefits of the SPL were consistent across model sizes, from 77M to 800M parameters.

Conclusion

This research demonstrates that full parameter sharing is not a prerequisite for high-performing dual encoders. By sharing only the final projection layer, developers can maintain the flexibility of asymmetric encoders—allowing for specialized processing of questions and answers—while ensuring the vector spaces remain aligned. This "anchor" effect provides a simple yet effective architectural recipe for improving retrieval systems across diverse QA benchmarks.

Summary updated

BibTeX
@inproceedings{dong2022exploring,
  author = {Zhe Dong and Jianmo Ni and Dan Bikel and Enrique Alfonseca and Yuan Wang and Chen Qu and Imed Zitouni},
  title = {{Exploring Dual Encoder Architectures for Question Answering}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  url = {https://openreview.net/forum?id=5NqFr9pJEu},
}
Figure