Efficient Document Retrieval by End-to-End Refining and Quantizing BERT Embedding with Contrastive Product Quantization

Zexuan Qiu, Qinliang Su, Jianxing Yu, Shijing Si · DOI

Introduction

In the era of massive digital repositories, the ability to perform efficient and accurate document retrieval is a cornerstone of modern information systems. Traditional retrieval methods often rely on Approximate Nearest Neighbor (ANN) search, specifically through semantic hashing. Semantic hashing converts high-dimensional document representations into compact binary strings, enabling rapid search via Hamming distance. However, this approach faces two significant hurdles: the reliance on outdated features like TF-IDF—which ignore semantic context—and the "Hamming bottleneck," where the discrete nature of binary codes limits the resolution of similarity measurements.

While Pre-trained Language Models (PLMs) like BERT have revolutionized natural language understanding, their raw embeddings are notoriously "anisotropic." They tend to occupy a narrow, directional cone in vector space, making them suboptimal for direct similarity-based retrieval. This paper introduces MICPQ (Mutual-Information-Improved Contrastive Product Quantization), an end-to-end framework designed to refine BERT embeddings and transform them into highly efficient, searchable codewords that overcome the limitations of traditional hashing.

The MICPQ Framework

MICPQ moves beyond simple binary hashing by utilizing Product Quantization (PQ). Unlike binary hashing, which maps vectors to bits, PQ decomposes the vector space into a Cartesian product of several low-dimensional subspaces and quantizes each subspace separately. The MICPQ architecture is built upon four primary pillars:

1. End-to-End Refining and Quantization

Traditional systems often treat embedding generation and quantization as two separate stages. MICPQ integrates these into a unified pipeline. The model slices a BERT embedding into $M$ distinct segments. Each segment passes through a learnable refining mapping designed to "spread out" the anisotropic distribution of the original BERT output, ensuring the resulting vectors are better suited for quantization.

2. Probabilistic Contrastive Learning

To ensure that the quantized representations capture deep semantic relationships, the framework employs a contrastive learning objective. By applying different dropout masks to the same document, the model generates two distinct "views" of the text. The training process then optimizes the model to pull these views together in the quantized space while simultaneously pushing representations of different documents apart.

3. Differentiable Quantization via Gumbel-Softmax

A major challenge in training quantization networks is that the "round-to-nearest-codeword" operation is non-differentiable, preventing standard backpropagation. MICPQ overcomes this by using the Gumbel-Softmax trick. This probabilistic approach allows for a differentiable approximation of the quantization step, enabling the model to learn the optimal codebooks directly from the data.

4. Mutual Information (MI) Maximization

To prevent "codeword collapse"—a scenario where the model only utilizes a small subset of the available codebook—the authors introduce a Mutual Information maximization objective. This regularizer encourages an even distribution of documents across codewords and ensures that each codeword is highly representative of the semantic cluster it defines.

Experimental Evaluation

The authors evaluated MICPQ against a variety of baselines, including generative hashing methods (VDSH, NASH) and state-of-the-art BERT-based hashing (DHIM), across three benchmark datasets:

  • NYT (New York Times): 26 categories of news articles.
  • AGNews: Academic news search results across 4 classes.
  • DBpedia: Wikipedia abstracts spanning 14 classes.

Key Results

MICPQ demonstrated superior performance across all datasets and code lengths (ranging from 16 to 128 bits). On average, the model improved retrieval precision by 4.32% on NYT, 3.07% on AGNews, and 4.37% on DBpedia compared to the previous state-of-the-art method, DHIM. Notably, MICPQ at 16 bits often outperformed competing models using 128 bits, highlighting its extreme efficiency.

Discussion and Insights

The success of MICPQ stems from the fundamental advantages of Product Quantization over binary hashing. PQ allows for Asymmetric Distance Computation (ADC), where a query's real-valued embedding can be compared against pre-computed real-valued codewords. This provides a much more nuanced similarity score than the "grainy" integer distances of the Hamming space.

Furthermore, the ablation studies confirmed that the integration of Gumbel noise and Mutual Information maximization is critical. The Gumbel noise serves as more than just a mathematical workaround for gradients; it acts as a regularizer that improves the final retrieval performance. Similarly, MI maximization ensures the discrete codebook effectively captures the hidden structural diversity of the document corpus.

Conclusion and Future Work

MICPQ represents a significant step forward in bridging the gap between high-performance BERT embeddings and efficient document retrieval. By refining anisotropic embeddings and utilizing a differentiable PQ framework, it achieves state-of-the-art precision with a minimal storage footprint.

Future research directions include investigating whether individual codebooks learn distinct semantic features (such as topic vs. sentiment) and scaling the framework to massive-scale passage retrieval tasks common in modern Retrieval-Augmented Generation (RAG) systems. While the training of BERT-based encoders is computationally intensive, the resulting gains in retrieval speed and accuracy make MICPQ a compelling solution for large-scale document management.

Summary updated

BibTeX
@inproceedings{qiu2022efficient,
  author = {Zexuan Qiu and Qinliang Su and Jianxing Yu and Shijing Si},
  title = {{Efficient Document Retrieval by End-to-End Refining and Quantizing BERT Embedding with Contrastive Product Quantization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.54},
}
Figure