并非所有维度都平等:基于分组二次核的离群点感知注意力线性化
Not All Dimensions Are Equal: Outlier-Aware Attention Linearization with Grouped Quadratic Kernels
AI总结:
该研究针对Transformer注意力线性化的离群维度误差问题,提出OAL方法,通过分组二次核实现维度感知的注意力近似,在Qwen2.5-0.5B等基准上提升了性能。
摘要:
将softmax注意力线性化为高效的Transformer推理提供了途径,但保留预训练注意力的特性仍具挑战性。我们发现标准线性化方法忽略的一个重要近似误差来源:少数离群维度对查询-键点积的贡献不成比例,且占近似误差的很大一部分。受这种异质性的启发,我们提出了离群点感知注意力线性化(Outlier-Aware Attention Linearization, OAL),这是一种用于构建二次注意力近似的维度感知方法。从二阶泰勒近似出发,我们引入了哈达玛乘积公式,该公式明确了单个查询-键的贡献。此公式放宽了全局共享系数,以支持特定维度的线性项和跨维度二次交互,同时保持可分离的评估。为了用更少的参数保留这种灵活性,OAL将贡献尺度相似的维度分组以共享系数,同时允许对少数离群点进行不同处理。所得的正二次核针对预训练注意力输出进行校准,对于固定头维度,其评估时间与序列长度呈线性关系。在Qwen2.5-0.5B上,与DiJiang相比,OAL将冻结注意力输出的相对均方误差降低了约8.9%。与学习到的全局二次核相比,替换中间层注意力模块并结合LoRA联合微调核系数,进一步将WikiText-103的困惑度从31.71降至27.50,同时提高了PIQA、HellaSwag和ARC-E的准确率。这些结果证明了离群点感知维度分组在注意力近似和预训练模型转换中的价值。代码可在该https URL获取。
英文摘要:
Linearizing softmax attention offers a route to efficient Transformer inference, but preserving pretrained attention remains challenging. We identify an important source of approximation error overlooked by standard linearization methods: a small number of outlier dimensions contribute disproportionately to query-key dot products and account for a large fraction of the approximation error. Motivated by this heterogeneity, we propose Outlier-Aware Attention Linearization (OAL), a dimension-aware method for constructing quadratic attention approximations. Starting from a second-order Taylor approximation, we introduce a Hadamard-product formulation that makes individual query-key contributions explicit. This formulation relaxes globally shared coefficients to support dimension-specific linear terms and cross-dimensional quadratic interactions while preserving separable evaluation. To retain this flexibility with fewer parameters, OAL groups dimensions with similar contribution scales to share coefficients, while allowing distinct treatment of the few outliers. The resulting positive quadratic kernel is calibrated against pretrained attention outputs and admits linear-time evaluation with respect to sequence length for fixed head dimensions. On Qwen2.5-0.5B, OAL reduces frozen-attention output relative MSE by approximately 8.9% compared with DiJiang. Replacing middle-layer attention modules and jointly fine-tuning the kernel coefficients with LoRA further lowers WikiText-103 perplexity from 31.71 to 27.50 compared with a learned global quadratic, while improving accuracy on PIQA, HellaSwag, and ARC-E. These results demonstrate the value of outlier-aware dimension grouping for both attention approximation and pretrained-model conversion. The code is available at https://github.com/wuqianyue09/OAL
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。