arXiv:2507.06457cs.CL2025-07被引 34

系统评估混合线性注意力,找到高效长序列建模的最优组合方式。

A Systematic Analysis of Hybrid Linear Attention

  • 对比六种线性注意力机制在混合架构中的表现
  • 发现3:1至6:1的线性与全注意力比例最利于召回性能
  • 推荐HGRN-2或GatedDeltaNet用于高效率长序列建模

Transformer在处理长序列时面临二次复杂度和内存瓶颈,促使采用固定状态大小的线性注意力机制。然而,线性模型常因记忆能力有限而表现不佳,催生了结合线性与全注意力层的混合架构。尽管混合架构研究广泛,但线性注意力组件的选择仍缺乏深入探讨。我们系统评估了从向量递归到先进门控机制的多种线性注意力模型,涵盖独立与混合应用。为此,训练并开源了72个模型:36个340M参数(200亿词训练)、36个13亿参数(1000亿词训练),覆盖六种线性注意力变体及五种混合比例。在标准语言建模与召回任务上的基准测试表明,优秀独立线性模型未必在混合中表现优异;语言建模性能随线性-全注意力比变化稳定,但召回性能显著提升,尤其当全注意力层占比高于1/3时。研究揭示选择性门控、层次递归与可控遗忘是高效混合模型的关键。建议采用如HGRN-2或GatedDeltaNet,线性-全注意力比介于3:1至6:1之间,以实现接近Transformer的召回能力且更高效。模型已开源至https://huggingface.co/collections/m-a-p/hybrid-linear-attention-research-686c488a63d609d2f20e2b1e。

原文摘要 · Abstract (English)

Transformers face quadratic complexity and memory issues with long sequences, prompting the adoption of linear attention mechanisms using fixed-size hidden states. However, linear models often suffer from limited recall performance, leading to hybrid architectures that combine linear and full attention layers. Despite extensive hybrid architecture research, the choice of linear attention component has not been deeply explored. We systematically evaluate various linear attention models across generations - vector recurrences to advanced gating mechanisms - both standalone and hybridized. To enable this comprehensive analysis, we trained and open-sourced 72 models: 36 at 340M parameters (20B tokens) and 36 at 1.3B parameters (100B tokens), covering six linear attention variants across five hybridization ratios. Benchmarking on standard language modeling and recall tasks reveals that superior standalone linear models do not necessarily excel in hybrids. While language modeling remains stable across linear-to-full attention ratios, recall significantly improves with increased full attention layers, particularly below a 3:1 ratio. Our study highlights selective gating, hierarchical recurrence, and controlled forgetting as critical for effective hybrid models. We recommend architectures such as HGRN-2 or GatedDeltaNet with a linear-to-full ratio between 3:1 and 6:1 to achieve Transformer-level recall efficiently. Our models are open-sourced at https://huggingface.co/collections/m-a-p/hybrid-linear-attention-research-686c488a63d609d2f20e2b1e.

注意力机制线性注意力混合架构长序列建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。