Abstract
Traditional vector quantization focuses on minimizing the error of individual point reconstructions. This paper introduces Pairwise Quantization (PairQ), which uses a simple linear transformation to optimize quantization specifically for preserving scalar products and Euclidean distances between points. By shifting the objective from reconstruction to relationship preservation, PairQ achieves up to a 43% reduction in approximation error for tasks like retrieval and recommendation while providing unbiased distance estimates.
Introduction
In large-scale machine learning and information retrieval, high-dimensional vectors (e.g., image embeddings or user profiles) are often compressed using quantization to save memory and accelerate search. Standard techniques like Product Quantization (PQ) or Optimized Product Quantization (OPQ) minimize "reconstruction error"—the distance between the original vector $x$ and its compressed version $\hat{x}$.
However, many applications rely on relationships between vectors, such as scalar products for search or Euclidean distances for clustering. Minimizing individual reconstruction error is a suboptimal proxy for preserving these pairwise interactions. PairQ addresses this by directly minimizing the distortion of these interactions.
Methodology
The core innovation of PairQ is reducing the minimization of pairwise distortion to a standard reconstruction error problem via a data-driven linear transformation.
The Linear Transform Trick
- Scalar Products: To minimize error in $\langle q, x \rangle$, the authors define a matrix $G = \sum q_i q_i^T$ from training queries. Using Singular Value Decomposition (SVD), $G$ is decomposed into $C^T C$. Transforming database vectors $x$ into $z = Cx$ makes minimizing scalar product distortion equivalent to minimizing reconstruction error in the $z$-space.
- Euclidean Distances: Vectors are augmented with their squared norms to convert distance preservation into a scalar product problem, solvable with the same transformation logic.
Implementation
PairQ acts as a preprocessing step. After applying the transformation $C$, any standard quantizer (e.g., OPQ) can be used. At query time, a corresponding inverse transform is applied to the query vector.
Key Insights
Unbiased Estimation
A critical theoretical finding is that standard OPQ provides a biased estimate for squared Euclidean distances, systematically underestimating them. PairQ provides an unbiased estimate for both scalar products and distances.
Query-Awareness
Unlike standard quantization, PairQ incorporates the distribution of queries $Q$. This allows the quantizer to focus precision on dimensions and directions most relevant to actual system usage.
Experimental Results
The authors evaluated PairQ across several domains, including text-to-image retrieval, recommendation systems (MovieLens-20M), and standard vector benchmarks (SIFT1M, GIST1M, DEEP1M).
- Error Reduction: In text-to-image retrieval, PairQ reduced mean squared error of cosine similarities by up to 43% compared to OPQ. On MovieLens, it achieved a 42% reduction in scalar product error.
- Efficiency: In Euclidean distance tests, PairQ with 4 bytes per vector often outperformed standard OPQ using 16 bytes, a 4x improvement in memory efficiency for equivalent accuracy.
Limitations and Future Work
PairQ is not optimized for Approximate Nearest Neighbor (ANN) search. Because its loss function treats all pairs equally, it allocates precision to accurately representing large distances. In ANN search, where only small distances matter, standard OPQ may perform better for top-1 neighbor retrieval. Future work includes investigating weighted loss functions to favor local distances for improved ANN performance.
Summary updated