Abstract
In the era of big data, efficient approximate nearest neighbor search is critical. Hashing methods address this by mapping high-dimensional data into compact binary codes. However, traditional hashing pipelines often suffer from rigid quantization stages that fail to preserve the underlying data distribution and neighborhood relationships. We introduce Affinity Preserving Quantization (APQ), a vector quantization-based approach that moves beyond axis-aligned scalar partitioning. By explicitly penalizing the loss of affinity between data points during the encoding process, APQ effectively restores the neighborhood structure typically damaged during dimensionality reduction. Our experiments on large-scale datasets, including ImageNet1M and NUS-WIDE, demonstrate that APQ consistently achieves superior retrieval accuracy compared to existing state-of-the-art quantization techniques.
Introduction
Finding the nearest neighbor to a query in massive datasets is a fundamental challenge in computer vision and information retrieval. Hashing has emerged as a dominant solution, compressing high-dimensional features into short binary strings (e.g., 32 to 256 bits) to enable rapid similarity search via Hamming distance.
Standard hashing methods typically involve a two-stage process: dimensionality reduction (projection) followed by quantization. A significant limitation of current methods is their reliance on Scalar Quantization (SQ). SQ treats each dimension independently, forcing data into rigid, rectangular bins that rarely align with the natural manifold of the data. Furthermore, the initial projection stage often distorts the original neighborhood relationships. Traditional quantization methods ignore this "affinity loss," resulting in binary codes that poorly represent the original data similarities.
Methods: Affinity Preserving Vector Quantization
APQ shifts the hashing paradigm from scalar to Vector Quantization (VQ). Unlike SQ, VQ partitions the feature space into Voronoi cells defined by learned centroids (codewords). This flexibility allows the quantizer to adapt to the actual shape of the data distribution.
The Affinity Objective
The core innovation of APQ is its joint objective function. Rather than solely minimizing the quantization error (the distance between a point and its codeword), APQ incorporates an affinity loss term. This term penalizes discrepancies between the distances of points in the original high-dimensional space and the distances between their corresponding codewords in the quantized space. By doing so, the quantization step acts as a corrective layer, repairing the neighborhood structure lost during the projection phase.
Scalability and Optimization
To maintain scalability for long binary codes, APQ utilizes Product Quantization, decomposing the high-dimensional space into disjoint subspaces and training separate quantizers for each. The optimization is performed through an iterative algorithm similar to K-means, alternating between an assignment step and a codeword update step using a quasi-Newton method.
Experimental Results
We evaluated APQ on several large-scale benchmarks, including NUS-WIDE (~270k images), GIST1M (1 million features), and ImageNet1M (1 million images). APQ was compared against seven state-of-the-art quantization methods across multiple hashing frameworks.
As shown in the results for ImageNet1M, APQ (integrated with PCA) significantly outperforms competing methods like ITQ, LSH, and CKM. On the NUS-WIDE dataset, APQ achieved mean Average Precision (mAP) gains of over 10% compared to the best baseline methods at 64 and 128 bits. Qualitative analysis further confirmed that APQ returns fewer false positives, providing more visually consistent retrieval results.
Conclusion and Future Work
Affinity Preserving Quantization demonstrates that the quantization stage of hashing should not be a passive rounding step. By adopting a vector quantization approach and explicitly preserving original-space affinities, APQ provides a robust mechanism for generating high-quality binary codes. While the training process is more computationally intensive than scalar methods—taking approximately 16 to 31 minutes for a million points—the gains in retrieval accuracy are substantial. Future research may explore the joint optimization of projection and quantization to further enhance the discriminative power of compact binary codes.
Summary updated