arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.07887cs.LGcs.CL
收藏

基于 Mamba 的语言模型实证研究

An Empirical Study of Mamba-based Language Models

NVIDIA(英伟达);University of Wisconsin-Madison(威斯康星大学麦迪逊分校);Princeton University(普林斯顿大学);Together AI;Carnegie Mellon University(卡内基梅隆大学);Cartesia AI
Roger Waleffe, Wonmin Byeon, Duncan Riach, Brandon Norick, Vijay Korthikanti, Tri Dao, Albert Gu, Ali Hatamizadeh, Sudhakar Singh, Deepak Narayanan, Garvit Kuls… 展开作者

Roger Waleffe, Wonmin Byeon, Duncan Riach, Brandon Norick, Vijay Korthikanti, Tri Dao, Albert Gu, Ali Hatamizadeh, Sudhakar Singh, Deepak Narayanan, Garvit Kulshreshtha, Vartika Singh, Jared Casper, Jan Kautz, Mohammad Shoeybi, Bryan Catanzaro

AI总结:

本文在相同数据和最高 3.5T tokens 条件下对比 8B 参数 Mamba、Mamba-2、Transformer 及混合模型,发现 Mamba-2-Hybrid 在标准与长上下文任务上整体更优且推理更快。

摘要:

诸如 Mamba 之类的选择性状态空间模型(SSM)克服了 Transformer 的一些缺点,例如随序列长度呈二次增长的计算复杂度,以及键值缓存导致的较大推理期内存需求。此外,近期研究已经表明,SSM 能够匹敌甚至超过 Transformer 的语言建模能力,因此成为一种有吸引力的替代方案。然而,在受控环境下(例如使用相同数据),迄今为止的研究只展示了比较 SSM 与 Transformer 的小规模实验。为了理解这些架构在更大规模上的优势与弱点,我们对在相同数据集上训练、参数量均为 8B、训练 token 数最高达 3.5T 的 Mamba、Mamba-2 和 Transformer 模型进行了直接比较。我们还将这些模型与一种混合架构进行比较,该架构由 43% 的 Mamba-2、7% 的注意力机制和 50% 的 MLP 层组成(Mamba-2-Hybrid)。通过一组多样化任务,我们回答了在更大训练预算下 Mamba 模型是否能够匹敌 Transformer 的问题。结果表明,尽管纯 SSM 在许多任务上匹敌或超过 Transformer,但它们在需要强复制能力或上下文学习能力的任务(例如 5-shot MMLU、Phonebook)或长上下文推理任务上落后于 Transformer。相比之下,我们发现 8B Mamba-2-Hybrid 在所评估的全部 12 项标准任务上均超过 8B Transformer(平均高出 2.65 分),并且据预测,其在推理阶段生成 token 时速度最高可达 8 倍。为验证长上下文能力,我们补充了实验,评估扩展为支持 16K、32K 和 128K 序列的 Mamba-2-Hybrid 与 Transformer 变体。在另外 23 项长上下文任务上,该混合模型平均而言继续紧密匹敌或超过 Transformer。为支持进一步研究,我们作为 NVIDIA Megatron-LM 项目的一部分,发布了检查点以及用于训练模型的代码。

英文摘要:

Selective state-space models (SSMs) like Mamba overcome some of the shortcomings of Transformers, such as quadratic computational complexity with sequence length and large inference-time memory requirements from the key-value cache. Moreover, recent studies have shown that SSMs can match or exceed the language modeling capabilities of Transformers, making them an attractive alternative. In a controlled setting (e.g., same data), however, studies so far have only presented small scale experiments comparing SSMs to Transformers. To understand the strengths and weaknesses of these architectures at larger scales, we present a direct comparison between 8B-parameter Mamba, Mamba-2, and Transformer models trained on the same datasets of up to 3.5T tokens. We also compare these models to a hybrid architecture consisting of 43% Mamba-2, 7% attention, and 50% MLP layers (Mamba-2-Hybrid). Using a diverse set of tasks, we answer the question of whether Mamba models can match Transformers at larger training budgets. Our results show that while pure SSMs match or exceed Transformers on many tasks, they lag behind Transformers on tasks which require strong copying or in-context learning abilities (e.g., 5-shot MMLU, Phonebook) or long-context reasoning. In contrast, we find that the 8B Mamba-2-Hybrid exceeds the 8B Transformer on all 12 standard tasks we evaluated (+2.65 points on average) and is predicted to be up to 8x faster when generating tokens at inference time. To validate long-context capabilities, we provide additional experiments evaluating variants of the Mamba-2-Hybrid and Transformer extended to support 16K, 32K, and 128K sequences. On an additional 23 long-context tasks, the hybrid model continues to closely match or exceed the Transformer on average. To enable further study, we release the checkpoints as well as the code used to train our models as part of NVIDIA's Megatron-LM project.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑