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
提出 TransMamba,一种通过共享 QKV 和 CBx 参数在序列级别统一 Transformer 和 Mamba 的混合框架。 Proposes TransMamba, a sequence-level hybrid framework unifying Transformer and Mamba via shared QKV and CBx parameters.
设计记忆转换器,在转换点实现从注意力机制到 SSM 的无损信息传递。 Designs Memory Converter for lossless information transfer from attention to SSM at TransPoints.
探索转换点调度策略,以平衡不同层和词元长度下的效果与效率。 Explores TransPoint scheduling to balance effectiveness and efficiency across layers and token lengths.
在训练效率和性能上优于 Transformer、Mamba 及混合基线模型。 Demonstrates superior training efficiency and performance over Transformer, Mamba, and hybrid baselines.
验证了 Transformer 与 Mamba 范式在序列级别更深层次的一致性。 Validates deeper consistency between Transformer and Mamba paradigms at the sequence level.
为下一代语言建模提供可扩展的解决方案,支持灵活的结构切换。 Provides a scalable solution for next-generation language modeling with flexible structure switching.
局限 · Limitations
TransMamba 的效率提升受工程优化限制,理论加速未完全实现。 TransMamba's efficiency gain is limited by engineering optimizations; theoretical speedup not fully realized.