Sequence distance embeddings

Graham Cormode

TL;DR

This thesis introduces a powerful framework for approximating distances between sequences (strings, permutations, and vectors) by embedding them into simpler metric spaces like $L_1$ or Hamming space. By transforming complex "edit-style" distances into vector norms, the author enables massive speedups for tasks like pattern matching, clustering, and nearest-neighbor search, often reducing quadratic-time problems to near-linear time.

What Problem Does This Paper Address?

In computer science, we often need to know how "similar" two sequences are. Whether it's comparing DNA strands, auditing network traffic, or deduplicating web pages, we rely on distance metrics. However, we face a major bottleneck: the most useful metrics are often the most expensive to compute.

For example, the standard Edit Distance (Levenshtein) typically requires quadratic time ($O(n^2)$), which is a non-starter for massive datasets. More complex distances, like Reversal Distance (used in biology to track genome rearrangements), are actually NP-hard to compute exactly. Furthermore, in modern "streaming" scenarios, we often can't even store the data; we need to process it on the fly in a single pass.

This thesis tackles the challenge of computing these distances efficiently at scale. The core question is: Can we transform these complex sequences into simple vectors such that the distance between the vectors accurately approximates the original distance between the sequences?

Methods

The author utilizes Embeddings—mathematical mappings from a "hard" space to an "easy" space—with a focus on two main areas:

  1. Permutation Embeddings: For distances like Swap, Reversal, and Transposition distance, the author develops embeddings into Hamming space. The trick involves representing a permutation as a binary matrix that captures "breakpoints" or adjacencies between elements. If two permutations are similar, their matrix representations will have very few differing entries.
  2. String Embeddings (Edit Sensitive Parsing): To handle string edit distance with moves (allowing blocks of text to be moved), the author introduces Edit Sensitive Parsing (ESP). ESP is a hierarchical parsing technique that is "resilient" to local edits. A single change in a string only affects a small, logarithmic number of nodes in its parse tree. By representing the string as a vector of the features found in this tree, the edit distance is approximated by the $L_1$ distance between these vectors.
  3. Sketching and Streaming: Once sequences are in vector space, the author uses Stable Distributions (like the Cauchy distribution) to create "sketches." These are tiny, fixed-size summaries (e.g., a few kilobytes) that can be computed in a single pass over a data stream. Because these sketches are linear, they are "composable"—you can subtract the sketch of stream A from the sketch of stream B to estimate their distance without ever seeing the full datasets simultaneously.

Datasets

The thesis evaluates these methods using both synthetic and high-volume real-world data:

  • Synthetic Data: Sequences generated using Zipf distributions with varying skewness to test the robustness of streaming algorithms.
  • Network NetFlow Data: 26MB of real IP traffic traces used to test Hamming norm approximations for detecting anomalies like Denial of Service (DoS) attacks.
  • AT&T Cellular Data: A massive dataset (34MB per day) representing call volumes across 20,000 base stations in the US. This was used to test the efficiency and quality of clustering algorithms (like k-means) when using approximate sketched distances.

Key Insights and Ideas

  • The Power of Breakpoints: For permutations, you don't need to solve the sorting problem to estimate the distance. Simply counting how many pairs of elements are no longer adjacent (breakpoints) provides a constant-factor approximation (usually within a factor of 2 or 3) that is much easier to compute.
  • Locality is Everything: The ESP technique works because it ensures that an edit operation has a "local" effect on the hierarchical representation. This is the "aha" moment for string similarity: if your parsing method isn't sensitive to shifts, you can't embed it effectively.
  • Sketches are Composable: The fact that sketches based on stable distributions are linear is a game-changer for distributed systems. Two different sensors can sketch their own data independently, and a central server can combine them to find the global difference without the sensors ever talking to each other.
  • Approximation as a Feature, Not a Bug: In tasks like k-means clustering, the author found that using approximate distances via sketches sometimes improved the clustering quality or reached a stable solution faster. The small "noise" introduced by the approximation can help the algorithm escape local minima.

Key Results

  • Massive Speedups: Clustering large tabular data using sketches was 3 to 10 times faster than using exact distance computations.
  • High Accuracy: In network monitoring tasks, the sketching method estimated the number of distinct items (Hamming norm) with less than 10% error using only a few kilobytes of memory, significantly outperforming traditional sampling methods.
  • Near-Linear Pattern Matching: The ESP embedding allowed for an $O(n \log n)$ time algorithm for approximate pattern matching with moves, a significant improvement over the traditional quadratic bounds.
  • Theoretical Bounds: The author proved that while permutation distances can be embedded with constant distortion, string edit distance (without moves) is much harder, providing lower bounds on how much distortion is inevitable (e.g., at least 4/3 for $L_1$ embeddings).

Limitations and Future Work

  • The "Moves" Requirement: The most effective string embeddings in this work require the "move" operation to be part of the edit distance. Embedding the standard Levenshtein edit distance (only inserts, deletes, substitutions) into a sketchable space with low distortion remains an open and very difficult problem.
  • Distortion Factors: While $O(\log n \log^* n)$ is a great theoretical result for string embeddings, the constant factors can be large in practice, meaning the "approximate" distance might be significantly larger than the true distance, even if it preserves the relative ordering of similarity.
  • Weighted Operations: The current framework treats all edits as having "unit cost." Real-world applications (like bioinformatics) often require different costs for different types of mutations, which adds another layer of complexity to the embedding process.

Summary updated

BibTeX
@inproceedings{cormode2003sequence,
  author = {Graham Cormode},
  title = {{Sequence distance embeddings}},
  booktitle = {Undefined},
  year = {2003},
  url = {https://openreview.net/forum?id=pROjPoit6Y},
}
Figure