arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.20969cs.LGcs.CL
收藏

理解Transformer中的上下文回忆:微调如何使模型在预训练知识上进行上下文推理

Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge

University of Southern California(南加州大学);University of British Columbia(不列颠哥伦比亚大学);Flatiron Institute(Flatiron研究所)

Bhavya Vasudeva, Puneesh Deora, Alberto Bietti, Vatsal Sharan, Christos Thrampoulidis

AI总结:

本文研究了Transformer模型在上下文学习中如何通过微调实现对预训练知识的推理,探讨了预训练和微调对上下文回忆能力的影响及机制。

摘要:

基于Transformer的语言模型在上下文学习(ICL)中表现出色,能够通过上下文示例适应新任务而无需参数更新。在一种特定的ICL形式中,即上下文回忆,预训练于开放文本的模型利用成对示例来回忆特定事实。我们研究了上下文回忆是否仅由预训练产生,微调需要什么,以及驱动必要表示的机制。为此,我们引入了一个受控的合成框架,其中预训练序列由主体-语法-属性元组组成,属性类型与语法统计相关联。我们证明,尽管这样的预训练能够产生事实性知识,但不足以支持上下文回忆:当ICL提示中移除语法统计时,模型无法隐式推断属性类型。然而,我们显示,通过在需要隐式推断的任务上微调,使用部分主体子集,可以触发所有主体上的上下文回忆的出现。这一转变伴随着共享属性类型的低维潜在编码的形成。为了获得机制性见解,我们推导出一个仅使用注意力的Transformer构造,能够复制从事实性到上下文回忆的转变,通过经验验证得到证实。

英文摘要:

Transformer-based language models excel at in-context learning (ICL), where they can adapt to new tasks based on contextual examples, without parameter updates. In a specific form of ICL, which we refer to as \textit{contextual recall}, models pretrained on open-ended text leverage pairwise examples to recall specific facts in novel prompt formats. We investigate whether contextual recall emerges from pretraining alone, what finetuning is required, and what mechanisms drive the necessary representations. For this, we introduce a controlled synthetic framework where pretraining sequences consist of subject-grammar-attribute tuples, with attribute types tied to grammar statistics. We demonstrate that while such pretraining successfully yields factual knowledge, it is insufficient for contextual recall: models fail to implicitly infer attribute types when the grammar statistics are removed in ICL prompts. However, we show that finetuning on tasks requiring implicit inference, distinct from the ICL evaluation, using a subset of subjects, triggers the emergence of contextual recall across all subjects. This transition is accompanied by the formation of low-dimensional latent encodings of the shared attribute type. For mechanistic insight, we derive a construction for an attention-only transformer that replicates the transition from factual to contextual recall, corroborated by empirical validation.

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

↑