Multiscale Quantization for Fast Similarity Search

Xiang Wu, Ruiqi Guo, Ananda Theertha Suresh, Sanjiv Kumar, Daniel N. Holtmann-Rice, David Simcha, Felix X. YuNeurIPS 2017

Fast similarity search—the process of finding the "nearest neighbors" to a query in a massive database—often relies on Product Quantization (PQ). PQ works by breaking a high-dimensional vector into smaller sub-vectors and quantizing each independently. While it is fast and memory-efficient, standard PQ has a significant blind spot: it performs poorly when there is high variance in the norms (lengths) of the data points.

This problem is particularly acute in hierarchical search systems. Typically, these systems first perform a coarse search (Vector Quantization) to find a cluster, and then use PQ to quantize the residuals (the distance from the cluster center). These residuals often have highly inconsistent lengths. If a standard PQ codebook is fitted to these varying lengths, the quantization error explodes, leading to poor search accuracy.

Effect of norm variance on quantization error and how coarse quantization exacerbates it.

To address this, researchers have introduced Multiscale Quantization (MSQ), an end-to-end framework that separately quantizes the "direction" and the "scale" of data residuals. By training the entire pipeline jointly, MSQ achieves a 15–25% reduction in quantization error and significantly better search recall than previous state-of-the-art methods.

The Multiscale Quantization Framework

MSQ decomposes the quantization process into several coordinated steps to directly tackle the variance in residual norms:

  1. Coarse Quantization (VQ): The vector is first assigned to a coarse cluster center.
  2. Learned Rotation: A rotation matrix is applied to the residuals. This balances the variance across different subspaces, making them easier to quantize. Theoretical analysis shows that without proper rotation, a product code might require an exponentially large number of codewords to achieve low error.
  3. Multiscale Decomposition: Instead of quantizing the residual directly, MSQ splits it into two components:
  4. Direction: The unit-normalized version of the rotated residual.
  5. Scale: The original norm of the residual.
  6. Joint Quantization: The "direction" is quantized using standard PQ, while the "scale" is quantized using a separate Scalar Quantizer (SQ).
  7. End-to-End Training: Unlike previous methods that train these steps in isolation, MSQ uses Stochastic Gradient Descent (SGD) to optimize all parameters (codebooks, rotation, and scales) simultaneously. To keep the rotation matrix valid (orthogonal) during gradient descent, the authors use the Cayley characterization, which parameterizes rotation through a skew-symmetric matrix.

Key Results and Performance

The authors evaluated MSQ on two standard large-scale benchmarks: SIFT1M (1 million 128-dimensional image features) and DEEP10M (10 million 96-dimensional vectors from a GoogLeNet model).

Moving from alternating optimization to joint SGD training provides a substantial boost in accuracy. The end-to-end approach allows the coarse quantizers and the fine-grained PQ codes to co-evolve.

Relative MSE reduction across datasets and query speed comparisons for different lookup table sizes.
  • Error Reduction: MSQ reduced Mean Squared Error (MSE) by 15–20% on SIFT1M and 20–25% on DEEP10M compared to the standard IVFADC baseline. The breakdown of this reduction highlights the combined importance of learned rotation, multiscale decomposition, and end-to-end training.
  • Recall Boost: In "Recall@N" tests, MSQ consistently outperformed standard Product Quantization (PQ), Optimized Product Quantization (OPQ), and Stacked Quantizers (SQ) across various bitrates.
  • Hardware Efficiency & Speed: Despite the extra "scale" parameter, MSQ maintains highly competitive search speeds. By using SIMD instructions (like VPSHUFB on modern CPUs) and a 16-center "in-register" lookup table (LUT16), the system achieves search speeds up to 5x faster than traditional in-memory ADC (Asymmetric Distance Computation) while maintaining high recall.

Limitations and Future Work

While MSQ offers a robust improvement over standard PQ, it does come with a few limitations. Computing the gradient for the rotation matrix requires inverting a $d \times d$ matrix. While manageable for hundreds or thousands of dimensions, this could become a bottleneck for extremely high-dimensional embeddings without further optimization. Additionally, while fixed hyperparameters demonstrated the method's robustness, per-dataset tuning could likely yield even higher performance. Finally, scaling these end-to-end techniques to billion-vector datasets remains an important next step for future research.

Summary updated

BibTeX
@inproceedings{wu2017multiscale,
  author = {Xiang Wu and Ruiqi Guo and Ananda Theertha Suresh and Sanjiv Kumar and Daniel N. Holtmann-Rice and David Simcha and Felix X. Yu},
  title = {{Multiscale Quantization for Fast Similarity Search}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
  url = {https://openreview.net/forum?id=SkbpyuZOWS},
}
Figure