Abstract
Edit distance similarity search, also called approximate pattern matching, is a fundamental problem with widespread database applications. The goal of the problem is to preprocess $n$ strings of length $d$, to quickly answer queries $q$ of the form: if there is a database string within edit distance $r$ of $q$, return a database string within edit distance $cr$ of $q$. Previous approaches to this problem either rely on very large (superconstant) approximation ratios $c$, or very small search radii $r$. Outside of a narrow parameter range, these solutions are not competitive with trivially searching through all $n$ strings. In this work give a simple and easy-to-implement hash function that can quickly answer queries for a wide range of parameters. Specifically, our strategy can answer queries in time $\tilde{O}(d3^rn^{1/c})$. The best known practical results require $c \gg r$ to achieve any correctness guarantee; meanwhile, the best known theoretical results are very involved and difficult to implement, and require query time at least $24^r$. Our results significantly broaden the range of parameters for which we can achieve nontrivial bounds, while retaining the practicality of a locality-sensitive hash function. We also show how to apply our ideas to the closely-related Approximate Nearest Neighbor problem for edit distance, obtaining similar time bounds.
Introduction
Similarity search is a cornerstone of computer science, used in everything from genomic sequencing to spell checkers. The goal is simple: given a database of $n$ strings, find the one closest to a query string $q$. When "closeness" is measured by edit distance (the number of insertions, deletions, and replacements needed to transform one string into another), the problem becomes notoriously difficult.
For high-dimensional data, we hit the "curse of dimensionality," where searching the database becomes no faster than a brute-force linear scan. While Locality-Sensitive Hashing (LSH) has solved this for Euclidean and Hamming spaces, edit distance has remained a "holy grail." Previous theoretical solutions were either extremely complex to implement or suffered from query times that grew exponentially with the search radius $r$ (e.g., $24^r$), making them impractical for anything but the smallest distances. This paper introduces the first LSH scheme for edit distance that provides provable worst-case guarantees by combining string embedding and bit-sampling into a single randomized process.
Methodology
The proposed hash function $h_\rho(x)$ treats the hashing process as a random walk through the dynamic programming table used to calculate edit distance.
Integrated Hashing and Oblivious Synchronization
Unlike previous approaches that first embed a string into Hamming space and then apply a standard LSH, this method combines both steps. This "one-shot" approach allows the hash to account for potential alignments while deciding which characters to sample. The hash function uses a random "underlying function" $\rho$ that maps (character, position) pairs to random values. This ensures that if two strings are similar, their hashes are likely to "synchronize" and produce identical outputs despite shifts caused by insertions or deletions.
Three-Action Logic
As the algorithm scans a string, it chooses between three actions based on random thresholds:
- Hash-insert: Add a special null character $\perp$ to the hash.
- Hash-replace: Add $\perp$ and skip the current character.
- Hash-match: Add the current character to the hash and move forward.
The mapping of these actions to the transitions in the edit distance grid is defined by the following logic:
Key Insights and Results
The most significant breakthrough is the realization that by accepting a polynomial dependence on $n$ (the $n^{1/c}$ term common in LSH), one can drastically reduce the exponential dependence on the search radius $r$. The author proves that strings collide in this hash if and only if a "greedy" sequence of edits can transform one into the other. This allows the use of random walk analysis on a 2D grid to bound collision probabilities.
Performance Bounds
- Query Time: The algorithm achieves a query time of $\tilde{O}(d^3 r n^{1/c})$, where $d$ is string length, $r$ is the radius, $n$ is the database size, and $c$ is the approximation factor.
- Space Complexity: The data structure requires $O(3^r n^{1+1/c} + dn)$ space.
- Theoretical Superiority: For an approximation factor $c=1.5$ and typical genomic data parameters (e.g., UniRef90 dataset), this method becomes more efficient than previous state-of-the-art tree-based methods (CGL trees) once the search radius $r$ is greater than 4.
Conclusion
While the paper significantly improves the exponential term, it doesn't eliminate it entirely (the $3^r$ in the space bound). Recent work in fine-grained complexity suggests that some form of exponential dependence on $r$ might be unavoidable for edit distance. Additionally, the $d^3$ factor in the query time is somewhat high for very long strings. Future work could focus on optimizing this factor or exploring how these theoretical bounds translate into practical, high-performance software implementations compared to existing heuristics like EmbedJoin or MinJoin.
Summary updated