Compact Token Representations with Contextual Quantization for Efficient Document Re-ranking

Yingrui Yang, Yifan Qiao, Tao YangACL 2022

Introduction

Modern search engines typically employ a multi-stage retrieval pipeline. A fast initial retriever (e.g., BM25) identifies candidate documents, which are then re-ranked by sophisticated Transformer-based models like BERT for maximum precision. While effective, these models are computationally expensive. To bridge the gap between speed and accuracy, "late interaction" models like ColBERT pre-compute and store embeddings for every token in a corpus.

However, this approach introduces a massive storage bottleneck. For a standard corpus like MS MARCO, these embeddings can require up to 1.6 Terabytes of storage. Hosting such a volume in RAM is prohibitively expensive, while disk-based retrieval introduces significant latency. To address this, researchers at UC Santa Barbara have developed Contextual Quantization (CQ), a method that compresses these embeddings by approximately 14x with negligible impact on search relevance.

The Contextual Quantization Framework

The core innovation of CQ is the decoupling of a token's embedding into two distinct components:

  1. Document-Independent Component: This represents the "base" semantic meaning of a word (e.g., the general concept of "bank"), which remains constant across the entire corpus.
  2. Document-Specific Component: This captures the contextual nuance (e.g., "bank" referring to a river vs. a financial institution) specific to a particular document.
The CQ architecture showing the offline indexing and online re-ranking phases.

As shown in the architecture above, CQ operates in two phases. Offline, the system identifies document-independent embeddings from a shared vocabulary and quantizes the document-specific residuals into short codes using learned codebooks. Online, during a search query, the system fetches these codes, decodes them, and uses a lightweight composition layer to reconstruct the final contextual embedding for ranking.

Ranking-Aware Training

Traditional compression techniques, such as Product Quantization (PQ), typically aim to minimize reconstruction error (Mean Squared Error). However, in information retrieval, not all errors are equal; an error that swaps the order of two documents is far more damaging than one that slightly shifts their absolute scores.

CQ addresses this by employing Ranking-Aware Training using a MarginMSE loss function. Instead of simply trying to replicate the original vector, the quantizer is trained to preserve the ranking order and score margins produced by the original, uncompressed "teacher" model.

Comparison of ranking score preservation (a) and Kendall’s τ coefficient distribution (b) between standard OPQ and CQ methods.

As illustrated in the figures above, CQ-MarginMSE significantly outperforms standard unsupervised methods like Optimized Product Quantization (OPQ). The scatter plot (a) shows that CQ scores correlate much more tightly with the original ranking scores, while the density plot (b) demonstrates a higher Kendall’s $\tau$ coefficient, indicating superior preservation of the relative document order.

Experimental Results

The authors evaluated CQ on the MS MARCO and TREC Deep Learning benchmarks. Key findings include:

  • Massive Compression: CQ achieved a 14:1 compression ratio. For the MS MARCO document task, storage requirements plummeted from 1.6TB to just 112GB, allowing the entire index to fit within the memory of a single high-end server.
  • High Fidelity: The drop in search quality was minimal. On the MS MARCO passage task, MRR@10 (Mean Reciprocal Rank) only decreased by 0.8% to 2.4%, depending on the specific configuration.
  • Low Latency: The computational overhead for decompressing and recomposing embeddings is approximately 1ms per query, ensuring that the efficiency gains in storage do not come at the cost of user experience.

Conclusion

Contextual Quantization represents a significant step forward for scalable, high-precision search. By recognizing that contextual nuances are sparse and prioritizing ranking preservation over raw reconstruction, CQ enables the deployment of state-of-the-art re-rankers on standard hardware without the prohibitive costs of massive memory arrays.

Summary updated

BibTeX
@inproceedings{yang2022compact,
  author = {Yingrui Yang and Yifan Qiao and Tao Yang},
  title = {{Compact Token Representations with Contextual Quantization for Efficient Document Re-ranking}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.51},
}
Figure