arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.27774cs.LG
收藏

Transformer中上下文事实回忆的微调动力学

Fine-Tuning Dynamics of In-Context Factual Recall in Transformers

Duke University(杜克大学);Princeton University(普林斯顿大学);UC Berkeley(加州大学伯克利分校)

Ruomin Huang, Eshaan Nichani, Jason D. Lee, Rong Ge

AI总结:

研究Transformer在上下文学习中如何利用存储的参数化事实知识,通过引入上下文事实回忆任务并分析单层Transformer的微调动力学,证明模型收敛到特定的成对注意力模式,且所需样本量极少。

摘要:

上下文学习——基于提示中给出的示例执行任务——是大型语言模型中涌现的重要能力,在理论和实践中都受到了广泛关注。现有的理论工作通常关注学习仅使用提示中信息的场景。然而,许多上下文学习的实际实例要求模型检索存储在模型参数中的事实知识,而上下文则用于识别哪些知识是相关的。在这项工作中,我们研究了上下文学习如何利用事实知识回忆。我们通过引入\emph{上下文事实回忆(IC-recall)}任务来形式化这种行为,其中Transformer接收从隐藏关系生成的(主题,答案)对上下文以及一个查询主题,必须同时推断该隐藏关系并检索相应的答案。事实知识通过Transformer访问一个简单预构建的MLP联想记忆(存储(主题,关系,答案)三元组)来建模。我们分析了单层Transformer在IC-recall数据上的监督微调动力学,并证明模型通过收敛到特定的成对注意力模式成功执行IC-recall。这个微调阶段只需要极少的样本——仅与存储的知识三元组数量成对数关系。实验验证了我们的理论预测,并表明即使MLP层是预训练而非构建的,成对注意力模式也会出现。

英文摘要:

In-context learning \ -- performing tasks based on examples given in the prompt \ -- is an important capability that has emerged in large language models and has received significant attention in both theory and practice. Existing theoretical work often focuses on settings where the learning uses information purely from the prompt. However, many practical instances of in-context learning require the model to retrieve factual knowledge stored in the model's parameters, with the context serving to identify which knowledge is relevant. In this work, we study how in-context learning leverages factual knowledge recall. We formalize this behavior by introducing the \emph{in-context factual recall (IC-recall)} task, where a transformer is provided a context of (subject, answer) pairs generated from a hidden relation, along with a query subject, and must both infer this hidden relation and retrieve the corresponding answer. Factual knowledge is modeled by the transformer having access to a simple pre-constructed MLP associative memory storing (subject, relation, answer) triplets. We analyze the supervised fine-tuning dynamics of a one-layer transformer on IC-recall data and prove that the model successfully performs IC-recall by converging to a particular pairwise attention pattern. This fine-tuning stage requires a very small number of samples \ -- only polylogarithmic in the number of stored knowledge triplets. Experiments verify our theoretical predictions and show that the pairwise attention pattern emerges even when the MLP layer is pretrained instead of constructed.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑