TransMamba:一种序列级混合 Transformer-Mamba 语言模型

TransMamba: A Sequence-Level Hybrid Transformer-Mamba Language Model

孙兴武 Xingwu Sun · Tencent Hunyuan · 2025-03-31 · arXiv:2503.24067 ↗ · 被引 3

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

Transformer 是现代大型语言模型的基石,但其二次计算复杂度限制了长序列处理的效率。最近 Mamba(一种具有线性复杂度的状态空间模型)的进展提供了有前景的效率提升,但存在上下文学习不稳定和多任务泛化能力差的问题。一些工作采用层级混合结构,结合 Transformer 和 Mamba 层,旨在充分利用两者的优势。本文提出 TransMamba,一种新颖的序列级混合框架,通过共享参数矩阵(QKV 和 CBx)统一 Transformer 和 Mamba,从而能在不同 token 长度和层上动态切换注意力与 SSM 机制。我们设计了 Memory Converter,通过将注意力输出转换为 SSM 兼容状态来桥接 Transformer 和 Mamba,确保在转换发生的 TransPoint 处信息流无缝衔接。还深入探索了 TransPoint 调度以平衡效果与效率。大量实验表明,与单一和混合基线相比,TransMamba 实现了更优的训练效率和性能,并在序列级验证了 Transformer 与 Mamba 范式之间更深层的一致性,为下一代语言建模提供了可扩展的解决方案。代码和数据见 https://github.com/Yixing-Li/TransMamba。

Transformers are the cornerstone of modern large language models, but their quadratic computational complexity limits efficiency in long-sequence processing. Recent advancements in Mamba, a state space model (SSM) with linear complexity, offer promising efficiency gains but suffer from unstable contextual learning and multitask generalization. Some works conduct layer-level hybrid structures that combine Transformer and Mamba layers, aiming to make full use of both advantages. This paper proposes TransMamba, a novel sequence-level hybrid framework that unifies Transformer and Mamba through shared parameter matrices (QKV and CBx), and thus could dynamically switch between attention and SSM mechanisms at different token lengths and layers. We design the Memory Converter to bridge Transformer and Mamba by converting attention outputs into SSM-compatible states, ensuring seamless information flow at TransPoints where the transformation happens. The TransPoint scheduling is also thoroughly explored for balancing effectiveness and efficiency. We conducted extensive experiments demonstrating that TransMamba achieves superior training efficiency and performance compared to single and hybrid baselines, and validated the deeper consistency between Transformer and Mamba paradigms at sequence level, offering a scalable solution for next-generation language modeling. Code and data are available at https://github.com/Yixing-Li/TransMamba

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 14)

阅读逐段中英对照全文 →