arXiv:2410.23819cs.LG2024-10NeurIPS被引 39

权重衰减让注意力层矩阵变低秩,解释了为何它在训练初期就起效。

Weight decay induces low-rank attention layers

  • 用理论证明权重衰减等价于对矩阵乘积的核范数正则化。
  • 实验证明注意力矩阵乘积在训练中显著降秩,即使在线更新也成立。
  • 建议将注意力层的权重衰减与其他参数解耦以避免性能下降。

深度神经网络中正则化(如权重衰减)的影响尚不明确。本文研究权重衰减与$L2$-正则化在参数矩阵以乘法方式交互的模型中的作用,这类结构常见于注意力层(如Transformer)。关键查询、值投影矩阵直接相乘:$W_K^TW_Q$ 和 $PW_V$。我们扩展已有结果,证明在形式为 $L(AB^ op) + λ("A"^2 + "B"^2)$ 的 $L2$-正则化损失下,任意局部最小值等同于核范数正则化损失 $L(AB^ op) + λ\|AB^ op\|_*$ 的最小值,且二者在训练中快速趋同。因此,我们补充了 $L2$-正则化与低秩正则化的联系,并解释其为何影响训练早期。基于此,我们实证发现,在视觉与语言建模任务中使用权重衰减优化时,注意力矩阵乘积 $W_K^TW_Q$ 与 $PW_V$ 显著降秩,即便在完全在线训练下亦然。结果表明,过度降低注意力矩阵秩会损害语言模型性能,而将注意力层的权重衰减与其他参数解耦可获益。

原文摘要 · Abstract (English)

The effect of regularizers such as weight decay when training deep neural networks is not well understood. We study the influence of weight decay as well as $L2$-regularization when training neural network models in which parameter matrices interact multiplicatively. This combination is of particular interest as this parametrization is common in attention layers, the workhorse of transformers. Here, key-query, as well as value-projection parameter matrices, are multiplied directly with each other: $W_K^TW_Q$ and $PW_V$. We extend previous results and show on one hand that any local minimum of a $L2$-regularized loss of the form $L(AB^\top) + λ(\|A\|^2 + \|B\|^2)$ coincides with a minimum of the nuclear norm-regularized loss $L(AB^\top) + λ\|AB^\top\|_*$, and on the other hand that the 2 losses become identical exponentially quickly during training. We thus complement existing works linking $L2$-regularization with low-rank regularization, and in particular, explain why such regularization on the matrix product affects early stages of training. Based on these theoretical insights, we verify empirically that the key-query and value-projection matrix products $W_K^TW_Q, PW_V$ within attention layers, when optimized with weight decay, as usually done in vision tasks and language modelling, indeed induce a significant reduction in the rank of $W_K^TW_Q$ and $PW_V$, even in fully online training. We find that, in accordance with existing work, inducing low rank in attention matrix products can damage language model performance, and observe advantages when decoupling weight decay in attention layers from the rest of the parameters.

注意力机制权重衰减低秩正则Transformer

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