Transformer在上下文学习中自动选择最简解释,像奥卡姆剃刀一样偏好简单模型。
In-Context Occam's Razor: How Transformers Prefer Simpler Hypotheses on the Fly
- 通过贝叶斯框架解释模型如何在不更新参数下自动识别任务复杂度
- 在多组复杂度兼容的数据中,始终优先选择最简单的足够解释
- 适用于理解大模型泛化能力,尤其对自适应推理研究者有启发
上下文学习(ICL)使Transformer能通过示例动态适应新任务而无需参数更新。现有研究多关注固定复杂度环境,但真实语言模型需应对多样复杂度任务。本文设计基于马尔可夫链与线性回归的受控测试平台,揭示Transformer不仅能识别任务恰当的复杂度层级,还能准确推断对应参数——即使上下文示例与多个复杂度假设兼容。特别地,当数据由更简单过程生成时,模型始终倾向最简充分解释。我们通过贝叶斯框架理论解释该行为,证明Transformer在上下文中有效实现贝叶斯奥卡姆剃刀,平衡拟合优度与复杂度惩罚。进一步通过模型规模、训练分布、上下文长度和架构的消融实验验证其鲁棒性。最后以预训练GPT-4在布尔函数任务上的案例研究验证该奥卡姆剃刀式归纳偏置,表明其可能源自在多样化任务分布上训练的Transformer本质特性。
原文摘要 · Abstract (English)
In-context learning (ICL) enables transformers to adapt to new tasks through contextual examples without parameter updates. While existing research has typically studied ICL in fixed-complexity environments, practical language models encounter tasks spanning diverse complexity levels. This paper investigates how transformers navigate hierarchical task structures where higher-complexity categories can perfectly represent any pattern generated by simpler ones. We design well-controlled testbeds based on Markov chains and linear regression that reveal transformers not only identify the appropriate complexity level for each task but also accurately infer the corresponding parameters--even when the in-context examples are compatible with multiple complexity hypotheses. Notably, when presented with data generated by simpler processes, transformers consistently favor the least complex sufficient explanation. We theoretically explain this behavior through a Bayesian framework, demonstrating that transformers effectively implement an in-context Bayesian Occam's razor by balancing model fit against complexity penalties. We further ablate on the roles of model size, training mixture distribution, inference context length, and architecture. Finally, we validate this Occam's razor-like inductive bias on a pretrained GPT-4 model with Boolean-function tasks as case study, suggesting it may be inherent to transformers trained on diverse task distributions.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。