Intermediate N-Gramming: Deterministic and Fast N-Grams For Large N and Large Datasets
By: Ryan R. Curtin , Fred Lu , Edward Raff and more
Potential Business Impact:
Finds popular word patterns much faster.
The number of n-gram features grows exponentially in n, making it computationally demanding to compute the most frequent n-grams even for n as small as 3. Motivated by our production machine learning system built on n-gram features, we ask: is it possible to accurately, deterministically, and quickly recover the top-k most frequent n-grams? We devise a multi-pass algorithm called Intergrams that constructs candidate n-grams from the preceding (n - 1)-grams. By designing this algorithm with hardware in mind, our approach yields more than an order of magnitude speedup (up to 33x!) over the next known fastest algorithm, even when similar optimizations are applied to the other algorithm. Using the empirical power-law distribution over n-grams, we also provide theory to inform the efficacy of our multi-pass approach. Our code is available at https://github.com/rcurtin/Intergrams.
Similar Papers
Zipf-Gramming: Scaling Byte N-Grams Up to Production Sized Malware Corpora
Cryptography and Security
Finds new computer viruses much faster.
Infini-gram mini: Exact n-gram Search at the Internet Scale with FM-Index
Computation and Language
Searches huge internet text fast and cheap.
Explainable identification of similarities between entities for discovery in large text
Information Retrieval
Finds hidden meaning in texts by comparing word groups.