Skip to main content
QUICK REVIEW

[论文解读] Training Dynamics of Multi-Head Softmax Attention for In-Context Learning: Emergence, Convergence, and Optimality

Siyu Chen, Heejune Sheen|arXiv (Cornell University)|Feb 29, 2024
Neural Networks and ApplicationsComputer Science被引用 3
一句话总结

本文首次对多头Softmax注意力模型在多任务线性回归中上下文学习(ICL)的梯度流进行了全局收敛性分析。研究揭示了三阶段训练动态——预热、涌现与收敛——在此过程中,每个注意力头均专注于单一任务,从而实现与最优多头模型性能相当的结果,误差控制在常数因子范围内。

ABSTRACT

We study the dynamics of gradient flow for training a multi-head softmax attention model for in-context learning of multi-task linear regression. We establish the global convergence of gradient flow under suitable choices of initialization. In addition, we prove that an interesting "task allocation" phenomenon emerges during the gradient flow dynamics, where each attention head focuses on solving a single task of the multi-task model. Specifically, we prove that the gradient flow dynamics can be split into three phases -- a warm-up phase where the loss decreases rather slowly and the attention heads gradually build up their inclination towards individual tasks, an emergence phase where each head selects a single task and the loss rapidly decreases, and a convergence phase where the attention parameters converge to a limit. Furthermore, we prove the optimality of gradient flow in the sense that the limiting model learned by gradient flow is on par with the best possible multi-head softmax attention model up to a constant factor. Our analysis also delineates a strict separation in terms of the prediction accuracy of ICL between single-head and multi-head attention models. The key technique for our convergence analysis is to map the gradient flow dynamics in the parameter space to a set of ordinary differential equations in the spectral domain, where the relative magnitudes of the semi-singular values of the attention weights determines task allocation. To our best knowledge, our work provides the first convergence result for the multi-head softmax attention model.

研究动机与目标

  • 理解多头Softmax注意力在多任务线性回归中上下文学习(ICL)的训练动态。
  • 在总体损失下,通过对称初始化建立梯度流的全局收敛性。
  • 刻画任务分配的涌现过程,即训练过程中每个注意力头聚焦于单一任务。
  • 量化所学模型的泛化性能,并与最优多头注意力模型进行比较。
  • 展示单头与多头注意力在ICL中存在严格性能差距,凸显多头结构的优势。

提出的方法

  • 分析在总体多任务线性回归数据上训练的一层多头Softmax注意力模型参数空间中的梯度流动力学。
  • 利用注意力权重的半奇异值,将注意力参数动态映射到谱域中的常微分方程(ODE)。
  • 采用对称初始化方案,使键(key)和查询(query)权重相同,以确保收敛性质。
  • 应用Stein引理与旋转不变性,分析注意力得分的分布及其对任务分配的影响。
  • 将损失动态分解为三个阶段:预热阶段(损失缓慢下降,头部倾向性逐渐形成)、涌现阶段(损失快速下降,头部选择单一任务)和收敛阶段(参数稳定)。
  • 通过证明极限模型的预测误差在最优多头模型误差的常数因子范围内,建立最优性。

实验结果

研究问题

  • RQ1在适当的初始化下,多头Softmax注意力在ICL中的梯度流是否实现全局收敛?
  • RQ2注意力头在训练过程中如何演化?是否表现出任务专业化?
  • RQ3所学模型的泛化性能如何?与最优模型相比有何差异?
  • RQ4ICL中单头与多头注意力之间是否存在严格性能差距?
  • RQ5注意力权重的谱特性在任务分配与收敛动力学中起到何种作用?

主要发现

  • 在对称初始化下,梯度流全局收敛至极限点,首次建立了ICL中多头Softmax注意力的收敛结果。
  • 训练动态呈现三个明显阶段:缓慢的预热阶段、每个头选择单一任务的快速涌现阶段,以及最终的收敛阶段。
  • 在涌现阶段,每个注意力头专注于单一任务,导致损失急剧下降,从而实现有效的ICL。
  • 极限模型的预测误差随d/L比值减小而趋近于零,且其误差被限制在最优多头模型误差的常数因子范围内。
  • 单头与多头注意力模型之间存在明确的预测精度差距,多头模型在ICL中显著优于单头模型。
  • 注意力权重的谱结构——特别是半奇异值的相对大小——决定了任务分配,并驱动了专业化现象的出现。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。