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

Distance-sensitive hashing

Martin Aumüller, Tobias Christiani, Rasmus Pagh, Francesco Silvestri

Introduction

Locality-Sensitive Hashing (LSH) has long been the gold standard for high-dimensional similarity search. However, LSH is fundamentally constrained: the probability of two points colliding in a hash bucket must be a decreasing function of the distance between them. This paper introduces Distance-Sensitive Hashing (DSH), a powerful generalization that allows researchers to design hash functions where the collision probability follows a specific, custom-defined profile. This enables efficient searches for points that are "close but not too close" or points at a specific distance, known as annulus queries.

The Limitation of Traditional LSH

For decades, the core idea of LSH has been to ensure similar items are more likely to collide than dissimilar ones. While effective for nearest-neighbor search, this monotonic requirement makes LSH ill-suited for several important tasks:

  1. Annulus Queries: Finding points within a specific distance range (e.g., between 10 and 20 units away), useful in recommender systems to avoid redundant suggestions.
  2. Hyperplane Queries: Finding vectors nearly orthogonal to a query vector.
  3. Privacy-Preserving Estimation: Determining proximity without revealing exact distances if points are "too close."

The DSH Framework: Embracing Asymmetry

The key innovation in DSH is the move to an asymmetric setting. In standard LSH, the same hash function is used for both data points and queries. DSH instead uses a distribution over pairs of functions $(h, g)$ such that the probability $Pr[h(x) = g(y)]$ equals a target "collision probability function" (CPF) $f(dist(x, y))$.

A unimodal collision probability function (CPF) peaking at a non-zero distance, enabling annulus queries.

As shown in the figure above, DSH allows the collision probability to be zero at distance zero and peak at a specific non-zero distance, breaking the mathematical requirement that identical points must always collide.

Key Techniques and Construction

The authors propose several novel techniques to achieve these custom profiles across different mathematical spaces:

  • The Negation Trick: For angular distance, negating the query point transforms standard LSH into "anti-LSH," where collision probability increases with distance.
  • Polynomial Factorization: In Hamming space, the authors demonstrate how to match any polynomial CPF by combining bit-sampling and "anti-bit-sampling" based on the polynomial's roots.
  • Asymmetric Euclidean Hashing: By shifting hash buckets for the query in the classic E2LSH algorithm, they create "unimodal" CPFs that peak at specific distances.
Complex collision profiles (red line) can be constructed by combining multiple base distributions.

By combining multiple base distributions, as illustrated in the figure above, DSH can synthesize complex target functions to meet specific application requirements.

Key Results and Theoretical Impact

As a theoretical contribution, the paper provides rigorous proofs and complexity analyses for the unit sphere, Hamming space, and Euclidean space. Major findings include:

  • Sublinear Annulus Search: The authors demonstrate that for any distance $r$, one can build a data structure that finds points at distance approximately $r$ in sublinear time ($O(n^\rho)$ where $\rho < 1$), matching the efficiency of standard nearest-neighbor search.
  • Optimality Bounds: The performance gaps for these new asymmetric schemes are proven to be as tight as the best-known bounds for traditional symmetric LSH.
  • Privacy Gains: The framework supports "step-function" CPFs that stay flat for small distances, preventing attackers from using varying collision rates to triangulate a user's exact location.

Conclusion

Distance-Sensitive Hashing provides a unified theoretical umbrella for geometric search problems that previously required ad-hoc algorithmic tricks. By allowing the query hash to differ from the data hash, DSH expands the utility of hashing-based search to a much wider array of high-dimensional data challenges.

Summary updated

BibTeX
@inproceedings{aumuller2017distance,
  author = {Martin Aumüller and Tobias Christiani and Rasmus Pagh and Francesco Silvestri},
  title = {{Distance-sensitive hashing}},
  booktitle = {PODS},
  year = {2017},
  doi = {10.1145/3196959.3196976},
}
Figure