Hashing for Similarity Search: A Survey

Jingdong Wang, Heng Tao Shen, Jingkuan Song, Jianqiu JiarXiv 2014

Abstract

Similarity search, or nearest neighbor search, is the fundamental task of retrieving data items from a database that are most similar to a query item based on a distance metric. As data dimensionality and volume grow, traditional indexing methods succumb to the "curse of dimensionality," making exact search computationally prohibitive. This paper surveys hashing—a leading solution for approximate nearest neighbor (ANN) search. We categorize hashing algorithms into two primary frameworks: Locality Sensitive Hashing (LSH), which utilizes data-independent random projections, and Learning to Hash (L2H), which optimizes hash functions based on data distributions. This survey reviews these methods through the lenses of hash function design, distance measures, and search schemes within the coding space.

Introduction

In modern data science, similarity search is ubiquitous, powering applications ranging from image retrieval and duplicate detection to recommendation systems. The core challenge is efficiency: finding the closest match in a billion-point, high-dimensional dataset must happen in milliseconds. Hashing addresses this by mapping high-dimensional vectors into compact binary codes. This transformation enables massive storage reduction—representing complex features in dozens of bits—and blazing-fast search speeds via bitwise Hamming distance calculations or constant-time hash table lookups.

The Hashing Taxonomy

1. Locality Sensitive Hashing (LSH)

LSH represents the foundational, data-independent approach to hashing. These methods rely on random projections to ensure that the probability of a collision (two points falling into the same bucket) is proportional to their similarity in the original space.

  • Key Variants: Notable algorithms include $p$-stable LSH for Euclidean distance, SimHash for cosine similarity, and Min-Hash for Jaccard similarity.
  • Characteristics: LSH is valued for its strong theoretical guarantees and simplicity. However, because it does not account for the specific distribution of the data, it often requires long code lengths or multiple hash tables to achieve high precision, which can offset some efficiency gains.

2. Learning to Hash (L2H)

L2H methods are data-dependent, seeking to learn more efficient hash functions by analyzing the underlying data distribution. These are generally categorized into three sub-types:

  • Hamming Embedding: Techniques like Spectral Hashing treat the problem as a graph partitioning task. The goal is to achieve "bit balance" (each bit having a 50% chance of being 0 or 1) and "bit uncorrelation" to maximize the information density of each code.
  • Quantization: Methods such as Product Quantization (PQ) decompose the high-dimensional space into several lower-dimensional subspaces, quantizing each independently. This approach provides a much more granular approximation of Euclidean distance than simple binary strings, often leading to superior retrieval accuracy.
  • Supervised vs. Unsupervised: While unsupervised L2H uses only the data distribution, supervised methods incorporate labels or pairwise constraints to ensure that semantically similar items are mapped to similar codes, even if their raw feature distance is high.

Design Principles for Effective Hashing

The survey identifies two critical criteria for designing high-quality hash codes:

  1. Coding Balance: To maximize the entropy of the hash codes, each bit should be distributed as evenly as possible (0 or 1) across the dataset.
  2. Bit Independence: Each bit in the code should capture unique information. If bits are highly correlated, the effective code length is reduced, leading to wasted computational resources.

Benchmarks and Performance

While this survey does not introduce new empirical data, it synthesizes results from standard benchmarks including SIFT and GIST (image descriptors), MNIST (handwritten digits), and various web-scale text datasets.

Key findings include:

  • Efficiency: Binary distance computations using XOR and popcount instructions on modern CPUs are orders of magnitude faster than floating-point Euclidean calculations.
  • Memory Footprint: Hashing can reduce memory requirements by over 100x, enabling billion-scale datasets to be indexed within the RAM of a single server.
  • The Shift to Learning: Recent research has pivoted toward L2H because learned codes can be significantly shorter (e.g., 32–64 bits) while outperforming much longer LSH codes in practical applications.

Challenges and Future Directions

Despite the maturity of the field, several frontiers remain:

  • Scalability of Training: Many L2H algorithms involve complex optimization phases that are difficult to scale to billion-point datasets.
  • Encoding Latency: For real-time applications, the time required to generate a hash code for a new query (especially when using deep neural networks) can become a bottleneck.
  • Cross-Modality: As multi-modal AI grows, there is an increasing need for hashing techniques that can map different data types (e.g., text and images) into a shared Hamming space for cross-modal retrieval.

Conclusion

Hashing remains a cornerstone of large-scale similarity search. By balancing the theoretical rigor of LSH with the empirical efficiency of Learning to Hash, researchers continue to push the boundaries of what is possible in high-dimensional data retrieval. The shift toward quantization and learned representations suggests a future where search is not only faster but increasingly semantic.

Summary updated

BibTeX
@misc{wang2014hashing,
  author = {Jingdong Wang and Heng Tao Shen and Jingkuan Song and Jianqiu Ji},
  title = {{Hashing for Similarity Search: A Survey}},
  year = {2014},
  eprint = {1408.2927},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1408.2927},
}
Figure