Infini-gram: Scaling Unbounded n-gram Language Models to a Trillion Tokens
作者: Jiacheng Liu, Sewon Min, Luke Zettlemoyer, Yejin Choi, Hannaneh Hajishirzi
分类: cs.CL, cs.AI, cs.IR
发布日期: 2024-01-30 (更新: 2025-04-07)
备注: Published at COLM 2024, spotlight paper
💡 一句话要点
提出Infini-gram以提升n-gram语言模型的性能与应用
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: n-gram模型 无限n-gram 语言模型 文本分析 机器生成文本 神经网络 后缀数组 数据规模
📋 核心要点
- 现有的n-gram语言模型在数据规模和n值上受到限制,影响了其性能和应用。
- 本文提出了一种新的无限n-gram模型,通过引入infini-gram引擎,允许n值任意增大并在大规模数据上训练。
- 实验结果显示,$ ext{∞}$-gram LM在下一个标记预测中准确率达到47%,并显著降低了神经LLMs的困惑度。
📝 摘要(中文)
在神经大语言模型(LLMs)盛行的时代,n-gram语言模型依然具有重要价值。本文通过将n-gram模型扩展到5万亿个标记,并引入无限n-gram模型($ ext{∞}$-gram LM)来提升其性能。我们开发了名为infini-gram的引擎,利用后缀数组以毫秒级延迟计算n-gram概率。研究表明,$ ext{∞}$-gram LM在下一个标记预测中具有较高的准确性(47%),并能有效降低神经LLMs的困惑度。通过分析机器生成文本,我们发现了与后缀长度相关的不规则性,揭示了神经LLMs预训练和Transformer位置嵌入的不足。
🔬 方法详解
问题定义:本文旨在解决现有n-gram语言模型在数据规模和n值限制下的性能不足问题。传统n-gram模型通常使用较小的n值,导致其在大规模文本分析中的应用受限。
核心思路:通过引入无限n-gram模型($ ext{∞}$-gram LM),允许n值任意增大,从而提升模型的表达能力和预测性能。同时,开发infini-gram引擎以支持大规模数据的实时计算。
技术框架:整体架构包括数据预处理、infini-gram引擎和模型训练三个主要模块。数据预处理阶段负责将5万亿个标记进行整理,infini-gram引擎则利用后缀数组实现高效的n-gram概率计算,最后进行模型训练以优化参数。
关键创新:最重要的创新在于引入了无限n-gram模型和infini-gram引擎,突破了传统n-gram模型的限制,使得模型能够在更大规模的数据上进行训练和实时推理。
关键设计:在设计上,infini-gram引擎采用后缀数组结构以实现快速查询,模型训练过程中使用了适应大规模数据的优化算法,确保了高效性与准确性。
🖼️ 关键图片
📊 实验亮点
实验结果显示,$ ext{∞}$-gram LM在下一个标记预测中的准确率达到47%,显著优于传统n-gram模型,并能有效降低神经LLMs的困惑度,展示了其在文本生成和分析中的强大潜力。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理、文本生成和机器翻译等。通过提升n-gram模型的性能,可以为文本分析、信息检索和对话系统等提供更为精准的支持,未来可能推动相关技术的进一步发展与应用。
📄 摘要(原文)
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.