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

从Transformer到SSM:将二次复杂度知识蒸馏到亚二次复杂度模型

Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models

Carnegie Mellon University(卡内基梅隆大学);MBZUAI(穆罕默德·本·扎耶德人工智能大学)

Aviv Bick, Kevin Y. Li, Eric P. Xing, J. Zico Kolter, Albert Gu

AI总结:

针对Transformer推理的二次复杂度问题,提出MOHAWK方法,将预训练Transformer蒸馏到SSM等亚二次架构,通过匹配混合矩阵、隐藏单元及端到端预测,用少量数据实现高性能,为非Transformer模型构建提供新途径。

摘要:

Transformer架构已成为语言建模等领域的主导范式,但由于其二次时间复杂度的自注意力机制,在许多推理场景中表现不佳。最近提出的亚二次复杂度架构(如Mamba)已显示出潜力,但与最强大的Transformer模型相比,其预训练使用的计算资源要少得多。在这项工作中,我们提出了一种能够将预训练Transformer架构蒸馏到替代架构(如状态空间模型SSM)的方法。我们方法的核心思想是,我们可以将Transformer和SSM都视为对token序列应用不同形式的混合矩阵。因此,我们可以通过在SSM中匹配不同粒度的信息来逐步蒸馏Transformer架构:首先匹配混合矩阵本身,然后匹配每个块的隐藏单元,最后匹配端到端预测。我们的方法名为MOHAWK,能够使用仅3B个token蒸馏出基于Phi-1.5架构的Mamba-2变体(Phi-Mamba),并使用5B个token蒸馏出混合版本(Hybrid Phi-Mamba)。尽管使用的训练数据不到从头训练模型通常所用数据的1%,Phi-Mamba的性能仍显著优于所有以往的开源非Transformer模型。MOHAWK使SSM等模型能够利用训练Transformer架构所投入的计算资源,为构建此类模型开辟了新途径。

英文摘要:

Transformer architectures have become a dominant paradigm for domains like language modeling but suffer in many inference settings due to their quadratic-time self-attention. Recently proposed subquadratic architectures, such as Mamba, have shown promise, but have been pretrained with substantially less computational resources than the strongest Transformer models. In this work, we present a method that is able to distill a pretrained Transformer architecture into alternative architectures such as state space models (SSMs). The key idea to our approach is that we can view both Transformers and SSMs as applying different forms of mixing matrices over the token sequences. We can thus progressively distill the Transformer architecture by matching different degrees of granularity in the SSM: first matching the mixing matrices themselves, then the hidden units at each block, and finally the end-to-end predictions. Our method, called MOHAWK, is able to distill a Mamba-2 variant based on the Phi-1.5 architecture (Phi-Mamba) using only 3B tokens and a hybrid version (Hybrid Phi-Mamba) using 5B tokens. Despite using less than 1% of the training data typically used to train models from scratch, Phi-Mamba boasts substantially stronger performance compared to all past open-source non-Transformer models. MOHAWK allows models like SSMs to leverage computational resources invested in training Transformer-based architectures, highlighting a new avenue for building such models.

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

↑