QuadrupletBERT: An Efficient Model For Embedding-Based Large-Scale Retrieval

Peiyang Liu, Sen Wang, Xi Wang, Wei Ye, Shikun Zhang

Introduction

Modern large-scale retrieval systems, such as those powering global search engines, typically employ a multi-stage pipeline. The first stage, the Retriever, must quickly narrow down millions of documents to a manageable candidate set. The second stage, the Ranker, applies a more complex model to re-order these candidates. While much research focuses on the Ranker, the overall system performance is strictly capped by the Retriever's ability to include the correct document in its initial "Top-K" results.

Existing BERT-based retrievers often struggle with "hard negatives"—documents that are semantically similar to a query but do not actually answer it. Standard two-tower or three-tower architectures often fail to distinguish these from random noise. QuadrupletBERT addresses this by introducing a four-tower architecture designed to explicitly model the relationship between queries, positive instances, hard negatives, and simple negatives.

Methodology

The core innovation of QuadrupletBERT is its expansion of the standard BERT retrieval setup into a four-tower system. During the training phase, the model processes four distinct inputs simultaneously:

  1. Query ($u$): The user's search string.
  2. Positive Instance ($v$): The ground-truth answer.
  3. Simple Negative ($w$): A randomly sampled, irrelevant document.
  4. Hard Negative ($x$): A document semantically close to the query but incorrect.
Comparison of BERT-based retrieval architectures: (a) Two-tower, (b) Three-tower, and (c) the proposed QuadrupletBERT.

Quadruplet Loss

The model utilizes a specialized "Quadruplet Loss" function. Unlike triplet loss, which only pushes the positive closer and the negative further away, this loss enforces a hierarchical margin. It minimizes the distance between the query and the positive instance while ensuring a specific distance margin ($m$) exists between the hard negative and the simple negative. This forces the embedding space to become more nuanced, recognizing that a hard negative is "more relevant" than random noise even if it is still "wrong."

Inference Efficiency

Despite the four-tower training setup, inference remains highly efficient. Document embeddings are pre-computed and indexed. At query time, only the single "Query Tower" is executed. The system then performs an approximate nearest neighbor (ANN) search using the Faiss library, maintaining the speed required for production environments.

Experimental Results

The authors evaluated QuadrupletBERT on the Retrieval Question-Answering (ReQA) benchmark, specifically using the SQuAD and Natural Questions (NQ) datasets. Testing included both a "cold-start" scenario (5% training data) and a standard scenario (80% training data).

Performance comparison (Recall@K) across different training/test splits and margin values ($m$).

Key Findings

  • Superior Accuracy: On SQuAD (80/20 split), QuadrupletBERT achieved a Recall@1 of 28.15%, significantly outperforming the 21.04% achieved by standard three-tower models.
  • Robustness to Data Scarcity: In the 5% training split, the quadruplet structure acted as a powerful regularizer, maintaining a substantial lead over baselines.
  • Sensitivity to Margin: The results highlight the importance of the margin parameter ($m$). Optimal performance was generally found at $m=0.1$ or $m=0.2$, with higher values leading to overfitting.

Conclusion

QuadrupletBERT demonstrates that explicitly modeling the hierarchy of document relevance during training leads to superior embedding spaces for retrieval. By distinguishing between simple and hard negatives, the model achieves state-of-the-art recall while preserving the inference efficiency necessary for large-scale applications. Future work may explore more sophisticated hard negative mining techniques and the application of this quadruplet approach to broader NLP tasks.

Summary updated

BibTeX
@inproceedings{liu2021quadrupletbert,
  author = {Peiyang Liu and Sen Wang and Xi Wang and Wei Ye and Shikun Zhang},
  title = {{QuadrupletBERT: An Efficient Model For Embedding-Based Large-Scale Retrieval}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.292},
}
Figure