Locality-Sensitive Hashing (LSH) is a family of hashing functions designed to map similar input items into the same hash buckets with high probability, while dissimilar items are hashed to different buckets. Unlike cryptographic hashing, which maximizes output differences for small input changes, LSH functions are engineered to preserve similarity in the hashed space. This property makes LSH a critical blocking or filtering mechanism in entity resolution pipelines, drastically reducing the quadratic number of pairwise comparisons needed to find matching records by only comparing candidates within the same hash bucket.
Glossary
Locality-Sensitive Hashing (LSH)

What is Locality-Sensitive Hashing (LSH)?
A foundational algorithmic technique for approximate nearest neighbor search and high-dimensional data indexing.
The core mechanism involves defining a hash function family where the probability of collision is proportional to the similarity between items, as measured by a metric like Jaccard similarity or cosine similarity. Common LSH families include MinHash for set similarity and random projection methods like SimHash for angular similarity. In practice, multiple hash functions are combined to increase precision, and the technique is central to scalable approximate nearest neighbor (ANN) search in vector databases, enabling fast semantic search over high-dimensional embeddings where exact search is computationally prohibitive.
Key Characteristics of LSH
Locality-Sensitive Hashing (LSH) is a foundational algorithmic technique for approximate nearest neighbor search, designed to hash similar input items into the same buckets with high probability. Its core characteristics make it uniquely suited for the blocking phase of large-scale entity resolution.
Probabilistic Approximation
LSH is fundamentally an approximate algorithm. It trades perfect accuracy for immense speed, providing probabilistic guarantees rather than deterministic results. The core guarantee is that the probability of collision (hashing to the same bucket) is higher for similar items than for dissimilar ones.
- Formal Property: For a distance metric
dand similarity thresholdR, an LSH familyHsatisfies: ifd(x, y) ≤ RthenP[h(x) = h(y)]is high (e.g.,p1); ifd(x, y) ≥ cRthenP[h(x) = h(y)]is low (e.g.,p2), wherep1 > p2andc > 1. - Engineering Implication: This means some truly similar pairs may be missed (false negatives), and some dissimilar pairs may collide (false positives). The parameters
k(number of hash functions per band) andL(number of bands) allow tuning this speed/recall trade-off.
Sub-Linear Search Complexity
LSH's primary advantage is reducing the computational complexity of similarity search from O(N) (comparing a query to every item in a database) to a sub-linear or near-constant time operation on average.
- Mechanism: Instead of a linear scan, the query is hashed to one or more buckets. Only the items within those buckets are considered as candidates for detailed comparison.
- Impact on Blocking: In entity resolution, this transforms an intractable
O(N²)pairwise matching problem across millions of records into a manageable process. Candidate pairs are generated only within hash-collision blocks, reducing comparisons by orders of magnitude (e.g., from billions to millions).
Hash Family for Specific Metrics
An LSH scheme is defined for a specific distance or similarity metric. Different metrics require mathematically distinct hash function families.
- Common LSH Families:
- Hamming Distance: Uses bit sampling functions.
- Jaccard Similarity: Uses MinHash (Min-wise independent permutations).
- Cosine Similarity: Uses SimHash (random hyperplane projections).
- Euclidean Distance (
L2): Uses p-stable distributions (e.g., E2LSH).
- Selection Criteria: The choice of LSH family is dictated by the similarity measure most appropriate for the data (e.g., MinHash for set-based token similarity, SimHash for text embedding cosine similarity).
Amplification via AND-OR Construction
The performance of a basic LSH function is amplified using a structured AND-OR concatenation of multiple hash functions to sharpen the probability curve.
- AND Construction (
khashes): Concatenatekindependent hash functions. Two items hash to the same bucket only if allkfunctions agree. This reduces false positives (makes collisions stricter). - OR Construction (
Lbands): CreateLindependent hash tables, each with its own AND-composed hash function. Two items are candidate pairs if they collide in any of theLtables. This increases recall (reduces false negatives). - Tuning: Adjusting
kandLmoves the system along a precision-recall curve, defined by theS-curveprobability function1 - (1 - p^k)^L.
Indexing vs. Querying Symmetry
A key operational feature of LSH is the symmetry between indexing and querying. The same hash functions are applied identically to both database records and incoming queries.
- Indexing Phase: All database items are pre-processed and inserted into
Lhash tables using their computed hash signatures. - Query Phase: The query item is hashed with the same
Lfunctions, and the corresponding buckets are probed to retrieve candidate neighbors. - Benefit: This symmetry enables extremely fast online querying, as the computational overhead is primarily in the one-time index build. The query process is a simple hash computation and bucket lookup.
Application in Entity Resolution Blocking
In entity resolution, LSH is predominantly used in the blocking or candidate generation stage to efficiently find record pairs that are potential matches.
- Workflow:
- Records are converted into a similarity-space representation (e.g., token sets, text embeddings).
- An appropriate LSH family (e.g., MinHash for tokens, SimHash for embeddings) hashes records into blocks.
- Only records within the same block are passed to the more expensive, precise matching stage (e.g., a classifier or detailed similarity scorer).
- Scalability: This is critical for deduplication and record linkage on datasets with millions or billions of records, where naive all-pairs comparison is computationally prohibitive.
LSH vs. Other Similarity Search Methods
A comparison of approximate and exact methods for finding similar records, a core task in entity resolution pipelines.
| Feature / Metric | Locality-Sensitive Hashing (LSH) | Exact k-Nearest Neighbors (k-NN) | Tree-Based Indexing (e.g., KD-Trees, Ball Trees) |
|---|---|---|---|
Primary Use Case | Approximate nearest neighbor search at scale | Exact nearest neighbor search on smaller datasets | Exact nearest neighbor search on low-to-moderate dimensional data |
Algorithmic Principle | Randomized hashing where similar items collide with high probability | Exhaustive pairwise distance calculation | Hierarchical space partitioning using tree structures |
Scalability with Data Size (N) | Sub-linear or near-linear query time (O(N) or better with pre-processing) | Linear query time (O(N)) without indexing | Logarithmic query time (O(log N)) in ideal, low-dimensional cases |
Scalability with Dimensionality (d) | Tolerant of high dimensionality; performance degrades gracefully | Suffers from the curse of dimensionality; query time is O(dN) | Performance severely degrades with high d (curse of dimensionality); often worse than brute force for d > 20 |
Result Guarantee | Probabilistic (high recall, configurable precision) | Deterministic (100% precision and recall) | Deterministic (100% precision and recall) |
Typical Query Time | < 10 ms for candidate generation in large datasets |
| Varies widely; can be < 10 ms for low-d, but degrades to brute-force speed for high-d |
Memory Overhead for Index | Low to moderate (stores multiple hash tables and buckets) | None (no index) or high (for cached distance matrices) | Moderate to high (stores tree structure, can be large for high-d data) |
Common Role in Entity Resolution | Blocking: Rapidly generates candidate pairs for detailed matching | Benchmarking: Provides ground truth for evaluating approximate methods | Not typically used for blocking due to poor high-dimensional scaling |
Tunable Parameters | Number of hash tables (L), hash functions per table (k), threshold | Distance metric (e.g., Euclidean, Cosine), k (number of neighbors) | Tree type, leaf size, distance metric, splitting rule |
Handles Sparse Data (e.g., Text) | |||
Supports Dynamic Updates (Insert/Delete) | |||
Integration with Embeddings | Directly operates on dense vector embeddings | Directly operates on dense vector embeddings | Best suited for dense, low-dimensional vectors |
Frequently Asked Questions
Locality-sensitive hashing (LSH) is a foundational algorithmic technique for approximate nearest neighbor search and blocking in large-scale data processing. These questions address its core mechanisms, applications, and trade-offs.
Locality-sensitive hashing (LSH) is a family of algorithmic techniques that hash input items so that similar items map to the same hash value, or 'bucket', with high probability, while dissimilar items map to different buckets. It works by defining a hash function family where the probability of collision (hashing to the same value) is high for similar points and low for distant points. The core mechanism involves:
- Hash Function Design: Selecting or constructing functions (e.g., based on random projections for cosine similarity, or bit sampling for Hamming distance) that preserve locality.
- Amplification: Using multiple hash functions and concatenating their outputs (AND construction) to reduce false positives, or using multiple hash tables (OR construction) to increase recall and reduce false negatives.
- Bucketing: Items that hash to the same value are placed in the same candidate bucket for subsequent detailed comparison.
This process transforms an intractable brute-force nearest neighbor search (O(N²) for N items) into an approximate, sub-linear time operation by only comparing items within the same hash buckets.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Locality-Sensitive Hashing is a foundational technique within the broader domain of entity resolution. These related concepts define the processes, algorithms, and evaluation metrics used to identify and consolidate records representing the same real-world entity.
Blocking
Blocking is a pre-processing technique in entity resolution that partitions records into candidate groups, or 'blocks', to drastically reduce the number of pairwise comparisons required. Instead of comparing every record to every other record (an O(n²) operation), only records within the same block are compared. Common blocking keys include:
- The first three letters of a surname.
- A geographic area code.
- A hashed value of a normalized attribute. LSH is a sophisticated form of blocking where the 'blocks' are hash buckets, and similarity, not exact key equality, determines bucket placement.
Probabilistic Matching
Probabilistic Matching is a statistical approach to entity resolution that calculates the likelihood that two records refer to the same entity. It contrasts with deterministic (rule-based) matching. The core idea is to weigh the agreement or disagreement on each attribute (e.g., name, date of birth, address) based on its discriminative power. A common framework is the Fellegi-Sunter model, which estimates:
- m-probability: The probability that an attribute agrees given the records are a match.
- u-probability: The probability that an attribute agrees given the records are a non-match. These probabilities are combined into a composite match score, with a threshold determining the final link decision. LSH serves as a highly efficient candidate generation step for probabilistic matching systems.
Similarity Measures & Metrics
Entity resolution relies on quantitative measures to compare records. LSH families are designed to preserve specific similarity metrics in the hashing process. Key measures include:
- Jaccard Similarity: For sets, it's the size of the intersection divided by the size of the union. MinHash is an LSH family for Jaccard similarity.
- Cosine Similarity: For vectors, it's the cosine of the angle between them. SimHash is a well-known LSH for cosine similarity.
- Hamming Distance: The number of positions at which corresponding symbols differ. Used for bit vectors.
- Levenshtein Distance: The minimum number of single-character edits (insert, delete, substitute) to change one string into another. The choice of similarity metric dictates the appropriate LSH algorithm and the definition of 'locality'.
Deduplication
Deduplication is the specific task of identifying and removing duplicate records that refer to the same entity within a single dataset. It is a core application of entity resolution focused on data hygiene and quality. The process typically involves:
- Standardization (canonicalization) of data fields.
- Blocking or LSH to create candidate duplicate pairs.
- Pairwise comparison using similarity scores or machine learning models.
- Clustering matched pairs into groups representing the same entity (e.g., finding connected components in a match graph).
- Survivorship or Golden Record creation to merge the group into one authoritative record. LSH is critical for scaling deduplication to large datasets.
Approximate Nearest Neighbor (ANN) Search
Approximate Nearest Neighbor search is the fundamental computational problem that LSH is designed to solve efficiently. Given a query point in a high-dimensional space (e.g., a text embedding or image feature vector) and a large database of points, ANN search finds points that are approximately the closest to the query, trading perfect accuracy for massive speed and memory gains. LSH achieves this by hashing similar points into the same buckets with high probability. This is directly analogous to entity resolution, where the 'database' is the set of all records, and the 'query' is a new record needing resolution. ANN is the engine behind scalable semantic search, recommendation systems, and clustering.
Evaluation: Precision & Recall
The performance of an LSH-based entity resolution pipeline is rigorously evaluated using precision and recall, derived from a confusion matrix of record pairs.
- Precision: The fraction of predicted matches that are correct.
Precision = True Positives / (True Positives + False Positives). High precision means few false matches. - Recall: The fraction of all true matches that were successfully retrieved.
Recall = True Positives / (True Positives + False Negatives). High recall means few missed matches. LSH involves a trade-off: increasing the number of hash tables or bands generally improves recall (finds more true matches) but can reduce precision (lets in more false candidates). Tuning LSH parameters (k, L) is often an optimization exercise on this precision-recall curve.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us