The quadratic complexity of self attention in Transformer based LLMs renders long context inference prohibitively expensive. While Sliding Window Attention (SWA), the simplest sparse attention pattern, offers a linear complexity alternative, it suffers from catastrophic long context performance collapse, which stems from two fundamental factors: the training inference mismatch when naively applying SWA to models pretrained with Full Attention (FA), and the inherent structural inability to access distant information when applying SWA to every module at all times. To address these dual challenges, we propose Sliding Window Attention Adaptation (SWAA), a plug and play toolkit of recipes that adapts FA models to SWA without costly pretraining. SWAA systematically combines four core strategies to tackle these distinct issues: (1) Full Attention (FA) Decode and (2) Interleaving FA and SWA layers, which mitigate structural defects by selectively allowing access to distant information; alongside (3) preserving ``sink'' tokens and (4) lightweight fine tuning, which mitigate the training inference mismatch. Our experiments reveal that while isolated strategies are insufficient, specific synergistic combinations effectively recover long context performance. Despite varying computational overheads, our performance efficiency trade off analysis identifies optimal SWAA configurations for diverse scenarios, achieving 30% to 100% speedups for long context inference with acceptable quality retention. Our code, data and model weights are available at https://github.com/yuyijiong/sliding-window-attention-adaptation


翻译:基于Transformer的大型语言模型中自注意力的二次复杂度导致长上下文推理成本过高。尽管最简单的稀疏注意力模式——滑动窗口注意力(SWA)提供了线性复杂度的替代方案,但其存在灾难性的长上下文性能崩塌,这源于两个根本因素:将SWA朴素应用于全注意力(FA)预训练模型时产生的训练-推理不匹配,以及对所有模块始终应用SWA时无法获取远距离信息的固有结构缺陷。为应对上述双重挑战,我们提出滑动窗口注意力自适应(SWAA),这是一个即插即用的工具包方案,能够在无需昂贵预训练的情况下将FA模型适配为SWA。SWAA系统性地结合四项核心策略来解决这些不同问题:(1)全注意力解码和(2)FA与SWA层的交错部署,通过选择性允许访问远距离信息来缓解结构缺陷;同时(3)保留“汇点”词元和(4)轻量级微调以缓解训练-推理不匹配。实验表明,尽管孤立策略效果不足,但特定的协同组合能有效恢复长上下文性能。在考虑不同计算开销的情况下,我们的性能-效率权衡分析为不同场景确定了最优SWAA配置,可在保持可接受质量的同时实现30%至100%的长上下文推理加速。我们的代码、数据和模型权重可在https://github.com/yuyijiong/sliding-window-attention-adaptation获取。

0
下载
关闭预览

相关内容

TransMLA:多头潜在注意力(MLA)即为所需
专知会员服务
23+阅读 · 2025年2月13日
【ICML2022】基于自适应上下文池化的高效表示学习
专知会员服务
20+阅读 · 2022年7月9日
深度学习的下一步:Transformer和注意力机制
云头条
56+阅读 · 2019年9月14日
长文本表示学习概述
云栖社区
15+阅读 · 2019年5月9日
干货 | NLP中的self-attention【自-注意力】机制
机器学习算法与Python学习
12+阅读 · 2018年4月11日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月20日
VIP会员
相关主题
最新内容
综述 | 3D场景图:开放挑战与未来方向
专知会员服务
4+阅读 · 6月22日
21世纪的无人机战争
专知会员服务
4+阅读 · 6月22日
《量子技术的军事任务技术适配与利用》
专知会员服务
4+阅读 · 6月22日
美国从乌克兰无人机战争中学习经验
专知会员服务
7+阅读 · 6月21日
ICML 2026 | 面向视觉语言模型的语义鲁棒性认证
专知会员服务
5+阅读 · 6月21日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员