Attention, Dynamic Wave and Hybrid Sequence Mixers in Language Models
作者: Dmytro Babarytskyi, Oleksandr Babarytskyi
分类: cs.LG, cs.CL
发布日期: 2026-10-29
备注: 14 pages, 6 figures, 9 tables
💡 一句话要点
提出动态波动层以优化长序列建模效率
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 动态波动层 长序列建模 多头注意力 自然语言处理 模型优化
📋 核心要点
- 现有的大型语言模型在处理长序列时,因多头注意力机制的二次复杂度而面临效率瓶颈。
- 论文提出了一种动态波动递归层,通过输入依赖的衰减和相位调制来优化长序列建模。
- 实验结果表明,混合配置在困惑度上优于纯Transformer和纯波动,且在内存使用上表现出显著优势。
📝 摘要(中文)
大型语言模型(LLMs)依赖多头注意力机制进行序列建模,但在长上下文中面临二次复杂度的限制,促使研究者探索亚二次的递归替代方案。本文提出了一种基于输入依赖的指数衰减和余弦相位调制的动态波动递归层,并在TinyStories数据集上评估了三种配置(纯Transformer、纯波动和混合波动-注意力),结果显示混合配置在困惑度上表现最佳。尽管在内存使用上,纯波动在4096个token的上下文中比未融合的注意力基线减少了78.7%的峰值VRAM,但在训练模式下其成本却高于Transformer。研究表明,递归注意力替代方案的效率提升需相对于具体的注意力后端和实现进行说明。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在处理长序列时,由于多头注意力机制导致的二次复杂度和内存使用问题。现有方法在长上下文中效率低下,限制了模型的扩展性。
核心思路:论文提出的动态波动递归层利用输入依赖的指数衰减和余弦相位调制,旨在通过更高效的递归结构替代传统的注意力机制,从而降低计算复杂度和内存消耗。
技术框架:整体架构包括三种配置:纯Transformer、纯波动和混合波动-注意力。每种配置在TinyStories数据集上进行评估,重点关注困惑度、延迟、吞吐量和峰值VRAM使用。
关键创新:动态波动递归层是本文的核心创新,与传统的注意力机制相比,它通过引入波动特性,显著降低了内存使用和计算延迟,尤其在长序列处理上表现出色。
关键设计:在实验中,纯波动配置在4096个token的上下文中使用了78.7%更少的峰值VRAM,且在训练模式下的成本高于Transformer。此外,提升递归层的速度通过将逐元素操作移出递归循环实现,减少了延迟差距。
🖼️ 关键图片
📊 实验亮点
实验结果显示,混合配置在困惑度上达到5.95,优于纯Transformer的6.93和纯波动的7.26。此外,纯波动在4096个token的上下文中使用的峰值VRAM为1404.3 MB,较未融合的注意力基线减少了78.7%。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理、对话系统和文本生成等。通过优化长序列建模的效率,研究成果能够提升大型语言模型在实际应用中的响应速度和资源利用率,具有重要的实际价值和未来影响。
📄 摘要(原文)
Large Language Models (LLMs) rely on Multi-Head Attention (MHA) for sequence modeling, but scaling to long contexts is constrained by the quadratic cost of attention, motivating sub-quadratic recurrent alternatives. This paper formalizes a Dynamic Wave recurrent layer, based on input-dependent exponential damping and cosine phase modulation, and evaluates three 10.94M-parameter configurations (Pure Transformer, Pure Wave, and Hybrid Wave-Attention) on TinyStories under perplexity, latency, throughput and peak VRAM profiling up to 4096 tokens. The Hybrid configuration reaches the best perplexity, 5.95 on the full held-out split against 6.93 for the Transformer and 7.26 for Pure Wave. The efficiency picture, however, is governed by implementation rather than by architecture. Against an unfused attention baseline, Pure Wave uses 78.7% less peak VRAM at a 4096-token context (1404.3 MB vs. 6601.6 MB); against a fused scaled-dot-product attention kernel the same comparison yields no advantage at all (1404.3 MB vs. 1403.6 MB), and in training mode Pure Wave is 8.3% more expensive than the Transformer. Likewise, hoisting elementwise terms out of the recurrence loop speeds the layer up 2.53-fold with no custom kernel, reducing its latency gap to attention from 2.48-fold to 1.12-fold. A hybrid stack is found to inherit the cost of its more expensive mixer rather than the advantage of its cheaper one, its peak VRAM matching the Pure Transformer to within 0.1%. A closed-form memory model reproduces these measurements and predicts the context length beyond which attention overtakes the vocabulary projection. The findings indicate that reported efficiency gains for recurrent attention replacements must be stated relative to a named attention backend and a named implementation, and that hybridization is best justified on quality grounds.