arXiv:2410.22244cs.LGstat.ML2024-10NeurIPS被引 12

Transformer训练中突然降损现象的机制解析

Abrupt Learning in Transformers: A Case Study on Matrix Completion

  • 将矩阵补全转为掩码语言建模,用BERT求解
  • 训练初期损失平缓,后突然降至接近最优
  • 模型从抄输入变为精准预测,注意力可解释

近期对Transformer训练动态的研究揭示了一个有趣现象:训练损失在大量训练步骤中保持平稳,随后突然且急剧下降至接近最优值。为深入理解这一现象,我们将低秩矩阵补全问题形式化为掩码语言建模(MLM)任务,并证明可训练BERT模型在此任务上达到低误差。此外,损失曲线显示早期训练阶段损失平台期后突然下降,且未改变训练过程或超参数。为获得可解释性洞察,我们分析了该突变前后模型的预测、注意力头和隐藏状态。具体发现:(a) 模型从简单复制掩码输入转变为准确预测被掩码项;(b) 注意力头转向与任务相关的可解释模式;(c) 嵌入和隐藏状态编码了与问题相关的信息。我们还分析了各模型组件的训练动态,以理解损失突降的成因。

原文摘要 · Abstract (English)

Recent analysis on the training dynamics of Transformers has unveiled an interesting characteristic: the training loss plateaus for a significant number of training steps, and then suddenly (and sharply) drops to near--optimal values. To understand this phenomenon in depth, we formulate the low-rank matrix completion problem as a masked language modeling (MLM) task, and show that it is possible to train a BERT model to solve this task to low error. Furthermore, the loss curve shows a plateau early in training followed by a sudden drop to near-optimal values, despite no changes in the training procedure or hyper-parameters. To gain interpretability insights into this sudden drop, we examine the model's predictions, attention heads, and hidden states before and after this transition. Concretely, we observe that (a) the model transitions from simply copying the masked input to accurately predicting the masked entries; (b) the attention heads transition to interpretable patterns relevant to the task; and (c) the embeddings and hidden states encode information relevant to the problem. We also analyze the training dynamics of individual model components to understand the sudden drop in loss.

Transformer矩阵补全训练动态

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