about
Infini-Gram: Scaling Unbounded N-Gram Language Models to a Trillion Tokens (arxiv.org)
3 points by PaulHoule on Feb 7, 2024 | hide | past | pdf | discuss on HN

In plain words: An n-gram model guesses the next word from how often preceding words appeared; this one allows any length and searches 5 trillion tokens in milliseconds, without precomputed count tables. It guessed the next word right 47% of the time and cut a neural model's errors.

Abstract · Infini-gram: Scaling Unbounded n-gram Language Models to a Trillion Tokens

Are $n$-gram language models still relevant in this era of neural large language models (LLMs)? Our answer is yes, and we showcase their values in both text analysis and improving neural LLMs. This was done by modernizing $n$-gram LMs in two aspects. First, we train them at the same data scale as neural LLMs -- 5 trillion tokens. This is the largest $n$-gram LM ever built. Second, existing $n$-gram LMs use small $n$ which hinders their performance; we instead allow $n$ to be arbitrarily large, by introducing a new $\infty$-gram LM with backoff. Instead of pre-computing $n$-gram count tables (which would be very expensive), we develop an engine named infini-gram -- powered by suffix arrays -- that can compute $\infty$-gram (as well as $n$-gram with arbitrary $n$) probabilities with millisecond-level latency. The $\infty$-gram framework and infini-gram engine enable us to conduct many novel and interesting analyses of human-written and machine-generated text: we find that the $\infty$-gram LM has fairly high accuracy for next-token prediction (47%), and can complement neural LLMs to greatly reduce their perplexity. When analyzing machine-generated text, we also observe irregularities in the machine--$\infty$-gram agreement level with respect to the suffix length, which indicates deficiencies in neural LLM pretraining and the positional embeddings of Transformers.

Jiacheng Liu, Sewon Min, Luke Zettlemoyer, Yejin Choi, Hannaneh Hajishirzi
arXiv:2401.17377 · cs.CL, cs.AI, cs.IR · submitted Jan 30, 2024 · updated Apr 7, 2025
abstract · pdf · html · Published at COLM 2024, spotlight paper

add comment on HN
Also discussed: May 2024 (142 points, 58 comments) · Feb 2024 (2 points, 1 comment)