Stacked Quantizers for Compositional Vector Compression

Julieta Martinez, Holger H. Hoos, James J. LittlearXiv 2014

TL;DR

Stacked Quantizers (SQ) bridge the gap between fast but less accurate Product Quantization (PQ) and accurate but computationally prohibitive Additive Quantization (AQ). By adopting a hierarchical, greedy approach to encoding residuals, SQ achieves state-of-the-art compression accuracy—particularly on modern deep learning features—while remaining orders of magnitude faster than previous non-independent methods.

What Problem Does This Paper Address?

In large-scale computer vision, we often need to search through millions or billions of high-dimensional vectors (like image descriptors). Storing these in raw form is impossible due to memory constraints, so we compress them into short binary codes using Vector Quantization.

The gold standard for years has been Product Quantization (PQ), which is fast because it assumes the data can be split into independent, orthogonal subspaces. However, real-world data rarely fits this assumption. A newer method, Additive Quantization (AQ), dropped the independence assumption to achieve much lower error, but it made encoding an NP-hard problem. Encoding a large database with AQ is so slow it becomes impractical for real-world scaling. The authors of this paper sought a "middle ground": a method with the representational power of AQ but the scalability of PQ.

Methods

The authors introduce Stacked Quantizers (SQ). Instead of assuming independence (like PQ) or tackling a complex combinatorial optimization (like AQ), SQ uses a hierarchical residual structure.

  1. Greedy Encoding: To encode a vector $x$, SQ first finds the best match in the first codebook ($C_1$). It then calculates the residual (the error), $r_1 = x - C_1b_1$. This residual is then quantized by the second codebook ($C_2$), and so on. The final representation is simply the sum of the chosen codewords from each level.
  2. Codebook Refinement: During training, the codebooks are initialized by recursively performing k-means on residuals. They are then fine-tuned using a top-down coordinate descent that preserves the hierarchical structure, ensuring that greedy encoding remains effective.
Figure 1. Encoding as performed with Stacked Quantizers, shown for 4 subcodebooks. Left: the vector is passed through a series of quantizers, with residuals further encoded down the line. Right: A geometric interpretation of our approach. After recursively encod- ing residuals, the representation is additive in the encodings, and the quantization error is the remaining residual.

Datasets

The authors evaluated SQ on several standard and new benchmarks:

  • SIFT1M: 128-dimensional local descriptors.
  • GIST1M: 960-dimensional global scene descriptors.
  • ConvNet1M (128 to 4096 dims): A new benchmark introduced in this paper consisting of features extracted from various layers of state-of-the-art Convolutional Neural Networks (CNNs). This is crucial as deep features are increasingly replacing hand-crafted ones like SIFT.

Key Insights and Ideas

  • The Independence Tax: The paper demonstrates that the independence assumption in PQ is particularly damaging for deep learning features. SQ shows a much larger performance gain over PQ on CNN features than on traditional SIFT descriptors.
  • Hierarchy as a Heuristic: While AQ tries to solve a globally optimal encoding (which is NP-hard), SQ shows that a simple greedy hierarchy captures most of the benefits of non-independent codebooks without the computational nightmare.
  • Dimensionality vs. Compressibility: Interestingly, the authors found that 128-dimensional deep features are more "amenable to compression" than 1024-dimensional ones for classification tasks, suggesting that lower-dimensional features should be preferred if quantization is part of the pipeline.

Key Results

  • Quantization Error: SQ consistently matches or beats AQ's accuracy. On deep features (ConvNet1M-128), SQ shows a significant lead over all baselines when using 8 or 16 codebooks.
  • Speedup: This is the headline result. For a database of 1 million features, SQ takes about 20 seconds to encode, whereas AQ takes 9.2 hours.
  • Scalability: The authors project that for a 1-billion vector dataset, AQ would take over a year to encode on a single core, while SQ would finish in about 6 hours.
Figure 6. Comparison of training and encoding times. SQ (orange) achieves much lower error than PQ/OPQ while being significantly faster than the high-accuracy AQ/APQ baseline.

Limitations and Future Work

While SQ is much faster than AQ, it is still roughly 4x slower than PQ for encoding (since it must compute residuals sequentially rather than in parallel). The training process is also quadratic in the number of codebooks, which is slower than PQ's linear scaling, though training is typically a one-time offline cost.

The authors suggest future work should focus on integrating SQ with non-exhaustive indexing structures (like inverted files) to further speed up search in billion-scale databases. They also propose exploring more advanced optimization techniques like stochastic gradient descent for codebook refinement.

Summary updated

BibTeX
@misc{martinez2014stacked,
  author = {Julieta Martinez and Holger H. Hoos and James J. Little},
  title = {{Stacked Quantizers for Compositional Vector Compression}},
  year = {2014},
  eprint = {1411.2173},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1411.2173},
}
Figure