arXiv:2605.27774cs.LG2026-05被引 1

揭示大模型如何通过少量示例快速调用内部知识

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

论文配图:Fine-Tuning Dynamics of In-Context Factual Recall in Transformers
图 1 · 摘自论文原文
  • 用配对注意力模式实现上下文知识检索
  • 仅需对数级样本即可完成知识调用
  • 适用于研究模型内知识存储与调用机制

在上下文学习中,模型需基于提示中的示例完成任务。本文聚焦于模型从自身参数中检索事实知识的机制,提出‘上下文事实召回’(IC-recall)任务:给定一组(主体,答案)对及查询主体,模型需推断隐藏关系并返回对应答案。通过引入预构建的MLP关联记忆存储(主体,关系,答案)三元组,研究发现一阶变压器在监督微调下会收敛至特定的成对注意力模式,从而实现知识召回。理论证明该过程仅需多对数级样本(polylogarithmic in number of triplets),实验验证了该模式的存在性,即使使用预训练的MLP层也可见类似现象。

原文摘要 · Abstract (English)

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.

上下文学习知识召回注意力机制

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