NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Jointly Optimizing Query Encoder and Product Quantization to Improve Retrieval Performance

Jingtao Zhan, Jiaxin Mao, Yiqun Liu, Jiafeng Guo, Min Zhang, Shaoping Ma

Abstract

Dense Retrieval (DR) has emerged as a powerful paradigm for information retrieval, yet it faces significant scalability challenges due to the memory and computational demands of brute-force search. While vector compression techniques like Product Quantization (PQ) can mitigate these costs, traditional disjoint training of encoders and quantizers often results in a substantial loss of retrieval accuracy. This paper introduces JPQ (Joint optimization of query encoding and Product Quantization), a framework that bridges this gap by jointly training the query encoder and the PQ index. By employing a ranking-oriented loss and end-to-end negative sampling, JPQ achieves a 30x compression ratio and up to 10x speedup while maintaining performance comparable to state-of-the-art uncompressed models.

Introduction

Modern Information Retrieval (IR) systems increasingly rely on Dense Retrieval (DR), which uses dual-encoders to map queries and documents into a continuous vector space. Unlike traditional keyword-based methods like BM25, DR can capture semantic nuances. However, the requirement to perform similarity searches against millions or billions of document embeddings creates a "scalability hurdle." Brute-force search is often too slow and memory-intensive for production environments.

To address this, researchers often turn to Product Quantization (PQ) to compress document vectors. The standard approach is a two-step process: first, train the encoders to produce high-quality embeddings, and then compress those embeddings into a PQ index. This separation creates a mismatch; the quantization process is typically optimized to minimize reconstruction error rather than ranking performance, leading to a significant drop in metrics like MRR@10.

The JPQ Framework

The authors propose JPQ, which treats the compression index as a differentiable component of the neural network architecture. This allows the model to learn representations that are inherently resilient to the distortions introduced by quantization.

Comparison of workflows between existing training methods (a) and the proposed JPQ framework (b).

The JPQ training strategy rests on three pillars:

  1. Ranking-oriented Loss: Unlike traditional PQ which minimizes "reconstruction error" (MSE), JPQ minimizes a pairwise ranking loss. It calculates similarity scores using the actual quantized embeddings during training, ensuring the query encoder learns to rank documents correctly despite the compression.
  2. PQ Centroid Optimization: Training a PQ index is challenging because document-to-cluster assignments are discrete and non-differentiable. JPQ overcomes this by fixing the "Index Assignments" after an initial warm-up phase. It then updates only the Centroid Embeddings via gradient descent, making the optimization process stable.
  3. End-to-End Negative Sampling: To improve robustness, JPQ retrieves "hard negatives" using the current PQ index during training. This forces the query encoder to distinguish between relevant documents and the specific types of "noise" or near-misses introduced by the quantization process.

Experimental Evaluation

The effectiveness of JPQ was evaluated on two major industry benchmarks: the MS MARCO Passage Ranking task (8.8 million passages) and the MS MARCO Document Ranking task (3.2 million documents). Performance was also validated using the TREC 2019 Deep Learning Track.

Results and Discussion

JPQ demonstrates that efficiency does not have to come at the cost of effectiveness. The framework achieves a 30x compression ratio on index size. On the MS MARCO Passage task, JPQ's index is approximately 1/186th the size of the ColBERT model while maintaining competitive accuracy.

Comparison of Index Size vs. MRR@10 for various retrieval models on MS MARCO Passage. JPQ (star) achieves high accuracy with a significantly smaller index.

Key performance highlights include:

  • Accuracy: On MS MARCO Passage, JPQ achieved an MRR@10 of 0.341, matching state-of-the-art brute-force models like ANCE and STAR, and vastly outperforming standard PQ (0.123).
  • Efficiency: The compressed index enables a 10x speedup on CPU and a 2x speedup on GPU compared to uncompressed DR models.
  • Latency: For document ranking, JPQ reduced CPU latency from 2.50s (uncompressed) to 0.28s.

Conclusion and Future Work

JPQ proves that joint optimization is a viable path toward scalable, high-performance dense retrieval. By making the query encoder "aware" of the quantization process, the system can maintain high ranking accuracy even with extreme compression.

Future research directions include allowing document-to-centroid assignments to evolve dynamically during training and exploring the joint update of the document encoder alongside the query encoder and centroids. Additionally, investigating the integration of other quantization variants, such as ScaNN, could further enhance the framework's versatility.

Summary updated

BibTeX
@inproceedings{zhan2021jointly,
  author = {Jingtao Zhan and Jiaxin Mao and Yiqun Liu and Jiafeng Guo and Min Zhang and Shaoping Ma},
  title = {{Jointly Optimizing Query Encoder and Product Quantization to Improve Retrieval Performance}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2021},
  url = {https://openreview.net/forum?id=0uU0Rfq-45},
}
Figure