Lably
Skip to content

Locality-sensitive hashing

Algorithmic technique using hashing

  • 8 min read
  • 4 chapters

Related on Lably

Through Computer science, Hash function and Probability distribution

Hashing-based approximate nearest-neighbor search algorithms generally use one of two main categories of hashing methods: either data-independent methods, such as locality-sensitive hashing (LSH); or data-dependent methods, such as locality-preserving hashing (LPH).

Locality-preserving hashing was initially devised as a way to facilitate data pipelining in implementations of massively parallel algorithms that use randomized routing and universal hashing to reduce memory contention and network congestion.

Definitions

A finite family F of functions h:M→S is defined to be an LSH family for

  • a metric space M=(M,d),
  • a threshold r>0,
  • an approximation factor c>1,
  • and probabilities p1>p2

if it satisfies the following condition. For any two points a,b∈M and a hash function h chosen uniformly at random from F:

  • If d(a,b)≤r, then h(a)=h(b) (i.e., a and b collide) with probability at least p1,
  • If d(a,b)≥cr, then h(a)=h(b) with probability at most p2.

Such a family F is called (r,cr,p1,p2)-sensitive.

LSH with respect to a similarity measure

Alternatively it is possible to define an LSH family on a universe of items U endowed with a similarity function ϕ:U×U→[0,1]. In this setting, a LSH scheme is a family of hash functions H coupled with a probability distribution D over H such that a function h∈H chosen according to D satisfies Pr[h(a)=h(b)]=ϕ(a,b) for each a,b∈U.

Amplification

Given a (d1,d2,p1,p2)-sensitive family F, we can construct new families G by either the AND-construction or OR-construction of F.

To create an AND-construction, we define a new family G of hash functions g, where each function g is constructed from k random functions h1,…,hk from F. We then say that for a hash function g∈G, g(x)=g(y) if and only if all hi(x)=hi(y) for i=1,2,…,k. Since the members of F are independently chosen for any g∈G, G is a (d1,d2,p1k,p2k)-sensitive family.

To create an OR-construction, we define a new family G of hash functions g, where each function g is constructed from k random functions h1,…,hk from F. We then say that for a hash function g∈G, g(x)=g(y) if and only if hi(x)=hi(y) for one or more values of i. Since the members of F are independently chosen for any g∈G, G is a (d1,d2,1−(1−p1)k,1−(1−p2)k)-sensitive family.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Robotics