TensorX
返回文献探索

Paper · arXiv 2503.24067

TransMamba: Flexibly Switching between Transformer and Mamba

Yixing Li, Ruobing Xie, Zhen Yang, Xingwu Sun, Shuaipeng Li, Weidong Han, Zhanhui Kang, Yu Cheng, Chengzhong Xu, Di Wang, Jie Jiang

21 upvotesMarch 31, 2025arXiv 预印本
AI 摘要

TransMamba combines Transformers and Mamba frameworks to leverage the strengths of both, achieving efficient and effective long-sequence processing through shared parameters and dynamic switching mechanisms.

TransformersMambastate space modelshared parameter matricesQKVCBxattention mechanismsMemory converterTransPointsTransPoint schedulingsequence modeling

Abstract

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. This paper proposes TransMamba, a novel framework that unifies Transformer and Mamba through shared parameter matrices (e.g., 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 further improvements. We conducted extensive experiments demonstrating that TransMamba achieves superior training efficiency and performance compared to baselines, and validated the deeper consistency between Transformer and Mamba paradigms, offering a scalable solution for next-generation sequence modeling.

北京市昌平区探索星信息技术及软件开发工作室

京ICP备2026059466号
TransMamba: Flexibly Switching between Transformer and Mamba | TensorX