Introduction
Language Models (LMs) are fundamental to modern natural language processing tasks, such as machine translation and speech recognition. They enable systems to distinguish between probable and improbable word sequences. However, as training data scales to massive corpora like the 1-trillion-token Web 1T, the memory requirements for storing these models become a significant bottleneck. Traditional "lossless" data structures, such as Tries, have a theoretical lower bound on size because they must uniquely identify every possible word combination. This paper proposes a paradigm shift: accepting a negligible rate of false positives in exchange for massive space savings using randomized data structures.
Methodology
The core of the proposed approach is the use of Bloomier filters and perfect hash functions to create a highly compact, randomized representation of n-gram probabilities.
The Bloomier Filter and XOR Trick
Unlike standard Bloom filters that only indicate set membership, a Bloomier filter associates a specific value (e.g., a quantized probability) with each item. To retrieve a value for an n-gram $x$, the system uses three hash functions to map $x$ to three locations in a large array. The stored value is reconstructed by XORing the values at these locations with a unique "fingerprint" of the n-gram.
This mechanism ensures that for any n-gram actually present in the training data, the retrieval is perfectly lossless. Errors only occur for unseen n-grams, which may occasionally return a valid-looking but incorrect probability (a false positive).
Perfect Hashing and Construction
To avoid collisions among the stored n-grams, the authors employ perfect hash functions. The construction involves an "ordered matching" algorithm that treats the mapping as a bipartite graph problem between n-grams and array locations. This ensures that each stored item has a unique set of indices that do not conflict with others in the set.
Hierarchical Sanity Checks
To mitigate the impact of false positives, the model implements a hierarchical check. During a lookup for a long sequence (e.g., a 5-gram), the model first verifies its constituent unigram, bigram, and so on. If a shorter prefix is not found, the longer sequence is automatically treated as a false positive and discarded, significantly cleaning the output noise.
Experimental Results
The researchers evaluated the model on the Web 1T 5-gram Corpus and various NIST machine translation benchmarks.
- Memory Efficiency: The randomized model required only 3.08 bytes per n-gram. For the full Web 1T corpus, this resulted in a total size of 10.87 GB, compared to 21.46 GB for a compact Trie. When combined with entropy-based pruning, the model size was further reduced to 3.68 GB.
- Translation Quality: In NIST machine translation tests, the randomized model achieved BLEU scores virtually identical to lossless models. Using 12 "error bits" per n-gram resulted in a false positive rate of approximately 1 in 40,000, which was low enough to have no measurable impact on the translation engine's search algorithm.
Discussion and Limitations
While highly efficient, the approach has some trade-offs. Perfect hash functions are typically static; adding new data requires rebuilding the entire structure, which is computationally expensive for billions of items. Additionally, the construction process requires an ordered matching algorithm that must process the entire dataset, though the authors mitigated this by sharding the data into blocks of 5 million n-grams. Future work may explore more sophisticated quantization methods, such as Lloyd-Max quantization, to further optimize space without increasing the error rate.
Summary updated