What Is Locality-Sensitive Hashing?

Locality-Sensitive Hashing Explainer

Locality-sensitive hashing, or LSH, is a family of techniques for approximate similarity search. Unlike ordinary hashing, which tries to scatter inputs uniformly, an LSH family makes nearby items more likely to receive the same hash value.

A system usually builds several hash tables from multiple random functions. A query is hashed into buckets, and only the items that collide with it become candidates for a more exact distance calculation.

The approach can reduce search work for high-dimensional images, text features, audio fingerprints, and duplicate detection. Different LSH families are designed for different similarity measures, such as cosine or Jaccard similarity.

Collisions are probabilistic: close points can separate, and distant points can collide. More tables improve recall but consume memory and query time. Results depend on dimension, data distribution, hash family, bucket width, and target distance.

Locality-sensitive hashing uses specially designed hash functions that are more likely to place similar items in the same bucket.

Key terms include LSH, hash family, bucket, collision, candidate, cosine similarity, Jaccard similarity, recall and random projection.

Each hash function partitions the space so nearby points have a higher collision probability.

Multiple tables give a query several chances to meet its true neighbors.

Extra hash tables recover more neighbors but create more candidates and storage.

The method must match the application’s similarity measure and data distribution.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.