arXiv:2507.11768stat.MLcs.LG2025-07

Transformer在上下文学习中虽不严格满足交换性,但整体仍具贝叶斯预测竞争力。

LLMs are Bayesian, In Expectation, Not in Realization

  • 从预序码长角度证明,模型平均预测误差可分解为顺序平均预测与顺序平均增益之和。
  • 在支持集256下,伯努利/四分类预测的额外码长仅0.020/0.039比特,置信度超0.999。
  • 位置编码是导致顺序敏感性的关键因素,且模型预测比最大似然基线更接近贝叶斯后验。

贝叶斯框架下的上下文学习面临直接质疑:对可交换数据,精确后验预测应与任务保持顺序无关,但Transformer在不同序列化下会改变下一个词的概率。本文指出该质疑针对的是结构不变性,而非在线预测的评分量。对于任意贝叶斯参考,超额预序码长恰好等于累积预测KL散度。对于必须序列化的无序支持集,单一合理顺序的期望遗憾可分解为顺序平均预测的遗憾加上顺序平均增益。因此,交换性违反并非二元否定,而是以对数损失定价。理论通过KT/Dirichlet有限字母表预测和粗粒化贝叶斯线性回归(BLR)分布实例化。在Qwen2.5-7B/14B上,支持集为256时,伯努利与四分类预测的一步超额码长分别为0.020/0.011比特与0.039/0.022比特,候选概率质量高于0.999;随着支持集增大,粗粒化BLR延续分布逐渐逼近后验预测数字分布。频率学派插值基线进一步表明,预测分布比最大似然插值更接近贝叶斯后验预测,优势在小支持集时最大,随参考分布收敛而消失。位置干预与从头消融实验表明,顺序敏感性源于位置编码;激活修补测试确认解码充分统计量的因果使用;排列混合量化了任意顺序带来的下游对数损失成本。Transformer无需对每种序列化都实现可交换后验预测,即可成为贝叶斯竞争的预序预测器。

原文摘要 · Abstract (English)

Bayesian accounts of in-context learning face a direct objection: exact posterior predictives for exchangeable data are invariant to task-preserving order, yet transformers change next-token probabilities when the same examples are serialized differently. We show this objection targets a structural invariant rather than the quantity scoring online prediction. For any Bayesian reference, excess prequential code length is exactly cumulative predictive KL. For unordered support sets that must be serialized, the expected regret of a single admissible ordering decomposes into that of the order-averaged predictor plus an order-averaging gain. Exchangeability violations are therefore not binary refutations; they are priced by log loss. We instantiate the theory with KT/Dirichlet finite-alphabet prediction and coarsened Bayesian linear-regression (BLR) predictive distributions. On Qwen2.5-7B/14B, floored candidate distributions at support $256$ have one-step excess code lengths of $0.020/0.011$ bits for Bernoulli and $0.039/0.022$ bits for four-way categorical prediction, with candidate mass above $0.999$; coarsened BLR continuations increasingly match the posterior-predictive digit distribution as support grows. A frequentist plug-in baseline sharpens the reading: the predictive distributions sit closer to the Bayesian posterior predictive than to the maximum-likelihood plug-in, by a margin largest at small support, where the plug-in is degenerate, and vanishing as the references converge. Position interventions and a from-scratch ablation localize order sensitivity to the positional encoding, activation patching tests causal use of decoded sufficient statistics, and permutation mixtures quantify the downstream log-loss cost of arbitrary orderings. Transformers need not realize exchangeable posterior predictives for every serialization to be Bayes-competitive prequential predictors.

贝叶斯推理大模型上下文学习预测误差

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