---
title: MinHash Locality Sensitive Hashing (LSH)
url: https://www.emergentmind.com/topics/minhash-locality-sensitive-hashing-lsh
type: topic
---

# MinHash Locality Sensitive Hashing (LSH)

MinHash Locality Sensitive Hashing (LSH) is a family of randomized algorithms foundational for approximate similarity search in high-dimensional discrete and numerical domains. The MinHash LSH framework maps input objects—traditionally sets, and more generally weighted or probabilistic objects—into lower-dimensional signatures such that the probability of hash collisions reflects a specific similarity measure (Jaccard or its extensions). This property enables sublinear-time candidate retrieval in large databases, making MinHash LSH a critical tool in deduplication, clustering, large-scale information retrieval, and modern scientific domains such as topological data analysis.

## 1. Foundations: Jaccard Similarity, MinHash, and LSH Structure

MinHash LSH originates from the relationship between Jaccard similarity and hash-based estimation. For sets $A,B\subseteq U$, Jaccard similarity is
\[
J(A,B) = \frac{|A\cap B|}{|A\cup B|}.
\]
The canonical MinHash algorithm selects a random permutation $\pi$ of $U$, defining $h_\pi(A) = \min\{\pi(x) : x \in A\}$. The central property is
\[
\Pr[h_\pi(A) = h_\pi(B)] = J(A,B),
\]
since the minimum of $A \cup B$ under a random order lies in $A\cap B$ with probability $|A\cap B|/|A\cup B|$ [2102.08942, 1408.2927].

For practical scale, $k$ independent MinHash functions, each generated by independent random permutations (or universal hash functions), produce signature vectors. The fraction of agreeing coordinates across signatures is an unbiased estimator of $J(A,B)$.

To enable sublinear candidate retrieval, banding LSH organizes the $k$-row signatures into $b$ bands of $r$ rows. Within each band, the $r$-tuple serves as a bucket key:
\[
P_{\text{candidate}}(s) = 1 - (1 - s^r)^b,
\]
where $s$ is the true Jaccard similarity. This forms an S-curve, sharply discriminating object pairs above or below a selected threshold [1408.2927].

## 2. MinHash for Probability Distributions: P-MinHash and Jaccard Generalization

Classic MinHash and LSH operate on sets (indicator vectors). Extensions to positive-weighted or probabilistic data require analogues of the Jaccard index. A frequently cited extension is
\[
J_W(x, y) = \frac{\sum_i \min(x_i, y_i)}{\sum_i \max(x_i, y_i)},
\]
for $x, y \in \mathbb{R}_+^n$. However, $J_W$ loses scale invariance and fails to recover set-Jaccard under normalization [1809.04052].

P-MinHash provides a scale-invariant, Pareto-optimal sampling-based extension. For nonnegative $x,y \in \mathbb{R}_+^n$, we define
\[
H(x) = \arg\min_{i:x_i > 0} \frac{-\log h(i)}{x_i},
\]
where $h(i)$ are independent uniform $(0,1]$ hash values. The resulting “exponential race” samples index $i$ with probability $x_i/\sum_j x_j$. The collision probability is
\[
\Pr[H(x) = H(y)] = J_P(x, y) = \sum_{i:x_i, y_i > 0} \frac{1}{\sum_j \max(x_j/x_i, y_j/y_i)},
\]
which is scale-invariant and reduces to classic Jaccard for indicator vectors. This is the unique Pareto-optimal collision kernel for sampling-based LSH over positive vectors [1809.04052].

## 3. Algorithmic Implementations: Sparse, Dense, and Set Data

### Set/Binary Data

Set-based MinHash can be efficiently implemented using $k$ hash functions, each applied to set members. State-of-the-art optimizations include one-permutation MinHash and densified hashing, reducing permutation or hash function costs [1408.2927].

### Sparse and Weighted Data

For sparse (many $x_i = 0$) or explicit distributions, P-MinHash computes, for each nonzero $x_i$,
\[
e_i = \frac{-\log\mathrm{UniformNonZeroFloat}(i,s)}{x_i},
\]
returning $\arg\min_i e_i$. This has $O(\mathrm{nnz}(x))$ time and is streamable. For dense/continuous data, a global A*-like search uses proposal measures and bounds to reduce computation, achieving $O(1 + B/\|x\|_1)$ expected steps for finite supports [1809.04052].

### Extensions: Structured and Hierarchical Data

Recent work has adapted MinHash LSH to data structures such as merge trees. For example, subpath-based and recursive MinHash signatures on rooted trees produce LSHable signatures supporting scalable comparative analysis in topological data analysis. Hash-based sketches are multiset-valued and processed via q-MinHash or recursive aggregation [2409.08519].

## 4. Theoretical Guarantees: Collision Probability and Optimality

### Unbiasedness

The collision probability of MinHash is exactly the target similarity:
\[
\forall A,B,\quad \Pr[h_\pi(A) = h_\pi(B)] = J(A,B)
\]
for sets, and analogously for $J_P(x, y)$ for probability distributions.

### Pareto-Optimality

P-MinHash’s $J_P(x,y)$ is Pareto-optimal: no other sampling-based LSH can strictly increase collision probability for some pair without decreasing it for another pair with higher $J_P$. The proof constructs auxiliary distributions and applies a pigeonhole argument across exclusive collision events [1809.04052].

### Embeddability

Banding schemes using MinHash produce S-shaped candidate curves sharply focusing on pairs above the chosen threshold. Both set-based and generalized MinHash LSH have formal embedding in $\ell_1$, with $1-s$ as a metric [2409.08519].

## 5. Parameterization and Practical Guidance

Recommended signature lengths are $k$ in the range $100$–$400$, divided into $b$ bands of $r$ rows (e.g., $b=20,r=5$) to tune the retrieval threshold. For set data, recent implementations employ b-bit MinHash (e.g., $b=8$), densified sketches, and single-permutation hashing to reduce storage and preprocessing.

For P-MinHash on web-scale sparse data, it is typical to concatenate $a\approx 4$–$8$ independent hashes, using 64-bit hash functions (e.g., splitmix64, xxHash). The number of output hash keys controls the trade-off between collision rates and recall [1809.04052].

## 6. Empirical Performance and Applications

Extensive empirical studies confirm MinHash LSH's effectiveness for duplicate and near-duplicate detection, large-scale document retrieval, and clustering [2102.08942, 1407.4416, 1408.2927, 1809.04052].

When compared to SimHash, MinHash offers superior candidate reduction and retrieval precision, especially for high similarity search tasks on sparse binary data. MinHash maintains a lower gap constant $\rho$ in the LSH time bound $O(n^\rho)$ for approximate neighbor search, ensuring more efficient search [1407.4416].

In web-scale tasks, P-MinHash yields higher collision rates on important data pairs, leading to notably reduced database accesses (e.g., achieving target recall with half the OR-lookups needed by weighted MinHash). The extension to merge trees and other structured data enables orders-of-magnitude speedups over edit distance or geometric methods, achieving near-linear scalability and interactive responsiveness for scientific workflows [1809.04052, 2409.08519].

## 7. Extensions and Open Directions

Recent deployments extend MinHash LSH beyond sets and vectors, including rooted trees (merge trees, subpath signatures), multisets, and arbitrary positive functions subject to measure-theoretic constraints [2409.08519]. The general principle remains: define a collision kernel based on an interpretable similarity measure, derive (when possible) a maximally consistent or optimal sampling-based hash, and tune hash concatenation and banding for application-dependent thresholds.

While MinHash LSH remains dominant for set and weighted set similarity search, possibilities include further compression (b-bit or hashed sketches), deeper structure-adaptive hierarchies, and adaptation to different data-dependent similarity metrics within the LSH framework, preserving unbiasedness and collision correspondence.

---

**References**:  
[1809.04052] "Maximally Consistent Sampling and the Jaccard Index of Probability Distributions"  
[2102.08942] "A Survey on Locality Sensitive Hashing Algorithms and their Applications"  
[1408.2927] "Hashing for Similarity Search: A Survey"  
[1407.4416] "In Defense of MinHash Over SimHash"  
[2409.08519] "Fast Comparative Analysis of Merge Trees Using Locality Sensitive Hashing"

Source: https://www.emergentmind.com/topics/minhash-locality-sensitive-hashing-lsh