Phase Transitions in Attention: A Bayesian Theory of Copy Head Emergence
作者: Itay Lavie, Kirsten Fischer, Andrey Lekov, Frederic Van Maele, Zohar Ringel, Moritz Helias
分类: stat.ML, cond-mat.dis-nn, cs.LG
发布日期: 2026-06-10
💡 一句话要点
提出贝叶斯理论解释注意力机制中的复制子电路出现
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 注意力机制 贝叶斯理论 相变分析 特征学习 变换器模型 复制子电路 深度学习
📋 核心要点
- 现有方法未能充分解释注意力机制中复制子电路的突然出现及其与训练数据量的关系。
- 本文提出了一种贝叶斯理论,通过分析单层softmax注意力网络,揭示了复制子电路的学习过程及相变现象。
- 实验结果表明,softmax注意力在训练数据量变化时经历了一阶相变,而线性注意力则表现出不同的相变特征。
📝 摘要(中文)
注意力机制是变换器中上下文学习的关键机制,实证研究表明注意力模式在训练过程中会突然出现。本文提出了一种贝叶斯特征学习理论,重点分析了在复制任务中如何学习诱导头第一层的复制子电路。通过对单层softmax注意力网络的分析,我们推导出注意力矩阵的封闭形式后验,并将其简化为低维有序参数空间。这一简化揭示了训练数据量的相变,我们通过贝叶斯采样和标准的Adam训练验证了这一结果。与线性注意力的结果对比,softmax注意力表现出一阶相变,而线性注意力则经历了二阶相变后平滑演变至结构化注意力模式。我们的工作为复制子电路的突然出现提供了第一性原理的理论解释,类似于在大型语言模型训练中观察到的现象。
🔬 方法详解
问题定义:本文旨在解决注意力机制中复制子电路突然出现的理论解释问题,现有方法未能有效描述这一现象与训练数据量之间的关系。
核心思路:通过建立贝叶斯特征学习理论,分析单层softmax注意力网络在复制任务中的表现,推导出注意力矩阵的后验分布,揭示相变现象。
技术框架:整体架构包括单层softmax注意力网络的设计,训练过程中对注意力矩阵的后验推导,以及相变的验证实验。主要模块包括数据准备、模型训练、后验推导和相变分析。
关键创新:最重要的创新在于通过贝叶斯理论提供了对复制子电路突然出现的第一性原理解释,揭示了训练数据量对注意力机制的影响,与现有方法的定性分析形成对比。
关键设计:在模型设计中,使用softmax注意力机制,采用Adam优化器进行训练,设置了适当的超参数以确保模型的收敛性和性能。
🖼️ 关键图片
📊 实验亮点
实验结果显示,softmax注意力在训练数据量变化时经历了一阶相变,而线性注意力则经历了二阶相变后平滑演变。通过贝叶斯采样和标准训练方法验证了这一现象,提供了对比基线和相应的性能数据,进一步支持了理论的有效性。
🎯 应用场景
该研究为理解变换器模型中注意力机制的动态变化提供了理论基础,潜在应用于自然语言处理、计算机视觉等领域,尤其是在需要高效特征学习的任务中。未来可能推动更高效的模型设计和训练策略的开发。
📄 摘要(原文)
Attention is the key mechanism underlying in-context learning in transformers, and attention patterns have been observed empirically to emerge abruptly during training. We present a Bayesian theory of feature learning in attention; we then focus on how the copy subcircuit in the first layer of an induction head is learned by analyzing a single-layer softmax attention network trained on a copy task. We derive a closed-form posterior over the attention matrix and reduce it to a low-dimensional order parameter space. This reduction reveals a phase transition in the amount of training data, which we verify using both Bayesian sampling and standard training with Adam. We contrast our results with linear attention and find that softmax attention exhibits a \emph{first-order phase transition} while in linear attention an initial \emph{second-order phase transition} is followed by a smooth, continuous evolution toward the structured attention pattern (\emph{crossover}). Our work provides a first-principles theoretical account of the abrupt emergence of the copy subcircuit, reminiscent of the one observed in training large language models.