[论文解读] Birth of a Transformer: A Memory Viewpoint
论文研究变换器如何在全局知识与上下文学习之间取得平衡,使用一个合成的两层变换器与联想记忆视角,展示快速的全局双gram学习和较慢的归纳头形成用于上下文预测。
Large language models based on transformers have achieved great empirical successes. However, as they are deployed more widely, there is a growing need to better understand their internal mechanisms in order to make them more reliable. These models appear to store vast amounts of knowledge from their training data, and to adapt quickly to new information provided in their context or prompt. We study how transformers balance these two types of knowledge by considering a synthetic setup where tokens are generated from either global or context-specific bigram distributions. By a careful empirical analysis of the training process on a simplified two-layer transformer, we illustrate the fast learning of global bigrams and the slower development of an "induction head" mechanism for the in-context bigrams. We highlight the role of weight matrices as associative memories, provide theoretical insights on how gradients enable their learning during training, and study the role of data-distributional properties.
研究动机与目标
- 通过理解内部机制来提升对大型语言模型的可解释性与可靠性。
- 研究变换器如何存储全局知识与上下文特定信息。
- 引入一个合成设置以分别分析上下文学习与全局知识形成。
- 提供一个基于记忆的理论框架,将变换器的权重矩阵视为联想记忆。
提出的方法
- 引入一个带固定随机嵌入的合成两层变换器以分析学习动力学。
- 用全局双gram分布的令牌并以上下文特定触发器来建模,以区分全局学习与上下文学习。
- 将权重矩阵表示为联想记忆,并推导一个具有显式目标记忆的简化记忆为基础的模型(Eq. 3–3)。
- 在受控设置下训练,观察归纳头机制(两层注意力电路)的涌现。
- 提供基于总体梯度的理论洞见,说明顶层向下梯度步骤如何从随机初始化恢复联想记忆(引理1–2 与 定理3)。
- 在训练后的矩阵中探测记忆召回并分析数据分布对学习速度与泛化的影响。
实验结果
研究问题
- RQ1变换器在训练过程中如何在全局知识与上下文特定的上下文知识之间取得平衡?
- RQ2权重矩阵是否可以作为联想记忆来存储输入-输出关系,以解释归纳头的形成?
- RQ3在合成数据下,全局双gram与上下文归纳头的学习 dynamics 与顺序是什么?
- RQ4数据分布属性如何影响上下文学习机制的出现?
主要发现
- 全局双gram统计快速学习,而归纳头的发展较慢。
- 作为一个两层电路的归纳头机制在合成设置中涌现,使得对诸如先前的a后跟的[a, b]模式能够进行上下文预测。该机制在合成设置中得到证明。
- 权重矩阵作为联想记忆,通过外积存储输入-输出对,并可从随机初始化通过梯度步骤恢复。
- 顶层向下的梯度步骤即使在高维、嘈杂输入设置下也能恢复所需的联想记忆。
- 记忆召回探针显示特定矩阵学习了目标关联,而全局前馈层(W_F)捕捉了更广义的双gram统计。
- 数据分布(触发器,随机与固定)显著影响上下文学习出现的速度与方式。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。