arXiv:2507.03340cs.LGstat.ML2025-07NeurIPS被引 2

自动调整线性注意力特征维度,提升长序列模型效率与精度。

Degrees of Freedom for Linear Attention: Distilling Softmax Attention with Optimal Feature Efficiency

  • 基于统计自由度理论,动态确定每层注意力的最优特征维数。
  • 在相同计算开销下,错误率更低,优于固定维数的基线方法。
  • 适合追求高效长序列建模的NLP研究者和部署工程师。

线性注意力因其计算高效性,成为长序列场景下软最大注意力的近似替代。现有方法将特征维度统一设置于所有注意力层,忽视了各层角色与复杂性的差异。本文提出一种基于统计自由度的原理性方法,自动选择线性注意力中的特征维度,该维度反映输入的有效维度。我们给出了近似误差的理论界,并证明所选维度在固定计算预算下可实现更小的误差。此外,我们设计了一种高效的逐层训练策略,以学习适配各层的非线性特征。在多个预训练Transformer模型上的实验表明,本方法在不增加推理成本的前提下,显著提升了蒸馏模型性能。研究结果还揭示了注意力机制在不同网络层间复杂度的演化规律。

原文摘要 · Abstract (English)

Linear attention has attracted interest as a computationally efficient approximation to softmax attention, especially for long sequences. Recent studies have explored distilling softmax attention in pre-trained Transformers into linear attention. However, a critical challenge remains: how to choose the feature dimension that governs the approximation quality. Existing methods fix this dimension uniformly across all attention layers, overlooking the diverse roles and complexities of them. In this paper, we propose a principled method to automatically determine the feature dimension in linear attention using the concept of statistical degrees of freedom, which represent the effective dimensionality of the inputs. We provide a theoretical bound on the approximation error and show that the dimension chosen by our method achieves smaller error under a fixed computational budget. Furthermore, we introduce an efficient layerwise training strategy to learn nonlinear features tailored to each layer. Experiments on multiple pre-trained transformers demonstrate that our method improves the performance of distilled models compared to baselines without increasing the inference cost. Our findings also provide insight into how the complexity of the attention mechanism evolves across layers.

注意力机制线性注意力模型压缩自适应结构

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