The Mamba in the Llama: Distilling and Accelerating Hybrid Models
Junxiong Wang, Daniele Paliotta, Avner May, Alexander M. Rush, Tri Dao
摘要
Linear RNN architectures, like Mamba, can be competitive with Transformer models in language modeling while having advantageous deployment characteristics. Given the focus on training large-scale Transformer models, we consider the challenge of converting these pretrained models for deployment. We demonstrate that it is feasible to distill large Transformers into linear RNNs by reusing the linear projection weights from attention layers with academic GPU resources. The resulting hybrid model, which incorporates a quarter of the attention layers, achieves performance comparable to the original Transformer in chat benchmarks and outperforms open-source hybrid Mamba models trained from scratch with trillions of tokens in both chat benchmarks and general benchmarks. Moreover, we introduce a hardware-aware speculative decoding algorithm that accelerates the inference speed of Mamba and hybrid models. Overall we show how, with limited computation resources, we can remove many of the original attention layers and generate from the resulting model more efficiently. Our top-performing model, distilled from Llama3-8B-Instruct, achieves a 29.61 length-controlled win rate on AlpacaEval 2 against GPT-4 and 7.35 on MT-Bench, surpassing the best 8B scale instruction-tuned linear RNN model. We also find that the distilled model has natural length extrapolation, showing almost perfect accuracy in the needle-in-a-haystack test at 20x the distillation length. Code and pre-trained checkpoints are open-sourced at https://github.com/jxiw/MambaInLlama and https://github.com/itsdaniele/speculative_mamba.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 47 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Measuring Massive Multitask Language Understanding 引用了 Language Models are Few-Shot Learners
- MoBA: Mixture of Block Attention for Long-Context LLMs 引用了 Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Measuring Massive Multitask Language Understanding
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Efficiently Modeling Long Sequences with Structured State Spaces
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 TruthfulQA: Measuring How Models Mimic Human Falsehoods
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Test-Time Training Done Right
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Language Models are Few-Shot Learners
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Gated Slot Attention for Efficient Linear-Time Sequence Modeling
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search 引用了 Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
- Direct Preference Optimization: Your Language Model is Secretly a Reward Model 引用了 Language Models are Few-Shot Learners
- TruthfulQA: Measuring How Models Mimic Human Falsehoods 引用了 Measuring Massive Multitask Language Understanding
- Gated Slot Attention for Efficient Linear-Time Sequence Modeling 引用了 Measuring Massive Multitask Language Understanding
- Gated Slot Attention for Efficient Linear-Time Sequence Modeling 引用了 Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
- Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models 引用了 Efficiently Modeling Long Sequences with Structured State Spaces
- Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models 引用了 Language Models are Few-Shot Learners
引用它的顶会 Paper47
- MoBA: Mixture of Block Attention for Long-Context LLMsEnzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du 等NeurIPS 2025 · 219 次引用
- Test-Time Training Done RightTianyuan Zhang, Sai Bi, Yicong Hong, Kai Zhang 等ICLR 2026 · 127 次引用
- Gated Slot Attention for Efficient Linear-Time Sequence ModelingYu Zhang, Songlin Yang, Rui-Jie Zhu, Yue Zhang 等NeurIPS 2024 · 93 次引用
- Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic ModelsAviv Bick, Kevin Y. Li, Eric P. Xing, J. Zico Kolter 等NeurIPS 2024 · 78 次引用
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture SearchYuxian Gu, Qinghao Hu, Haocheng Xi, Junyu Chen 等NeurIPS 2025 · 39 次引用
它引用的 Paper35
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafael Rafailov, Archit Sharma, Eric Mitchell, Christopher D. Manning 等NeurIPS 2023 · 10,924 次引用
- Measuring Massive Multitask Language UnderstandingDan Hendrycks, Collin Burns, Steven Basart, Andy Zou 等ICLR 2021 · 7,905 次引用
- Efficiently Modeling Long Sequences with Structured State SpacesAlbert Gu, Karan Goel, Christopher RéICLR 2022 · 3,482 次引用
- TruthfulQA: Measuring How Models Mimic Human FalsehoodsStephanie Lin, Jacob Hilton, Owain EvansACL 2022 · 3,228 次引用
相关 Paper
- MaTVLM: Hybrid Mamba-Transformer for Efficient Vision-Language ModelingYingyue Li, Bencheng Liao, Wenyu Liu, Xinggang WangICCV 2025 · 1 次引用
- Joint Fine-tuning and Conversion of Pretrained Speech and Language Models towards Linear ComplexityMutian He, Philip N. GarnerICLR 2025
- Gated Linear Attention Transformers with Hardware-Efficient TrainingSonglin Yang, Bailin Wang, Yikang Shen, Rameswar Panda 等ICML 2024 · 390 次引用
- Effective Distillation to Hybrid xLSTM ArchitecturesLukas Hauzenberger, Niklas Schmidinger, Thomas Schmied, Anamaria-Roberta Hartl 等ICML 2026 · 3 次引用
- Mamba Drafters for Speculative DecodingDaewon Choi, Seunghyuk Oh, Saket Dingliwal, Jihoon Tack 等EMNLP Findings 2025 · 1 次引用
