Abstract
Product quantization-based approaches are effective to encode high-dimensional data points for approximate nearest neighbor search. The space is decomposed into a Cartesian product of low-dimensional subspaces, each of which generates a sub codebook. Data points are encoded as compact binary codes using these sub codebooks, and the distance between two data points can be approximated efficiently from their codes by the precomputed lookup tables. Traditionally, to encode a subvector of a data point in a subspace, only one sub codeword in the corresponding sub codebook is selected, which may impose strict restrictions on the search accuracy. In this paper, we propose a novel approach, named Optimized Cartesian $K$-Means (OCKM), to better encode the data points for more accurate approximate nearest neighbor search. In OCKM, multiple sub codewords are used to encode the subvector of a data point in a subspace. Each sub codeword stems from different sub codebooks in each subspace, which are optimally generated with regards to the minimization of the distortion errors. The high-dimensional data point is then encoded as the concatenation of the indices of multiple sub codewords from all the subspaces. This can provide more flexibility and lower distortion errors than traditional methods. Experimental results on the standard real-life datasets demonstrate the superiority over state-of-the-art approaches for approximate nearest neighbor search.
Introduction
In the era of big data, finding the "nearest neighbor" to a query point (e.g., finding similar images in a database of billions) is a fundamental challenge. Exact search is impossible at scale due to the "curse of dimensionality"—as dimensions grow, the computational cost explodes. To solve this, researchers use Approximate Nearest Neighbor (ANN) search. A popular technique is Product Quantization (PQ), which breaks a high-dimensional vector into smaller "subvectors" and quantizes each one using a small codebook. However, traditional PQ and its successor, Cartesian $K$-Means (CKM), are rigid: they only allow one codeword per subvector. This limitation creates a "quantization error" (distortion) that hurts search accuracy. The authors aim to break this rigidity to achieve higher precision without sacrificing the efficiency that makes quantization attractive.
Methodology
The authors propose two main advancements over the standard Cartesian $K$-Means:
- Extended Cartesian $K$-Means (ECKM): Instead of picking just one codeword from a sub-codebook to represent a subvector, ECKM allows picking $C$ codewords from the same codebook. This provides much more flexibility in representing the original data point.
- Optimized Cartesian $K$-Means (OCKM): This is the flagship contribution. Instead of one codebook, OCKM generates $C$ different sub-codebooks for each subspace. To encode a subvector, it selects exactly one codeword from each of these $C$ sub-codebooks.
The Optimization Loop
The authors use an iterative coordinate descent algorithm to learn three things simultaneously: a rotation matrix ($R$), the sub-codebooks ($D$), and the binary codes ($b$). The sub-codebooks are optimized to minimize the squared distortion error. As shown in the figure below, the distortion decreases rapidly and converges within a few hundred iterations.
Experimental Results
The approach was evaluated on three standard high-dimensional benchmarks: SIFT1M, GIST1M, and a subset of SIFT1B.
Key Insights
- Flexibility Equals Accuracy: By moving from a single codeword to a combination of codewords, the "resolution" of the quantization increases exponentially without a massive increase in storage.
- The Power of Diversity: The paper proves that OCKM is theoretically superior to CKM. Specifically, using multiple distinct sub-codebooks (OCKM) is more effective than just picking multiple codewords from a single large codebook (ECKM) because it allows for a more nuanced reconstruction of the original signal.
- Negligible Overhead: While OCKM sounds more complex, the search process (Asymmetric Distance Computation) only requires one additional table lookup and one extra addition per subvector compared to standard PQ. In practice, this means a negligible increase in query time (e.g., 24.3ms vs 23.5ms for 1 million points).
Performance Metrics
- Lower Distortion: OCKM consistently achieved lower quantization errors than PQ and CKM across all tested bit-lengths (32, 64, and 128 bits).
- Higher Recall: At a fixed code length of 64 bits, OCKM improved search recall by approximately 5% on SIFT1M and 4% on GIST1M and SIFT1B compared to CKM.
Discussion and Conclusion
While OCKM offers significant accuracy gains, it introduces some complexity in encoding. Encoding a new data point is more computationally expensive than in standard PQ because of the matching pursuit-style algorithm used to select the best combination of codewords. The performance also depends on the parameter $T$ (the number of candidates tracked during encoding). Increasing $T$ helps reduce distortion, but with diminishing returns after a certain point.
The authors suggest that the OCKM framework could potentially be extended to supervised hashing or multi-modal retrieval tasks. In conclusion, OCKM provides a powerful way to squeeze more accuracy out of quantization-based ANN search with minimal impact on query performance.
Summary updated