arXiv:2506.17859cs.LGcs.AI2025-06NeurIPS被引 16

模型为何在上下文学习中选择不同策略?答案是:权衡效果与复杂度。

In-Context Learning Strategies Emerge Rationally

  • 用贝叶斯框架解释模型如何在训练中动态选择记忆或泛化策略
  • 预测结果与Transformer实际行为高度吻合,无需访问模型权重
  • 适合研究大模型推理机制、认知科学和机器学习理论的人阅读

近期研究揭示了上下文学习(ICL)中存在多种行为策略。本文试图统一这些发现,回答模型为何学会这些不同策略。当模型被训练以处理任务混合时,其在ICL中表现出的策略可由一类贝叶斯预测器描述:一种假设任务为离散分布的记忆型预测器,另一种则匹配真实任务分布的泛化型预测器。基于理性分析视角,我们构建了一个层次化贝叶斯框架,几乎完美预测了Transformer在训练全过程中的下一个词输出,且无需访问其参数。预训练被视为对不同策略后验概率的更新,而推理阶段则是各策略预测的加权平均。该框架结合神经网络学习动力学常见假设,明确刻画了策略在数据拟合能力与复杂度之间的权衡——模型更倾向采用复杂度更低、解释力强的策略。这不仅能解释已知的ICL现象,还提出新预测:随着任务多样性增加,从泛化到记忆的转换时间尺度呈超线性增长。整体工作为ICL提供了基于策略损失与复杂度权衡的解释与预测框架。

原文摘要 · Abstract (English)

Recent work analyzing in-context learning (ICL) has identified a broad set of strategies that describe model behavior in different experimental conditions. We aim to unify these findings by asking why a model learns these disparate strategies in the first place. Specifically, we start with the observation that when trained to learn a mixture of tasks, as is popular in the literature, the strategies learned by a model for performing ICL can be captured by a family of Bayesian predictors: a memorizing predictor, which assumes a discrete prior on the set of seen tasks, and a generalizing predictor, where the prior matches the underlying task distribution. Adopting the normative lens of rational analysis, where a learner's behavior is explained as an optimal adaptation to data given computational constraints, we develop a hierarchical Bayesian framework that almost perfectly predicts Transformer next-token predictions throughout training -- without assuming access to its weights. Under this framework, pretraining is viewed as a process of updating the posterior probability of different strategies, and inference-time behavior as a posterior-weighted average over these strategies' predictions. Our framework draws on common assumptions about neural network learning dynamics, which make explicit a tradeoff between loss and complexity among candidate strategies: beyond how well it explains the data, a model's preference towards implementing a strategy is dictated by its complexity. This helps explain well-known ICL phenomena, while offering novel predictions: e.g., we show a superlinear trend in the timescale for transitioning from generalization to memorization as task diversity increases. Overall, our work advances an explanatory and predictive account of ICL grounded in tradeoffs between strategy loss and complexity.

上下文学习贝叶斯推理模型行为分析

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