NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Compact Hash Codes for Efficient Visual Descriptors Retrieval in Large Scale Databases

Simone Ercoli, Marco Bertini, Alberto Del Bimbo

TL;DR

This paper introduces multi-k-means, a novel hashing method that creates extremely compact binary codes for large-scale image retrieval. By allowing a single visual feature to be assigned to multiple cluster centers simultaneously, the authors achieve state-of-the-art retrieval accuracy on billion-scale datasets while significantly reducing memory requirements and training complexity compared to traditional vector quantization.

What Problem Does This Paper Address?

In the era of massive visual databases, finding the "nearest neighbor" to a query image is like finding a needle in a haystack—if the haystack were a billion points wide and hundreds of dimensions deep. Exhaustive search is too slow, so researchers use Approximate Nearest Neighbor (ANN) search, often relying on hashing to convert high-dimensional descriptors into compact binary strings.

However, existing methods face a trade-off:

  1. Memory Constraints: Storing billions of descriptors requires massive RAM, which is problematic for mobile devices or large-scale analysis systems.
  2. Complexity: Sophisticated methods like Product Quantization (PQ) or deep learning-based hashing can be computationally expensive to train or require vast amounts of training data.
  3. Quantization Error: "Hard" assignment (mapping a point to exactly one cluster center) often leads to errors when a point sits right on the boundary between two clusters.

Methods

The authors propose a "soft assignment" twist on the classic k-means algorithm. Instead of mapping a feature vector to just one centroid, they associate each centroid with a specific bit in a hash code.

The Multi-k-means Algorithm:

  1. Dictionary Learning: Perform standard k-means to find a small number ($k$) of centroids.
  2. Bit Assignment: For a given feature $x$, the $j$-th bit of its hash code is set to 1 if the distance to centroid $C_j$ is below a threshold $\delta$, and 0 otherwise.
  3. Thresholding Strategies: The paper explores different ways to set $\delta$:
  4. m-k-means-t: Uses a threshold based on the arithmetic or geometric mean of distances to all centroids.
  5. m-k-means-n: Assigns the feature to a fixed number ($n$) of the nearest centroids.
  6. Variant x2: Splitting the training data to create two separate codebooks and concatenating the resulting bits.
Toy examples illustrating the multi-k-means assignment logic. Top: variable number of clusters based on a threshold. Middle: fixed number of clusters. Bottom: union of two different codebooks.

This approach effectively treats each centroid as a "landmark." If a feature is "near" a landmark, that bit flips on. This naturally handles the ambiguity of points near cluster boundaries without needing expensive "multi-probe" search techniques at query time.

Datasets

The method was rigorously tested across both "engineered" features (like SIFT) and "learned" features (from CNNs):

  • BIGANN (SIFT1M, SIFT1B, GIST1M): Large-scale public datasets containing up to one billion descriptors.
  • CIFAR-10: 60,000 color images across 10 classes, used with features extracted from a VGG-style CNN.
  • MNIST: 70,000 handwritten digits, used with features from a LeNet architecture.
  • INRIA Holidays: Used as the source for query and base descriptors in the BIGANN experiments.
Sample images from the INRIA Holiday dataset used in the BIGANN benchmarks.

Key Insights and Ideas

  • Simplicity Wins: The core idea—one centroid equals one bit—is remarkably simple compared to the sub-space decomposition used in Product Quantization. Yet, it yields better results because it directly addresses codeword ambiguity.
  • Soft Assignment as Regularization: By allowing multiple bits to be "on," the hash code captures a richer local neighborhood of the feature space than a single-index assignment.
  • Efficiency for Mobile: Because the codebook size is so small (e.g., only 64 centroids for a 64-bit code), the memory footprint for the quantizer itself is negligible, making it ideal for deployment on mobile devices with limited RAM.

Key Results

The results are particularly impressive on the most challenging benchmarks:

  • SIFT1B (1 Billion Vectors): On the massive SIFT1B dataset, m-k-means-t achieved a Recall@1 of 0.668, dwarfing the previous state-of-the-art (LOPQ at 0.199). This represents a 3x improvement in finding the exact nearest neighbor in the top rank.
  • CIFAR-10: The method achieved a Mean Average Precision (MAP) of 0.972, outperforming deep supervised hashing methods like KevinNet (0.894) and CNNH+ (0.532).
  • Robustness: The method consistently outperformed or matched complex methods like Cartesian k-means and Optimized Product Quantization (OPQ) across various bit lengths and dataset types.

Limitations and Future Work

While the paper demonstrates excellent performance, a few areas remain for exploration:

  • Threshold Sensitivity: The performance of the m-k-means-t variant depends on the choice of threshold $\delta$. While the arithmetic mean worked well, an adaptive threshold per region might further improve results.
  • Supervised Extension: The current method is unsupervised. Integrating class labels during the centroid learning phase (similar to the CNN-based methods it was compared against) could potentially push the MAP even higher for classification-heavy tasks.
  • Computational Cost of Distances: Although the codebook is small, calculating distances to all $k$ centroids for every feature might become a bottleneck if $k$ grows very large (e.g., 1024 bits or more), though the paper focuses on compact 32-64 bit codes where this is not an issue.

Not discussed in the paper: The specific impact of different k-means initialization strategies beyond k-means++.

Summary updated

BibTeX
@article{ercoli2017compact,
  author = {Simone Ercoli and Marco Bertini and Alberto Del Bimbo},
  title = {{Compact Hash Codes for Efficient Visual Descriptors Retrieval in Large Scale Databases}},
  journal = {IEEE Trans. Multimedia},
  year = {2017},
  url = {https://openreview.net/forum?id=ReQcMUOkaIz},
}
Figure