MoBA:面向长上下文大语言模型的混合块注意力机制

MoBA: Mixture of Block Attention for Long-Context LLMs

杨植麟 Zhilin Yang · Moonshot AI · 2025-02-18 · arXiv:2502.13189 ↗ · 被引 165

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

摘要 · Abstract

扩展有效上下文长度对于推动大语言模型迈向通用人工智能至关重要。然而,传统注意力机制固有的二次计算复杂度带来了高昂的开销。现有方法要么引入强偏置结构(如汇聚注意力或窗口注意力),这些结构具有任务特异性;要么将注意力机制彻底修改为线性近似,其在复杂推理任务中的性能尚未得到充分探索。本文提出了一种遵循“少结构”原则的解决方案,允许模型自主决定关注位置,而非引入预定义偏置。我们引入了混合块注意力(MoBA),这是一种将混合专家(MoE)原理应用于注意力机制的创新方法。该新型架构在长上下文任务上表现出优越性能,同时具备一个关键优势:能够在全注意力和稀疏注意力之间无缝切换,从而在提升效率的同时避免性能下降的风险。MoBA 已部署用于支持 Kimi 的长上下文请求,并在大语言模型的高效注意力计算方面展现了显著进展。我们的代码可在 https://github.com/MoonshotAI/MoBA 获取。

Scaling the effective context length is essential for advancing large language models (LLMs) toward artificial general intelligence (AGI). However, the quadratic increase in computational complexity inherent in traditional attention mechanisms presents a prohibitive overhead. Existing approaches either impose strongly biased structures, such as sink or window attention which are task-specific, or radically modify the attention mechanism into linear approximations, whose performance in complex reasoning tasks remains inadequately explored. In this work, we propose a solution that adheres to the ``less structure'' principle, allowing the model to determine where to attend autonomously, rather than introducing predefined biases. We introduce Mixture of Block Attention (MoBA), an innovative approach that applies the principles of Mixture of Experts (MoE) to the attention mechanism. This novel architecture demonstrates superior performance on long-context tasks while offering a key advantage: the ability to seamlessly transition between full and sparse attention, enhancing efficiency without the risk of compromising performance. MoBA has already been deployed to support Kimi's long-context requests and demonstrates significant advancements in efficient attention computation for LLMs. Our code is available at https://github.com/MoonshotAI/MoBA.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 12)

阅读逐段中英对照全文 →