arXiv:2505.23520cs.LG2025-05EMNLP被引 3

提出细粒度稀疏注意力机制,显著提升长文本处理速度与精度。

AnchorAttention: Difference-Aware Sparse Attention with Stripe Granularity

论文配图:AnchorAttention: Difference-Aware Sparse Attention with Stripe Granularity
图 1 · 摘自论文原文
  • 基于全局差异识别关键注意力区域,以条带为单位实现精细稀疏
  • 128k文本长度下提速44%,召回率更高
  • 适合需要高效长序列建模的场景,如超长文档理解

扩展上下文长度的大语言模型在预填充阶段面临严重的计算挑战,主要源于自注意力的二次复杂度。现有方法通常采用动态模式匹配和块稀疏低级实现,但依赖局部信息进行模式识别难以捕捉全局上下文,且块粒度过粗导致内部稀疏性持续存在,影响准确性和效率。为此,我们提出锚点感知稀疏注意力机制 AnchorAttention,通过更细的条带粒度动态识别关键注意力区域,并适应全局上下文,实现更快的速度与更高的精度。AnchorAttention 包含三个核心组件:(1) 基于模式的锚点计算,利用所有输入中的共性快速生成近似最大得分作为锚点;(2) 差异感知条带稀疏性识别,通过与锚点进行差异比较,快速获取具有显著意义区域的离散坐标,形成条带状稀疏模式;(3) 细粒度稀疏计算,用并行离散KV位置加载替代传统连续KV块加载,最大化稀疏率同时保留硬件计算潜力。该方法在相同召回率下实现更高稀疏率,显著降低计算时间。相比先前最优方法,在128k文本长度下,加速比达1.44×,且保持更高召回率。

原文摘要 · Abstract (English)

Large Language Models (LLMs) with extended context lengths face significant computational challenges during the pre-filling phase, primarily due to the quadratic complexity of self-attention. Existing methods typically employ dynamic pattern matching and block-sparse low-level implementations. However, their reliance on local information for pattern identification fails to capture global contexts, and the coarse granularity of blocks leads to persistent internal sparsity, resulting in suboptimal accuracy and efficiency. To address these limitations, we propose \textbf{AnchorAttention}, a difference-aware, dynamic sparse attention mechanism that efficiently identifies critical attention regions at a finer stripe granularity while adapting to global contextual information, achieving superior speed and accuracy. AnchorAttention comprises three key components: (1) \textbf{Pattern-based Anchor Computation}, leveraging the commonalities present across all inputs to rapidly compute a set of near-maximum scores as the anchor; (2) \textbf{Difference-aware Stripe Sparsity Identification}, performing difference-aware comparisons with the anchor to quickly obtain discrete coordinates of significant regions in a stripe-like sparsity pattern; (3) \textbf{Fine-grained Sparse Computation}, replacing the traditional contiguous KV block loading approach with simultaneous discrete KV position loading to maximize sparsity rates while preserving full hardware computational potential. With its finer-grained sparsity strategy, \textbf{AnchorAttention} achieves higher sparsity rates at the same recall level, significantly reducing computation time. Compared to previous state-of-the-art methods, at a text length of 128k, it achieves a speedup of 1.44$\times$ while maintaining higher recall rates.

稀疏注意力长文本处理大模型优化

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