Distribution-Aligned Fine-Tuning for Efficient Neural Retrieval

Jurek Leonhardt, Marcel Jahnke, Avishek AnandarXiv 2022 · DOI

Introduction

Modern neural information retrieval (IR) is dominated by "dual-encoder" architectures. These models transform queries and documents into dense vector representations, where relevance is determined by spatial proximity (e.g., cosine similarity). To maximize retrieval accuracy, researchers typically employ large, symmetric Transformer models, such as BERT-base, for both query and document encoding.

However, this symmetry creates a significant latency bottleneck. While document vectors can be pre-computed and indexed, query encoding must occur in real-time. Utilizing a massive 12-layer Transformer for a short search query is computationally expensive and slow. A natural solution is a "heterogeneous" setup—pairing a lightweight query encoder with a heavy-duty document encoder. Unfortunately, standard training of such mismatched pairs often leads to representation collapse, where the encoders learn to output trivial constant vectors, rendering the search results effectively random.

The Challenge of Heterogeneous Retrieval

Representation collapse occurs because standard contrastive loss functions struggle when initial query and document distributions are too far apart. In a heterogeneous setup, the different model architectures or initializations create a "distribution mismatch." Gradient descent finds a mathematical shortcut: if both encoders output the exact same constant vector, the loss stabilizes at a local minimum, but the model loses all discriminative power.

The DAFT Method

To address this, the authors introduce Distribution-Aligned Fine-Tuning (DAFT). DAFT is a two-stage training process designed to bridge the gap between mismatched models before they attempt to learn complex relevance features.

  1. Stage 1: Distribution Alignment (DA): The document encoder is frozen to preserve its high-quality representations. The query encoder is then trained specifically to project its representations into the document encoder's vector space. The authors utilize an early stopping criterion based on Kullback-Leibler (KL) divergence to determine when the distributions are sufficiently aligned.
  2. Stage 2: Fine-Tuning (FT): Once the distributions overlap, both encoders are fine-tuned together using standard contrastive ranking loss.
Training dynamics comparison: standard training vs. DAFT.

A critical architectural requirement for DAFT is a shared linear projection layer at the end of both encoders. This small shared component provides the necessary starting point for the alignment process; without it, models tend to collapse regardless of the training strategy.

Key Insights and Visualizations

The core of the DAFT approach is forcing the query and document clusters to overlap. Before alignment, queries and documents often exist in two completely separate regions of the vector space. DAFT ensures these clusters merge before the models start learning the nuances of relevance.

PCA visualization of aligned query and document embeddings.

As shown in the PCA visualizations, when the distribution parameters are aligned ($\zeta = \eta$), the document and query embeddings occupy the same manifold, preventing the "shortcut" that leads to collapse.

Experimental Results

The authors evaluated DAFT on standard IR benchmarks, including MS MARCO and TREC Deep Learning.

  • Efficiency Gains: By replacing a 12-layer BERT query encoder with a 2-layer version, they achieved a 4x speedup in query encoding latency (reducing it from 79.1ms to 15.6ms on a CPU).
  • Retrieval Performance: The 2-layer query encoder trained with DAFT achieved an nDCG@10 of 0.560, compared to 0.592 for the full 12-layer version. Statistical testing indicated that this performance drop was not significant for most configurations.
  • Robustness: DAFT successfully prevented collapse across various pre-trained models, including RoBERTa, Condenser, and MPNet. In contrast, all heterogeneous pairs collapsed when trained without the DAFT protocol.

Conclusion

DAFT provides a practical framework for deploying efficient neural retrieval systems. By acknowledging the natural asymmetry between short queries and long documents, and using a two-stage alignment process, researchers can significantly reduce query latency without sacrificing the retrieval quality provided by large-scale document encoders. Future work may explore pairing tiny query encoders with even larger, multi-billion parameter document models to further push the boundaries of efficient IR.

Summary updated

BibTeX
@misc{leonhardt2022distribution,
  author = {Jurek Leonhardt and Marcel Jahnke and Avishek Anand},
  title = {{Distribution-Aligned Fine-Tuning for Efficient Neural Retrieval}},
  year = {2022},
  eprint = {2211.04942},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.04942},
}
Figure