微调让大模型在新格式中准确回忆事实,关键在构建共享属性编码。
Understanding Contextual Recall in Transformers: How Finetuning Enables In-Context Reasoning over Pretraining Knowledge
- 用合成数据控制预训练,分离知识与推理机制。
- 仅预训练无法实现上下文回忆,需特定微调触发能力。
- 发现低维隐空间编码共享属性,解释推理机制。
基于Transformer的语言模型在上下文学习(ICL)中表现出色,能根据上下文示例适应新任务而无需参数更新。本文关注一种特定形式的ICL——上下文回忆,即模型通过成对示例从开放文本预训练中回忆具体事实,并在新颖提示格式下生效。我们设计了一个受控的合成框架,其中预训练序列由主语-语法-属性三元组构成,属性类型与语法统计相关联。实验表明,尽管预训练能有效获取事实知识,但若在ICL提示中移除语法统计,模型无法隐式推断属性类型。然而,当在需要隐式推理的任务上,使用部分主语进行微调后,模型在所有主语上均实现了上下文回忆。该转变伴随共享属性类型的低维潜在编码形成。进一步地,我们提出一个仅依赖注意力的Transformer构造,可复现从事实记忆到上下文回忆的跃迁,经实证验证其有效性。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。