arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.16747cs.CLcs.LG
收藏

越稀疏越快速,少即是多:面向长距离Transformer的高效稀疏注意力

Sparser is Faster and Less is More: Efficient Sparse Attention for Long-Range Transformers

ShanghaiTech University(上海科技大学);BIGAI(北京智源人工智能研究院)

Chao Lou, Zixia Jia, Zilong Zheng, Kewei Tu

AI总结:

针对自回归Transformer长序列处理的计算与内存瓶颈,提出结合评分网络与可微SPARSEK算子的稀疏注意力机制,实现生成阶段线性复杂度与恒定内存,性能与速度优于现有方法且易集成到预训练LLMs。

摘要:

自注意力机制固有的二次计算复杂度与巨大的KV内存需求,使得自回归Transformer(尤其是在扩展上下文窗口场景下)高效处理长序列面临重大挑战。本文提出SPARSEK Attention——一种新型稀疏注意力机制,旨在在保持性能的同时突破上述计算与内存瓶颈。该方法结合了一个评分网络与可微top-k掩码算子SPARSEK,为每个查询选择固定数量的KV对,从而支持基于梯度的优化。因此,SPARSEK Attention在生成阶段具备线性时间复杂度与恒定内存占用。实验结果表明,SPARSEK Attention的表现优于以往的稀疏注意力方法,在训练与推理阶段均能实现显著的速度提升,在语言建模与下游任务中表现尤为突出。此外,该方法可无缝集成到预训练大语言模型(LLMs)中,仅需极少微调,为各类应用中有效处理长距离依赖提供了实用方案。

英文摘要:

Accommodating long sequences efficiently in autoregressive Transformers, especially within an extended context window, poses significant challenges due to the quadratic computational complexity and substantial KV memory requirements inherent in self-attention mechanisms. In this work, we introduce SPARSEK Attention, a novel sparse attention mechanism designed to overcome these computational and memory obstacles while maintaining performance. Our approach integrates a scoring network and a differentiable top-k mask operator, SPARSEK, to select a constant number of KV pairs for each query, thereby enabling gradient-based optimization. As a result, SPARSEK Attention offers linear time complexity and constant memory footprint during generation. Experimental results reveal that SPARSEK Attention outperforms previous sparse attention methods and provides significant speed improvements during both training and inference, particularly in language modeling and downstream tasks. Furthermore, our method can be seamlessly integrated into pre-trained Large Language Models (LLMs) with minimal fine-tuning, offering a practical solution for effectively managing long-range dependencies in diverse applications.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑