Unifying ICL, SFT, KL-Regularized RL Through a Bayesian Lens
{"primary":"cs.AI","secondary":[]}local graph
Unifying ICL, SFT, KL-Regularized RL Through a Bayesian Lens
Section titled “Unifying ICL, SFT, KL-Regularized RL Through a Bayesian Lens”Authors: Junxin Fan
arxiv: 2609.05111
Converted to markdown on 2026-10-13 from the arXiv HTML (LaTeXML) rendering. This paper’s figures are not image-based or were unavailable; captions are kept.
Abstract
Section titled “Abstract”Supervised fine-tuning (SFT), few-shot in-context learning (ICL), KL-regularized RLHF/RLVR, and on-policy distillation are usually treated as distinct post-training paradigms. We develop a unified Bayesian perspective in which each is an instance of a two-step template: construct a (generalized) Bayes or Gibbs posterior from a reference model and a utility signal (log-likelihood, reward, or advantage), then approximate it by a forward-KL projection onto a parametric family, either in-weights (SFT/RL) or in-context (ICL). This yields a single chain of equivalences: few-shot ICL is an amortized projection onto the Bayes posterior predictive, and reward-weighted SFT, reward-weighted ICL, and advantage-weighted SFT are forward-KL projections of reward-induced Gibbs posteriors. The framework explains why supervised warm-up is practically unavoidable for importance-weighted projections, and interprets R1/o1-style reasoning models as combining test-time Bayesian search with training-time amortization. Matched-budget experiments on Qwen3 models corroborate the picture: operators that share their learning-signal granularity produce nearly identical updates when support is good and diverge when it degrades, and reward-weighted projection performs on par with standard baselines.
Keywords: in-context learning; supervised fine-tuning; KL-regularized reinforcement learning; Gibbs posterior; Bayesian meta-learning
Part I: Few-shot ICL SFT (Bayesian View)
Section titled “Part I: Few-shot ICL ≈\approx≈ SFT (Bayesian View)”1.1 Supervised Fine-Tuning (SFT) as Maximum Likelihood
Section titled “1.1 Supervised Fine-Tuning (SFT) as Maximum Likelihood”Given a dataset , standard supervised fine-tuning maximizes the conditional log-likelihood:
| (1) |
Equivalently, define the empirical data distribution
| (2) |
so that the SFT objective can be written as
| (3) |
Bayesian / KL interpretation.
Section titled “Bayesian / KL interpretation.”Assume the data are generated from an unknown teacher conditional distribution , and that is an empirical approximation to the joint . Then
| (4) | ||||
| --- | --- | --- | --- | --- |
| (5) |
Here we expand the inner expectation using the standard cross-entropy decomposition applied to and , where is conditional entropy. The first term is independent of , so minimizing expected negative log-likelihood is equivalent to
| (6) |
In words, SFT learns as the forward KL (maximum-likelihood) projection of the teacher onto the model family .11 1 Here “projection” refers to minimizing the forward KL , also known as MLE or the m-projection in information geometry.
1.2 Hierarchical Bayesian model for tasks and contexts
Section titled “1.2 Hierarchical Bayesian model for tasks and contexts”We now introduce a hierarchical Bayesian model for tasks, following the “ICL is Bayes” framework of Wakayama and Suzuki [25].
Task-level generative model.
Section titled “Task-level generative model.”Let be a space of functions . A random task is sampled as
| (7) |
and conditioned on , data pairs are generated i.i.d. by
| (8) |
For a given task , a few-shot context (prompt) and a query point are generated as
| (9) |
Bayes posterior over tasks and posterior predictive.
Section titled “Bayes posterior over tasks and posterior predictive.”Given context , the posterior over tasks is
| (10) |
and the corresponding Bayes posterior predictive at a new query is
| (11) |
Bayes-optimal in-context predictor.
Section titled “Bayes-optimal in-context predictor.”Consider any in-context prediction rule that maps to a predictive distribution Under log-loss, define the ICL risk
| (12) |
where the expectation is over the hierarchical model above (sampling , then and ).
Theorem 1 (Bayes-optimal in-context predictor; after Wakayama and Suzuki [25]). Define the Bayes posterior predictive
| (13) |
Then:
-
(i)
is the unique minimizer of over all measurable predictors .
-
(ii)
For any , we define its Bayes Gap as
(14) In particular, the excess risk satisfies
(15) In the squared-loss setting of Wakayama and Suzuki [25], this quantity coincides with their Bayes Gap term in the decomposition , and corresponds to their Posterior Variance component .
The full non-asymptotic bounds for the Bayes Gap and Posterior Variance are given in Wakayama and Suzuki [25]; here we only use that is the normative target of in-context prediction. This hierarchical model can be justified from a within-task exchangeability assumption via a de Finetti–type representation; see Appendix A.4.
Remark (Order of demonstrations).
Section titled “Remark (Order of demonstrations).”Real transformers process ordered sequences with positional embeddings, so the order of few-shot demonstrations in the prompt can affect predictions. Our exchangeability assumption applies at the level of the data-generating process: within a task, the examples are assumed to form an exchangeable sample from an underlying task distribution, so the Bayes posterior and posterior predictive depend only on the multiset , not on their order. Part I analyzes this ideal, order-symmetric Bayes predictor; practical in-context learners may introduce position-dependent biases, which we view as algorithmic deviations from this ideal rather than violations of the assumption.
1.3 In-context learning as amortized Bayesian inference
Section titled “1.3 In-context learning as amortized Bayesian inference”Let denote the conditional distribution implemented by a pretrained Transformer with parameters . Pretraining across many tasks and contexts can be abstracted as minimizing the expected log-loss
| (16) |
where the expectation is over the same hierarchical process as in Section 1.2.
By Theorem 1, the risk-minimizing population predictor is . Thus, in the limit of infinite model capacity and pretraining data, any minimizer of must satisfy
| (17) |
Formally, under the assumption in Sec. 1.5 that the model class is rich enough to approximate , any global minimizer (or sequence of asymptotic minimizers) of can be chosen to be arbitrarily close to in expected log-loss.
This viewpoint matches recent constructions that explicitly train Transformers as amortized Bayesian inference procedures over latent variables and datasets (e.g., [23]), where a single forward pass maps each dataset to an approximate posterior.
Interpretation.
Section titled “Interpretation.”In this Bayesian picture, few-shot ICL is best viewed as learning the mapping
| (18) |
in an amortized way. The Transformer does not explicitly perform gradient descent in parameter space at test time; instead, it approximates the Bayes posterior predictive directly in its forward pass. While our exposition centers on the Bayesian view, a complementary first-order / meta-learning interpretation (ICL one GD step) has been studied extensively in prior work [5, 3, 14], which shows that Transformers can implement gradient-based updates in their forward passes. We do not re-derive those results here, as our goal is to foreground the Bayesian formulation.
1.4 From Bayes posterior to SFT: forward-KL projection over outputs
Section titled “1.4 From Bayes posterior to SFT: forward-KL projection over outputs”We now connect the Bayes posterior predictive to supervised fine-tuning.
Fix a context and query , and write
| (19) |
for the ideal target distribution over outputs. Consider any parametric conditional model (suppressing in notation). For this fixed pair , the best approximation to within under log-loss is
| (20) |
or equivalently
| (21) |
If we had direct samples for many , then performing SFT on those samples would be exactly the forward KL projection of the Bayes posterior predictive onto the family . Aggregating over contexts and queries yields the population objective
| (22) |
and the standard SFT objective is its empirical approximation.
Bayesian reading of “ICL SFT”.
Section titled “Bayesian reading of “ICL ≈\approx≈ SFT”.”Putting Sections 1.2-1.4 together:
-
•
The ideal in-context predictor is the Bayes posterior predictive .
-
•
A sufficiently expressive Transformer minimizing ICL risk implements an amortized approximation to .
-
•
Supervised fine-tuning (SFT) learns as the forward KL projection of (or of an empirical approximation) onto the parametric family.
Thus, in the Bayesian view,
| (23) |
and ”ICL SFT” is understood as both being different approximations to the same underlying Bayesian predictor.
This distribution-level identification is the backbone for Part II, where KL-regularized RL (RLHF/RLVR) is shown to define a generalized Gibbs posterior over outputs, and reward-weighted SFT is exactly its KL projection onto .
1.5 Assumptions and scope
Section titled “1.5 Assumptions and scope”Regularity for Part I (Bayesian ICL and SFT).
Section titled “Regularity for Part I (Bayesian ICL and SFT).”We assume: (i) a well-defined hierarchical prior and data-generating mechanism as in Section 1.2 (this representation follows from a within-task exchangeability assumption; see Appendix A.4);
(ii) log-loss and finite (or densities with respect to a common base measure); (iii) integrability conditions ensuring Fubini/Tonelli can be applied when exchanging expectations and logs; (iv) a model class rich enough that some can approximate .
The non-asymptotic generalization guarantees (Bayes Gap bounds, posterior variance behavior under task mixtures, and out-of-distribution analyses) are from Wakayama and Suzuki [25].
Regularity for Part II (KL-RL).
Section titled “Regularity for Part II (KL-RL).”We assume ; rewards are bounded above so that is integrable; and shared support: whenever . Interchange of and expectation is justified by dominated convergence.
Regularity for Part IV (process-level).
Section titled “Regularity for Part IV (process-level).”We assume a stationary MDP; well-defined / functions; and advantage estimates (e.g., GAE) with bounded bias/variance. These are standard in KL-regularized policy optimization and RL-as-inference formulations.
Remark (Meta-learning view as complementary, not primary). The original meta-learning perspective that ICL behaves like a single small gradient step on a contextual loss can be rigorously justified under additional smoothness and linearization assumptions, and connects attention to accumulated gradient updates. We treat that interpretation as complementary (see the discussion and citations summarized in Appendix A.3), while the main text takes the Bayesian formulation as the primary conceptual and mathematical foundation.
Part II: KL-Regularized RL (RLHF/RLVR) Reward-weighted SFT
Section titled “Part II: KL-Regularized RL (RLHF/RLVR) ↔\leftrightarrow↔ Reward-weighted SFT”2.1 KL-regularized RL objective and closed-form optimum
Section titled “2.1 KL-regularized RL objective and closed-form optimum”Fix an input (e.g., a prompt), a reference policy , a reward function , and a temperature . The standard KL-regularized objective is
| (24) |
This form appears both in RLHF (human preference reward) and in RLVR (verifiable/correctness reward); the only difference is the source of [19, 22, 16, 26].
In practice, many RLHF-style algorithms (e.g., PPO-style KL-penalized RL, GRPO’s effective loss, and RLVR-style updates) optimize surrogate objectives that approximate (24) rather than this exact form. In what follows we work at the level of the underlying KL-regularized objective (24) and abstract away such implementation details.
For discrete , we can write the objective as
| (25) |
with the constraint . Introducing a Lagrange multiplier for this constraint, the Lagrangian is
| (26) |
Proposition 2 (KL-regularized RL Gibbs posterior). The unique maximizer of (24) is
| (27) |
Proof.
Section titled “Proof.”Take derivative of w.r.t. :
| (28) |
Setting gives
| (29) |
Exponentiating both sides,
| (30) |
The last factor does not depend on and is determined by normalization , which yields (27) with
Because the negative entropy term is strictly concave in , the objective in (24) is strictly concave with respect to , guaranteeing that the stationary point above is the unique maximizer.
Thus, KL-regularized RLHF/RLVR produces a Gibbs posterior over outputs: a generalized Bayes update with prior and pseudo-likelihood proportional to . This structure is classical in relative-entropy policy search and RL-as-inference formulations [21, 1, 13].
2.2 Reward-weighted SFT as KL projection of the Gibbs posterior
Section titled “2.2 Reward-weighted SFT as KL projection of the Gibbs posterior”We now show that reward-weighted SFT is exactly the forward-KL projection of onto a parametric family .
Fix and write
| (31) |
(This is distinct from the teacher distribution used in Section 1.1.) Consider a parametric policy and the KL projection problem
| (32) |
Throughout, when we write we mean that for a constant independent of ; i.e., we drop additive terms that do not affect the optimizer. Expanding the KL,
| (33) | ||||
| --- | --- | --- | --- | --- |
| (34) |
Therefore
| (35) |
Substituting the Gibbs form of ,
| (36) |
The normalizer does not depend on , so maximizing the above is equivalent to maximizing
| (37) |
Proposition 3 (Reward-weighted SFT = forward-KL projection). For fixed , any minimizer of (32) can be obtained by maximizing the reward-weighted SFT objective (37), and any maximizer of (37) minimizes (32). In particular, reward-weighted SFT learns as the forward KL projection of the KL-regularized RL optimum (i.e., ) onto the parametric family .
In practice, one does not enumerate all , but instead samples from a data distribution whose -marginal matches (e.g., rollouts from the reference model or logged data), and forms the empirical objective
| (38) |
which is the familiar reward-weighted SFT loss used in many recent RLHF / RLVR formulations.
Summary for Part II.
Section titled “Summary for Part II.”KL-regularized RLHF/RLVR has a closed-form optimum that is a Gibbs posterior (27). Reward-weighted SFT is exactly the KL projection of this posterior onto . Thus, at the distribution level,
| (39) |
This equivalence is meant at the level of the target Gibbs posterior and its forward-KL projection; it does not claim that all practical RLHF algorithms exactly attain the closed-form optimum in (27). This matches recent variational interpretations of RLHF that treat it as reward-weighted regression.
Part III: Reward-weighted Few-shot ICL (RW-ICL)
Section titled “Part III: Reward-weighted Few-shot ICL (RW-ICL)”We now lift the discussion from single decisions to few-shot in-context prediction with rewards.
3.1 Generalized Bayesian posterior over outputs given context
Section titled “3.1 Generalized Bayesian posterior over outputs given context”Let be a context, and a query. As in Part I, the Bayes posterior predictive under a hierarchical task model is
| (40) |
For our RLHF/RLVR setting, we augment this with a reward signal. Assume that for each potential output at we have a scalar score
| (41) |
which aggregates the relevant reward information (from human preferences, a verifier, or a reward model) given the entire context and query .
We define a generalized Bayes posterior over outputs:
| (42) |
i.e., a Gibbs posterior with prior and pseudo-likelihood proportional to . This is the natural extension of Proposition 2 to the context-dependent case.
3.2 RW-ICL objective as KL projection of the generalized posterior
Section titled “3.2 RW-ICL objective as KL projection of the generalized posterior”Let denote the in-context predictor implemented by a meta-trained Transformer. A natural population objective for reward-weighted ICL is
| (43) |
where the expectation is taken over the same hierarchical meta-distribution on tasks and contexts as in Part I, together with whatever process generates .
Expanding the KL and discarding terms independent of , (43) is equivalent to maximizing
| (44) |
Substituting the Gibbs form of from (42),
| (45) | ||||
| --- | --- | --- | --- | --- |
| (46) |
In practice, one approximates this expectation empirically by sampling contexts , queries , and candidate outputs from the reference model (or from a replay buffer), and forming the empirical objective
| (47) |
i.e., a reward-weighted in-context SFT objective.
Proposition 4 (RW-ICL = KL projection of generalized Gibbs posterior). Under mild regularity conditions, any minimizer of (43) is the forward KL projection of the generalized Gibbs posterior onto the model family . Stochastic gradient ascent on (47) implements this projection using samples from reweighted by .
Gradient-level correspondence.
Section titled “Gradient-level correspondence.”Although our exposition so far has been distributional (KL projections of Gibbs posteriors), the resulting stochastic-gradient updates have exactly the reward-weighted form emphasized in meta-learning views of ICL. For example, the empirical RW-ICL objective (47) has gradient
| (48) |
so a single SGD step is a reward-weighted in-context update. The reward-weighted SFT and AWSFT losses (37) and (59) yield the same update structure with replaced by and replaced by or . Thus, at the level of first-order optimization dynamics, RW-ICL, reward-weighted SFT, and KL-regularized RL share the same summed-score weighted by ; the meta-learning results of Dai et al. [5], Akyürek et al. [3], Li et al. [14] can be viewed as constructive realizations of such updates in a single forward pass.
Relation to Part II.
Section titled “Relation to Part II.”Comparing (42) to (27), we see that KL-regularized RLHF/RLVR defines the same Gibbs-family posterior over outputs, with playing the role of . Reward-weighted ICL meta-trains a Transformer to amortize the mapping
| (49) |
just as ordinary ICL in Part I amortizes the Bayes posterior predictive. Hence, at the distribution level,
| (50) |
up to approximation error in the KL projection.
Part IV: Process-level KL-RLVR and Advantage-weighted SFT
Section titled “Part IV: Process-level KL-RLVR and Advantage-weighted SFT”We finally consider the full RL setting with trajectories and state-dependent policies, which is the regime of KL-RLVR and related algorithms.
4.1 Statewise KL-regularized objective and Gibbs policy
Section titled “4.1 Statewise KL-regularized objective and Gibbs policy”Let be a state and a stochastic policy over actions . A typical stepwise KL-regularized objective is
| (51) |
where is an action-value function (for example, a critic or Monte Carlo return), and is a reference policy. This is the policy-improvement subproblem solved in many KL-regularized policy search methods.
By the same Lagrangian argument as in Proposition 2, the unique maximizer is
| (52) |
This is again a Gibbs posterior, now over actions conditional on state , with log-likelihood .
It is often convenient to reparameterize in terms of the advantage
| (53) |
which only shifts by a baseline independent of . Any such state-dependent baseline contributes a multiplicative factor that is absorbed into the partition function , leaving the normalized policy unchanged. Hence,
| (54) |
4.2 Advantage-weighted SFT (AWSFT) as KL projection
Section titled “4.2 Advantage-weighted SFT (AWSFT) as KL projection”Fix a state and define
| (55) |
given by (52) or (54). For a parametric policy , the KL projection problem is
| (56) |
Expanding as before, this is equivalent to
| (57) |
Substituting the Gibbs form with advantages,
| (58) |
Thus, across states , the population objective is equivalent to maximizing
| (59) |
where is some state visitation distribution (e.g., from the reference or a replay buffer).
In practice, we approximate (59) by empirical sums over state–action pairs with estimated advantages :
| (60) |
which is exactly an advantage-weighted SFT (AWSFT) loss. This matches the advantage-weighted regression family of algorithms [20, 17] and entropy-regularized methods such as SAC [8], which all rely on exponentiated / weighting.
Proposition 5 (AWSFT = KL projection of statewise KL-RLVR optimum). For each state , any minimizer of is a maximizer of the local AWSFT objective, and any maximizer of that objective minimizes the KL. Consequently, the global AWSFT objective (59) implements the forward KL projection of the stepwise KL-regularized RL optimum (52) onto the parametric policy family .
4.3 Process-level RW-ICL alignment
Section titled “4.3 Process-level RW-ICL alignment”From the in-context perspective, a trajectory (or multi-step interaction) provides a context
| (61) |
and the goal is to predict or select future actions in-context. A reward-weighted in-context learner can be meta-trained to approximate, at each state , the Gibbs posterior defined by the (advantage-based) KL-regularized RL objective:
| (62) |
The corresponding RW-ICL meta-objective is the trajectory-level analogue of (43), with per-step pseudo-likelihoods proportional to and model predictions . In particular, performing stochastic gradient ascent on this objective yields updates of exactly the same form as those obtained from the advantage-weighted SFT objective
| (63) |
up to choices of state distribution and context window.
Thus, process-level RW-ICL and stepwise KL-RLVR share the same Gibbs-posterior backbone and are both realized as advantage-weighted SFT in parameter space.
4.4 Learning signals and credit assignment in SFT, RL, and ICL
Section titled “4.4 Learning signals and credit assignment in SFT, RL, and ICL”The equivalence results in Parts II and III operate at the level of objectives and first-order updates: under a suitable Gibbs posterior, KL-regularized RL, reward-weighted SFT, and reward-weighted ICL all reduce to minimizing a forward KL , and their stochastic gradients share the familiar “weighted score” form. Writing a generic forward-KL loss as
| (64) |
its gradient takes the form
| (65) |
for appropriate choices of samples and weights . However, the source and granularity of the learning signal differ substantially across paradigms. In this section we disentangle these differences and show how they fit into our unified view.
Dense token-level supervision in SFT.
Section titled “Dense token-level supervision in SFT.”Under standard supervised fine-tuning, the model is trained with a token-level cross-entropy loss. For an autoregressive language model with inputs and target sequence , the SFT objective can be written as
| $$\mathcal{L}_{\text{SFT}}(\theta);=;-\mathbb{E}_{(x,y)}\Bigg[\sum_{i=0}^{n-1}\log p_{\theta}\big(t_{i+1},\big | ,x,t_{\leq i}\big)\Bigg].$$ |
Equivalently, SFT learns from every mapping : each prefix within a sequence contributes a term to the loss and a gradient to the update. The learning signal is thus dense at the token level, and credit assignment is implicit in the data: human- or model-generated targets already specify which next-token prediction should be encouraged at each position.
KL-regularized RL: sparse rewards + explicit credit assignment.
Section titled “KL-regularized RL: sparse rewards + explicit credit assignment.”In contrast, KL-regularized RL (including RLHF/RLVR-style objectives) typically starts from a sequence- or trajectory-level reward. In the sequence-level setting of Part II, the objective has the form
| (67) |
and the naive policy gradient estimator looks like
| (68) |
At first sight, this appears to support the claim that “RL can only learn once from the mapping ”: a single scalar reward per sampled sequence.
In practice, however, modern RL algorithms do not update the policy directly from (68). Instead, they introduce a credit assignment step, in which the scalar reward is decomposed into per-step signals. In the step-wise KL-regularized MDP setting of Part IV, this yields a Gibbs-optimal policy
and the corresponding forward-KL projection leads to the advantage-weighted SFT objective (cf. Eq. (59)–(60)):
| (69) |
The resulting policy gradient has exactly the weighted-score form (65):
| (70) |
Thus, while the raw RL signal is a single scalar reward per trajectory, RL algorithms recover the ability to “learn from each ” by explicitly estimating value functions , action-values , or advantages and using them as per-step weights. The final policy update becomes a form of advantage- or reward-weighted SFT. In our framework, this is precisely the AWSFT/RWSFT connection established in Parts II and IV: at the level of updates, KL-regularized RL is equivalent to a particular choice of weights in (65).
Few-shot ICL: dense supervision in pretraining, fast learning in activations.
Section titled “Few-shot ICL: dense supervision in pretraining, fast learning in activations.”Few-shot in-context learning sits somewhat orthogonally to this discussion. As formalized in Part I, we view a parametric ICL predictor as an amortized Bayes approximation to the posterior predictive under a task prior :
The parameters are learned using the same dense token-level supervision as in SFT: for example, the outer objective
| (71) |
is a standard log-loss aggregated over tasks and positions. In this sense, few-shot ICL does not introduce a new type of training signal: it consumes the same token-level (possibly reward-weighted) supervision as SFT/RW-ICL in the outer loop.
The key difference is where and when adaptation happens. At test time, few-shot ICL does not take further gradients on . Instead, given a context , the transformer uses attention and MLP activations to construct a task-specific internal state in its forward pass, and the effective predictor for the query can be written schematically as
for some implicit inner model class . Recent theoretical and mechanistic studies have shown that, in controlled settings, the fast state closely matches the output of explicit learning algorithms such as least squares or gradient descent on a task-specific inner objective; in this sense, ICL learning happens in activations rather than through online updates of .
Summary.
Section titled “Summary.”Putting these pieces together, our framework unifies SFT, KL-regularized RL, and few-shot ICL at the level of target posteriors and first-order updates: all three aim to approximate a Bayes or Gibbs posterior, and their gradients can be written as weighted score sums of the form (65). At the same time, the origin and granularity of the learning signal differ:
-
•
SFT observes dense token-level supervision: every prefix has an explicit label , and credit assignment is implicit in the data.
-
•
KL-regularized RL starts from sparse sequence- or trajectory-level rewards ; it must perform explicit credit assignment via estimates, but the resulting policy update is an advantage- or reward-weighted SFT step.
-
•
Few-shot ICL relies on dense supervision during pretraining to learn as a meta-learner; at test time, it performs task-specific adaptation in the forward activations without additional gradients.
In this sense, our claimed equivalences are intentionally restricted to the level of objectives (posterior distributions) and update forms. They do not erase the very real differences in how SFT, RL, and ICL acquire and use their learning signals—differences which have important implications for sample efficiency, stability, and the kinds of structure (e.g., credit assignment and reasoning) each paradigm can readily capture.
Part V: Implications for Reasoning Models and Training Recipes
Section titled “Part V: Implications for Reasoning Models and Training Recipes”5.1 Posterior design and practical RLHF/RLVR recipes
Section titled “5.1 Posterior design and practical RLHF/RLVR recipes”Parts II and IV showed that a broad class of KL-regularized RLHF/RLVR objectives admits a Gibbs-posterior optimum and that reward- or advantage-weighted SFT is exactly the forward-KL projection of this posterior onto a parametric policy family. This matches a growing line of recent work that re-formulates RLHF as reward-weighted regression or weighted SFT rather than generic policy gradient [12, 9, 6, e.g.].
From our perspective, practical RLHF/RLVR pipelines can be viewed as two-step procedures:
-
Posterior design. Choose a reference model and a reward or advantage signal , which together define a target Gibbs posterior .
-
Projection. Fit a deployable policy by minimizing the forward KL , either directly via reward-/advantage-weighted SFT, or indirectly via a PPO-style optimizer that approximates the same projection.
This view identifies three concrete design knobs:
-
•
Reward shaping as likelihood design. The reward enters only through , so shifting and scaling correspond to changing the effective likelihood ratio between high- and low-quality outputs. Overly sharp or poorly calibrated rewards lead to posteriors with very low support overlap with , which our framework predicts to cause instability and over-optimization.
-
•
Temperature as posterior concentration. Small produces a highly concentrated that strongly prefers top-reward outputs; large keeps close to . In our KL-projection picture, controls how much the optimizer is allowed to move the policy away from the reference model before running into support-mismatch issues.
-
•
Offline vs on-policy projection. When rollouts come from or an early-stage model, the reward-weighted SFT losses in Parts II and IV implement an off-policy projection to the Gibbs posterior. PPO-style RLHF instead approximates the same target distribution with on-policy samples. Our analysis suggests that both are instances of the same forward-KL projection, but they trade off exploration (on-policy) against stability and reuse of pre-generated data (offline or replay-based).
5.2 Cold start and on-policy distillation
Section titled “5.2 Cold start and on-policy distillation”Our KL-projection view also clarifies why recent pipelines based on on-policy distillation and iterative self-training almost always include a small supervised “cold start” phase before running high-variance on-policy updates.
Empirically, several lines of work report that purely on-policy optimization from a random or weakly aligned prior tends to fail: DeepSeek-R1 distinguishes a pure-RL variant (R1-Zero) that exhibits severe style and safety issues compared to the full R1 pipeline with a small SFT warm-up; on-policy distillation methods for language and vision-language models emphasize that a “cold-start alignment” of student and teacher distributions is essential for successful online training; and recent diffusion-model distillation methods similarly cast reward-guided fine-tuning as iteratively projecting onto soft-optimal policies rather than running unconstrained RL [7, 2, 4, 27, 24, e.g.].22 2 For an accessible engineering perspective on on-policy distillation for post-training, see the blog post by Lu and Lab [15].
In our framework, these observations are natural consequences of importance-weighted KL projection. Consider a target Gibbs posterior and a sampling distribution used to generate candidate outputs. The classical effective sample size of the importance weights [10], collapses when the support of has little overlap with the high-reward region under . In that regime, both off-policy reward-weighted SFT and on-policy distillation degenerate: most samples receive negligible weight, and the few high-weight samples lead to unstable gradients.
A small SFT or behavior-cloning warm-up can be understood as moving (or the student policy) into the high-reward region so that and have non-trivial overlap. On-policy distillation steps then refine the policy by repeatedly projecting the current Gibbs-approximate teacher onto the student family via forward-KL, as in Parts II and III, but now in a regime where the importance weights have reasonable variance. Our framework thus predicts a theoretical necessity of cold start for OPD-style pipelines: without sufficient support overlap, Gibbs-posterior projection is not statistically feasible, regardless of the specific optimizer used.
Recent work on reward-guided fine-tuning of diffusion models adopts an almost identical recipe: simulate soft-optimal policies under a reward, then distill them via KL minimization into the base diffusion model [24]. From our perspective, these methods are simply applying the same Gibbs-posterior projection principle to non-autoregressive generative models.
5.3 Compute allocation and reasoning models
Section titled “5.3 Compute allocation and reasoning models”Our analysis so far has been distributional and first-order: SFT, KL-regularized RL, and reward-weighted ICL all aim to approximate a (common) Bayes or Gibbs posterior, and their updates share the same weighted-score form. An orthogonal, but increasingly important, dimension in contemporary systems is how compute is allocated between training time and inference time.
Recent “reasoning models” such as DeepSeek-R1 and OpenAI’s o1 family explicitly scale inference-time compute via long chain-of-thought traces, multi-sample search, or tree-style exploration [7, 18, 11]. At a high level, these models combine two regimes:
-
•
Test-time inference (ICL / search). Given a fixed base policy, the model spends substantial compute per query to explore alternative reasoning paths and approximate a task-specific posterior over solutions.
-
•
Training-time amortization (RL / OPD / SFT). RLHF, RLVR, and on-policy distillation stages then amortize this search by projecting the high-reward posterior (often defined over multi-step chain-of-thoughts) back into the base model’s weights via KL-regularized updates.
DeepSeek-R1 and related work report a somewhat surprising empirical finding: few-shot prompting often does not improve, and can even degrade, the performance of heavily RL-tuned reasoning models [7]. In our framework, this can be understood as a mismatch between the posterior that the model has been trained to amortize and the posterior implicitly defined by few-shot prompts.
During RLHF/RLVR-style training, the model is typically optimized to approximate a Gibbs posterior under a distribution of zero-shot or lightly-structured prompts . In contrast, few-shot prompting at inference time replaces by a richer context and implicitly targets a different posterior , as in Part I. Unless the model has been meta-trained to perform reward-weighted ICL (RW-ICL) over such contexts, the learned mapping need not approximate the desired posterior, and the additional context can act as distribution shift rather than useful information.
From this perspective, few-shot prompting “fails” on some reasoning models not because ICL is inherently weaker than RL, but because the posterior level has changed (from token-level to in-context ) without a corresponding change in the training objective. Our RW-ICL formulation suggests a natural remedy: if one wants RL-tuned models to benefit from few-shot prompts, the reward signal should be defined at the contextual level and the meta-objective should directly train to approximate the corresponding Gibbs posterior .
The Bayesian/KL framework suggests that “System 2” reasoning via test-time search and ICL, and “System 1” behavior via amortized RL/SFT, are two ways of paying for the same posterior: either spend more compute per query to approximate it explicitly, or invest more training compute to bake it into the weights. Reasoning models such as DeepSeek-R1 and o1 can be viewed as deliberately combining both, using inference-time compute to explore high-reward regions of the posterior and training-time KL projection (via RLHF/RLVR/OPD) to amortize the resulting distributions into a fast at-test-time policy.
Experiments
Section titled “Experiments”Before concluding, we report a set of experiments on real models under matched budgets (every operator receives the same generation and optimization budget). The equivalences of Parts I–V are formal statements about objectives and first-order updates, but the framework also carries falsifiable empirical content, and we check two implications of it. Concretely, we ask whether (i) when the projection enjoys good support overlap, operators that the framework places on the same footing produce nearly identical updates, and the agreement collapses once support degrades; and (ii) a reward-weighted projection objective is at least competitive with its unweighted counterpart under a matched budget. The experiments span three operator families (SFT, KL-regularized RL, and reward-weighted context distillation) and student and teacher models of two sizes (Qwen3-4B and Qwen3-14B), with three seeds for the operator-agreement study.
E.1 Operator agreement under matched support
Section titled “E.1 Operator agreement under matched support”Parts II and IV predict that, when the Gibbs posterior has good support overlap with the sampling distribution, a PPO-style clipped operator and a standard group-relative policy-gradient operator (GRPO) [16] approximate the same forward-KL projection and should produce nearly identical first-order updates. Using a Qwen3-4B base/instruct model pair under a matched generation budget, we construct two regimes by varying only the sampling proposal: a stable regime where the proposal is anchored to the reference model (anchor mixing coefficient , sampling temperature ), and a stress regime without anchoring (coefficient , same temperature), which degrades the overlap between proposal and target by construction. Over three seeds (Table 1), agreement between PPO and GRPO, two operators that share the same sequence-level reward signal, is essentially perfect in the stable regime ( on all three seeds) and collapses once support degrades (–). The reward-weighted SFT direction is genuinely different even in the stable regime ( between and ) and becomes erratic under stress (including negative cosines). This mirrors the granularity distinction of Section 4.4: weighted SFT realizes a token-level amortized projection rather than a sequence-level policy-gradient step, and the framework claims equivalence of targets and update forms, not identity of update directions across signal granularities. Agreement is computed on the last two transformer layers.
Table 1: Cosine similarity between update directions under matched generation budget (Qwen3-4B; last two layers only; seeds 42–44). Stable: proposal anchored to the reference model; stress: unanchored proposal.
| Regime | Seed | ||
|---|---|---|---|
| stable | 42 | 1.000 | |
| stable | 43 | 1.000 | |
| stable | 44 | 1.000 | |
| stress | 42 | 0.107 | |
| stress | 43 | 0.219 | |
| stress | 44 | 0.358 |
E.2 Cold-start failure and rescue (controlled demonstration)
Section titled “E.2 Cold-start failure and rescue (controlled demonstration)”Section 5.2 predicts that importance-weighted KL projection is not statistically feasible without support overlap, regardless of the optimizer. We construct a controlled demonstration with a Qwen3-4B student on a slice of a public 17K-prompt verifiable math dataset (DAPO-Math-17K). Holding the warm-start initialization and training budget fixed, we change only the generation contract (Table 2). Under the original contract the rollout reward signal is effectively dead: raw reward sum , and of prompt groups have zero reward variance, so any importance-weighted update receives no signal. After fixing the contract (disabling thinking mode, generation budget raised to 2048 tokens), the raw reward sum rises to , the zero-signal fraction drops to , and parse success reaches . The failure was a property of the support/signal interface, not of the projection operator — exactly the cold-start argument of Part V.
Table 2: Same initialization and training budget; only the generation contract differs (DAPO-Math-17K slice, Qwen3-4B).
| Generation contract | raw reward sum | zero-signal group frac. | parse success |
|---|---|---|---|
| original (thinking on, 1024 tokens) | |||
| fixed (thinking off, 2048 tokens) |
E.3 Reward-weighted projection vs. standard operators (matched budget)
Section titled “E.3 Reward-weighted projection vs. standard operators (matched budget)”Finally, implication (ii): the reward-weighted projection of Parts II–III should be at least competitive with unweighted SFT and with KL-regularized RL under a matched budget. A Qwen3-4B student (teacher-bridge warm-start initialization) is trained on a DAPO-Math-17K slice (train 2000 / val 1000 / test 500) with a Qwen3-14B teacher, and all variants are evaluated under one contract (256 validation prompts, max_new_tokens ). Table 3 reports accuracy. Reward-weighted context distillation — a direct on-policy implementation of the RW-ICL objective of Part III — scores of , ahead of answer-only SFT () and GRPO (). The paired bootstrap 95% interval for the gap between the reward-weighted model and the strongest standard baseline spans accuracy points: at this evaluation scale the operators are statistically indistinguishable, and the reward-weighted objective performs on par with the standard operators it is theoretically tied to. A second probe at a larger generation budget (8192 tokens, 64 prompts) preserves the ordering (reward-weighted , SFT , warm-start and GRPO , base ), and the reward-weighted model is the only one whose extracted answers are strictly stable within 4096 tokens, while the completed baselines require 8192.
Table 3: Matched-budget comparison on the 256-prompt validation slice (Qwen3-4B student, Qwen3-14B teacher, DAPO-Math-17K).
| Model / operator | accuracy (/256) |
|---|---|
| Qwen3-4B base | () |
| warm-start (teacher bridge) | () |
| GRPO (KL-regularized RL) | () |
| SFT (answer-only) | () |
| reward-weighted context distillation | () |
Scope.
Section titled “Scope.”All experiments use the Qwen3 model family: E.1 uses three seeds and E.2–E.3 one; E.3 evaluates on 256 validation prompts, and operator agreement in E.1 is measured on the last two transformer layers. The section characterizes the mechanism-level behavior of post-training operators that the framework predicts, rather than benchmark-scale improvements.
Final Conclusions
Section titled “Final Conclusions”Combining Parts I-IV, we obtain the following Bayesian chain:
-
•
Few-shot ICL (Bayesian view). Under a hierarchical task model, the Bayes-optimal in-context predictor is the posterior predictive . A sufficiently expressive Transformer trained on many tasks approximates this predictor in an amortized way.
-
•
Generalized Bayes and KL-regularized RL. KL-regularized RLHF/RLVR defines a Gibbs posterior over outputs where is a reward or advantage signal.
-
•
Reward-weighted SFT / AWSFT. Reward-weighted SFT (for single-step problems) and advantage-weighted SFT (for RL) are exactly the forward KL projections of these Gibbs posteriors onto the parametric model family or .
-
•
Reward-weighted ICL (RW-ICL). Meta-training a Transformer with reward-weighted in-context objectives makes its predictions approximate the same Gibbs posteriors in an amortized fashion.
In summary,
| (72) | |||
| --- | --- | --- | --- |
| (73) | |||
| --- | --- | --- | --- |
| (74) |
Here, “” is intended in an idealized sense at two levels: at the distribution level, as forward-KL projections onto the same posterior (Bayes or Gibbs) under our modeling assumptions; and at the first-order optimization level, as stochastic-gradient updates of the same weighted-score form described in Section 3.2. It does not claim that the corresponding practical algorithms are identical beyond these aspects.
This equivalence is deliberately confined to objectives and update forms. The source and granularity of the learning signal remain genuinely different across paradigms. Supervised fine-tuning observes dense token-level supervision from mappings ; KL-regularized RL begins with sparse sequence- or trajectory-level rewards and must perform explicit credit assignment via value/advantage estimation before reducing to an advantage-weighted SFT update; and few-shot ICL reuses dense supervision in pretraining to learn a meta-learner , but performs task-specific adaptation at test time in the forward activations rather than via additional gradients. Our framework reconciles these methods at the level of their posterior targets and first-order dynamics, while leaving room for these process-level differences to drive distinct sample-efficiency and stability trade-offs in practice.
All of these procedures are different faces of the same underlying mechanism: a (possibly generalized) Bayesian update of a reference model that produces a target posterior (either the true Bayes posterior or a designed Gibbs posterior ), followed by a forward-KL (MLE) projection onto the parameterized policy family. Meta-learning / first-order interpretations (ICL one-step SFT / AWSFT) can then be seen as algorithmic realizations of these projection steps and are best viewed as complementary to the Bayesian backbone developed here.
From an information-design perspective, vanilla SFT passively assumes that the data source already supplies the optimal information structure (the true posterior ). RLHF/RLVR first designs a target posterior via the choice of reward and temperature , and then performs the same forward-KL/MLE projection as in SFT. In this sense, RLHF is SFT on a designed information structure: the optimization remains maximum likelihood, but the posterior being fit has been engineered to encode the desired incentives.
The experiments of the preceding section corroborate this picture at the mechanism level: operators that share their learning-signal granularity coincide almost exactly when support is good and diverge when it degrades; cold-start failure appears as a support phenomenon rather than an optimizer failure; and reward-weighted projection performs on par with its unweighted counterpart under a matched budget.
References
Section titled “References”- [1] A. Abdolmaleki, J. T. Springenberg, Y. Tassa, R. Munos, et al. (2018) Maximum a posteriori policy optimisation. arXiv preprint arXiv:1806.06920. External Links: Link Cited by: Proof..
- [2] R. Agarwal, N. Vieillard, Y. Zhou, P. Stanczyk, S. Ramos, M. Geist, and O. Bachem (2024) On-policy distillation of language models: learning from self-generated mistakes. In International Conference on Learning Representations, External Links: 2306.13649 Cited by: 5.2 Cold start and on-policy distillation.
- [3] E. Akyürek, D. Schuurmans, J. Andreas, T. Ma, and D. Zhou (2022) What learning algorithm is in-context learning? investigations with linear models. arXiv preprint arXiv:2211.15661. External Links: Link Cited by: Interpretation., Gradient-level correspondence., A.3 Relation to the main text (and to meta-learning views).
- [4] W. Bousselham, H. Kuehne, and C. Schmid (2025) VOLD: reasoning transfer from llms to vision-language models via on-policy distillation. arXiv preprint. External Links: 2510.23497 Cited by: 5.2 Cold start and on-policy distillation.
- [5] D. Dai, Y. Sun, L. Dong, Y. Hao, S. Ma, Z. Sui, and F. Wei (2022) Why can GPT learn in-context? language models implicitly perform gradient descent as meta-optimizers. arXiv preprint arXiv:2212.10559. External Links: Link Cited by: Interpretation., Gradient-level correspondence., A.3 Relation to the main text (and to meta-learning views).
- [6] Y. Du, Z. Li, P. Cheng, Z. Chen, Y. Xie, X. Wan, and A. Gao (2025) Simplify rlhf as reward-weighted sft: a variational method. arXiv preprint. External Links: 2502.11026 Cited by: 5.1 Posterior design and practical RLHF/RLVR recipes.
- [7] D. Guo et al. (2025) DeepSeek-r1: incentivizing reasoning capability in llms. arXiv preprint. External Links: 2501.12948 Cited by: 5.2 Cold start and on-policy distillation, 5.3 Compute allocation and reasoning models, 5.3 Compute allocation and reasoning models.
- [8] T. Haarnoja, A. Zhou, P. Abbeel, and S. Levine (2018) Soft actor-critic: off-policy maximum entropy deep reinforcement learning with a stochastic actor. In ICML (PMLR v80), External Links: Link Cited by: 4.2 Advantage-weighted SFT (AWSFT) as KL projection.
- [9] T. Kaufmann, P. Weng, V. Bengs, and E. Hüllermeier (2025) A survey of reinforcement learning from human feedback. Transactions on Machine Learning Research. External Links: ISSN 2835-8856, 2312.14925 Cited by: 5.1 Posterior design and practical RLHF/RLVR recipes.
- [10] L. Kish (1965) Survey sampling. Wiley. Cited by: 5.2 Cold start and on-policy distillation.
- [11] H. Lai, X. Liu, J. Gao, J. Cheng, Z. Qi, Y. Xu, S. Yao, D. Zhang, J. Du, Z. Hou, X. Lv, M. Huang, Y. Dong, and J. Tang (2025) A survey of post-training scaling in large language models. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 2771–2791. Cited by: 5.3 Compute allocation and reasoning models.
- [12] N. Lambert (2024) Reinforcement learning from human feedback. rlhfbook.com. Note: https://rlhfbook.comOnline textbook Cited by: 5.1 Posterior design and practical RLHF/RLVR recipes.
- [13] S. Levine (2018) Reinforcement learning and control as probabilistic inference: tutorial and review. arXiv preprint arXiv:1805.00909. External Links: Link Cited by: Proof..
- [14] Y. Li, M. E. Ildiz, D. Papailiopoulos, and S. Oymak (2023) Transformers as algorithms: generalization and stability in in-context learning. In ICML, External Links: Link Cited by: Interpretation., Gradient-level correspondence., A.3 Relation to the main text (and to meta-learning views).
- [15] K. Lu and T. M. Lab (2025) On-policy distillation. Thinking Machines Lab: Connectionism. Note: https://thinkingmachines.ai/blog/on-policy-distillation External Links: Document Cited by: footnote 2.
- [16] Y. Mroueh et al. (2025) GRPO’s effective loss, dynamics, and success amplification. arXiv preprint arXiv:2503.06639. External Links: Link Cited by: 2.1 KL-regularized RL objective and closed-form optimum, E.1 Operator agreement under matched support.
- [17] A. Nair, M. Dalal, A. Gupta, and S. Levine (2020) Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359. External Links: Link Cited by: 4.2 Advantage-weighted SFT (AWSFT) as KL projection.
- [18] OpenAI (2024) Learning to reason with llms. Note: https://openai.com/index/learning-to-reason-with-llms/Announces the OpenAI o1 “reasoning” model Cited by: 5.3 Compute allocation and reasoning models.
- [19] L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. Wainwright, P. Mishkin, et al. (2022) Training language models to follow instructions with human feedback. In NeurIPS, External Links: Link Cited by: 2.1 KL-regularized RL objective and closed-form optimum.
- [20] X. B. Peng, A. Kumar, G. Zhang, and S. Levine (2019) Advantage-weighted regression: simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177. External Links: Link Cited by: 4.2 Advantage-weighted SFT (AWSFT) as KL projection.
- [21] J. Peters, K. Mülling, and Y. Altun (2010) Relative entropy policy search. In AAAI, External Links: Link Cited by: Proof..
- [22] R. Rafailov, A. Sharma, E. Mitchell, S. Ermon, C. Finn, et al. (2023) Direct preference optimization: your language model is secretly a reward model. NeurIPS. External Links: 2305.18290, Link Cited by: 2.1 KL-regularized RL objective and closed-form optimum.
- [23] A. Reuter, T. G. J. Rudner, V. Fortuin, and D. Rügamer (2025) Can transformers learn full Bayesian inference in context?. arXiv preprint arXiv:2501.16825. External Links: Link Cited by: 1.3 In-context learning as amortized Bayesian inference, 2nd item, A.2 Transformers as amortized Bayesian inference (Reuter et al.), Appendix A: Bayesian ICL Results Used in the Main Text.
- [24] X. Su, X. Li, M. Uehara, S. Kim, Y. Zhao, G. Scalia, E. Hajiramezanali, T. Biancalani, D. Zhi, and S. Ji (2025) Iterative distillation for reward-guided fine-tuning of diffusion models in biomolecular design. arXiv preprint. External Links: 2507.00445 Cited by: 5.2 Cold start and on-policy distillation, 5.2 Cold start and on-policy distillation.
- [25] T. Wakayama and T. Suzuki (2025) In-context learning is provably Bayesian inference: a generalization theory for meta-learning. arXiv preprint arXiv:2510.10981. External Links: Link Cited by: item (ii), Bayes-optimal in-context predictor., Bayes-optimal in-context predictor., 1.2 Hierarchical Bayesian model for tasks and contexts, Regularity for Part I (Bayesian ICL and SFT)., 1st item, A.1 Risk decomposition and non-asymptotic bounds (Wakayama & Suzuki), A.1 Risk decomposition and non-asymptotic bounds (Wakayama & Suzuki), Appendix A: Bayesian ICL Results Used in the Main Text.
- [26] X. Wen, Z. Liu, S. Zheng, Z. Xu, S. Ye, Z. Wu, X. Liang, Y. Wang, J. Li, Z. Miao, J. Bian, and M. Yang (2025) Reinforcement learning with verifiable rewards implicitly incentivizes correct reasoning in base LLMs. arXiv preprint arXiv:2506.14245. External Links: Link Cited by: 2.1 KL-regularized RL objective and closed-form optimum.
- [27] T. Ye, L. Dong, Z. Chi, X. Wu, S. Huang, and F. Wei (2025) Black-box on-policy distillation of large language models. arXiv preprint. External Links: 2511.10643 Cited by: 5.2 Cold start and on-policy distillation.
Appendix A: Bayesian ICL Results Used in the Main Text
Section titled “Appendix A: Bayesian ICL Results Used in the Main Text”This appendix summarizes the key theoretical results from recent work on Bayesian views of in-context learning that we rely on in Part I: Wakayama and Suzuki [25] and Reuter et al. [23]. We only state what is needed for our arguments; full technical details and proofs are in the original papers.
A.1 Risk decomposition and non-asymptotic bounds (Wakayama & Suzuki)
Section titled “A.1 Risk decomposition and non-asymptotic bounds (Wakayama & Suzuki)”Wakayama and Suzuki [25] formalize a hierarchical prompt-generating process over tasks and show that the in-context learning (ICL) risk admits an exact orthogonal decomposition under squared loss. Let be any in-context predictor (not necessarily a Transformer), and let denote its expected ICL risk under their meta-distribution. Then
| (75) |
where:
-
•
is the Bayes Gap: an excess-risk term measuring how far is from the Bayes-optimal in-context predictor ;
-
•
is the Posterior Variance: an irreducible term depending only on the task distribution and context length, not on .
In particular, is the unique minimizer of , and captures the intrinsic task uncertainty. This is exactly the content we use in Theorem 1 in Part I: the Bayes posterior predictive is the normative target for in-context prediction, and any in-context learning algorithm is judged by its Bayes Gap .
For a class of uniform-attention Transformers with feature dimension , context length and number of pretraining prompts , Wakayama and Suzuki [25] further provide a non-asymptotic upper bound of the form
| (76) |
where is a Hölder exponent and is an effective dimension of the data manifold. The first term is an approximation error controlled by , and the second term is a pretraining generalization error depending jointly on and .
They also analyze mixtures of task types and input-distribution shift, showing that:
-
•
In mixed-task settings, the posterior over the task index concentrates quickly as the context grows, so the Bayes-optimal meta-algorithm rapidly specializes to the true task family.
-
•
Under input-distribution shift between pretraining and inference, only the Bayes Gap increases, with an out-of-distribution penalty proportional to a Wasserstein distance between input distributions, while the posterior variance term is intrinsic to the target domain.
We do not need these bounds explicitly, but they support our assumption in Sec. 1.3 that a sufficiently expressive Transformer, trained on many tasks, can approximate up to a small Bayes Gap in the regimes of interest.
A.2 Transformers as amortized Bayesian inference (Reuter et al.)
Section titled “A.2 Transformers as amortized Bayesian inference (Reuter et al.)”Reuter et al. [23] study whether in-context Transformers can approximate full Bayesian posterior inference over latent variables.
They construct several synthetic scenarios (generalized linear models, Gaussian mixture models, etc.) where the ground-truth posterior over latents is available via high-quality MCMC, and then:
-
•
Train an in-context learner that maps each dataset to a predictive distribution (or posterior sampler) over latent variables and responses.
-
•
Compare the distribution of samples from with those from gold-standard Bayesian methods (e.g., HMC, SGLD, variational approximations) using metrics such as C2ST, MMD, Wasserstein distance, and RMSE.
-
•
Investigate robustness under distribution shift between training and test datasets, showing that the in-context learner often remains close to the Bayesian baseline in out-of-distribution regimes.
They find that suitably trained Transformers can act as strong amortized Bayesian inference engines in context, often matching or approaching fully Bayesian baselines on both synthetic and real-world datasets, and sometimes outperforming classical approximate methods in certain distributional metrics.
This provides empirical support for the assumption used in Sec. 1.3 that a sufficiently expressive Transformer, trained on many tasks, can approximate the Bayes posterior predictive via a single forward pass .
A.3 Relation to the main text (and to meta-learning views)
Section titled “A.3 Relation to the main text (and to meta-learning views)”In the main body of this note:
-
•
Part I uses Wakayama and Suzuki [25] to justify that the Bayes posterior predictive is the canonical target for in-context prediction, and that ICL risk decomposes into a Bayes Gap plus an irreducible posterior-variance term.
-
•
The amortized-inference perspective in Sec. 1.3 and the statement that a single Transformer forward pass can approximate a dataset-level Bayesian posterior are motivated by Reuter et al. [23].
We do not reproduce the gradient-based/meta-learning derivations in this appendix. Instead, we refer to Akyürek et al. [3], Dai et al. [5], and Li et al. [14] for rigorous analyses showing that, in linear and linearized regimes, Transformers can implement one-step gradient updates in their forward passes and that attention has an algebraic dual representation as accumulated gradient corrections. In our view, those results are best interpreted as algorithmic realizations of the Bayesian predictor described in Parts I–III, rather than as the primary conceptual foundation.
A.4 Task–prior representation under within-task exchangeability
Section titled “A.4 Task–prior representation under within-task exchangeability”In Part I (Section 1.2), we adopted the hierarchical task–prior model
to formalize few-shot in-context learning as Bayes posterior prediction over tasks. In this appendix, we justify that such a hierarchical representation is a canonical consequence of a much weaker and more intuitive assumption on within-task data: exchangeability. Throughout, exchangeability is an assumption on the data-generating process within a task episode, not on any particular neural architecture used to implement in-context learning.
We first recall the notion of exchangeability and then invoke a classical representation theorem of de Finetti–Hewitt–Savage to obtain the hierarchical model used in the main text.
A.4.1 Within-task exchangeability.
Section titled “A.4.1 Within-task exchangeability.”Let be the input space and the output space (e.g., labels or next tokens). Define the sample space . We consider sequences
generated under a single “task episode”.
Definition A.4.1 (Finite and infinite exchangeability). A finite sequence is exchangeable if for every permutation of ,
i.e., its joint distribution is invariant under any reordering of the indices.
An infinite sequence is exchangeable if for every , the finite prefix is exchangeable.
Intuitively, for an exchangeable sequence, only the multiset matters, not the order. This is a standard formalization of “order-invariant” data within a task. Note that i.i.d. sequences are a special case of exchangeable sequences, but exchangeability is strictly weaker.
In our setting, we model each task episode as inducing an exchangeable sequence of sample pairs:
Assumption A.4.2 (Within-task exchangeability). For each task episode, the (conceptual) infinite sequence of observations taking values in is exchangeable.
In practice, we only ever observe a finite dataset , but we assume it arises as a finite prefix of such an exchangeable sequence. This is the usual idealization used in probability theory: we posit that, if we were to continue sampling from the same task, the joint law of the extended sequence would remain exchangeable.
A.4.2 A de Finetti–Hewitt–Savage representation.
Section titled “A.4.2 A de Finetti–Hewitt–Savage representation.”The sample space is a standard Borel space in typical supervised learning settings (e.g., finite or subsets of ), so we can invoke the general form of de Finetti’s representation theorem as extended by Hewitt and Savage.
We state an informal version sufficient for our purposes.
Theorem A.4.3 (de Finetti–Hewitt–Savage representation; informal). Let be an infinite exchangeable sequence of random variables taking values in a standard Borel space . Then there exists a random probability measure on (a random element of ) such that, conditional on , the sequence is i.i.d. with common distribution :
for some probability law on . Moreover, the mixing law is unique.
Equivalently, the joint law of can be written as a mixture of i.i.d. sequences.
The original versions of this theorem were proved by de Finetti for Bernoulli sequences and generalized by Hewitt, Savage, and many others to arbitrary standard Borel spaces; see, e.g., standard modern references in probability theory for precise statements and proofs.
Under Assumption A.4.2, the sequence generated by a given task episode satisfies the hypotheses of Theorem A.4.3, and hence admits such a mixture-of-i.i.d. representation.
A.4.3 From a random measure to a task prior.
Section titled “A.4.3 From a random measure to a task prior.”We now reinterpret the random measure from Theorem A.4.3 as a task, and its mixing distribution as a task prior .
Let denote the space of all probability measures on , equipped with the -algebra generated by the usual weak topology. For each realization , define the joint law on by
or more generally as the Radon–Nikodym density of with respect to a suitable base measure if is continuous.
We introduce the following identification:
-
•
Tasks. Each realization of is interpreted as a task , with joint law over ;
-
•
Task prior. The mixing law over is renamed as a prior over tasks.
Under this identification, Theorem A.4.3 can be restated as:
There exists a random task and a conditional distribution such that, for each task episode, the joint law of is the same as that of an i.i.d. sequence drawn from .
Formally, we obtain the hierarchical representation:
This is exactly the task–prior generative model used in Section 1.2 and the main Bayesian ICL analysis.
For supervised tasks, it is often convenient to factor as
and to interpret primarily via its conditional component . In that case, we may succinctly write , with a prior over such conditional task functions, as in the main text.
We summarize this as a proposition:
Proposition A.4.4 (Task–prior representation under exchangeability). Suppose that, for each task episode, the within-task observation sequence taking values in is infinite and exchangeable (Assumption A.4.2). Then there exists a task space and a prior over such that the joint distribution over data induced by a task episode admits the hierarchical representation
In particular, the existence of a task prior is not an additional modeling assumption beyond within-task exchangeability; it is a canonical hierarchical reparameterization of the same joint law guaranteed by the de Finetti–Hewitt–Savage theorem.
Proof sketch. Apply Theorem A.4.3 to the exchangeable sequence on to obtain a random measure on and a mixing law such that are i.i.d. with common distribution , and . Define , identify each with a task , and set . Let denote the joint law induced by on . Then
is exactly the hierarchical generative process whose marginal law over coincides with the original exchangeable sequence.
A.4.4 Remarks and scope.
Section titled “A.4.4 Remarks and scope.”(1) What is the real modeling assumption? Proposition A.4.4 shows that the only substantive structural assumption we make at the task level is within-task exchangeability (Assumption A.4.2). Given this, the existence of a hierarchical task prior is a representation theorem, not an extra ad hoc assumption.
(2) Finite sequences and approximate exchangeability. In practice, we only observe finite datasets . The infinite-sequence formulation assumes that these finite datasets can be extended to an infinite exchangeable sequence. There also exist “finite de Finetti” theorems which provide approximate mixture representations for finitely exchangeable sequences; we do not rely on their technical details here, but conceptually they support the view that approximately exchangeable finite datasets are well-approximated by such hierarchical models.
(3) Connection to Wakayama & Suzuki’s hierarchical model. Wakayama and Suzuki [14] start directly from a hierarchical task prior and derive non-asymptotic generalization bounds and a Bayes-optimal ICL risk decomposition. Our use of de Finetti–type representations clarifies that this hierarchical structure is not arbitrary: it is the canonical form of the joint distribution under within-task exchangeability. This provides a principled foundation for adopting their model in Part I.
(4) Empirical plausibility. Whether within-task exchangeability is a good approximation for real pretraining corpora is ultimately an empirical question. In the main text, we view the task–prior model as an effective theory of the latent task structure in natural data and discuss experimental designs (e.g., shuffling document structure, mixing tasks within prompts) that can probe the degree to which such a model is appropriate.
(5) Order effects in practical in-context learners. Assumption A.4.2 and Proposition A.4.4 concern the joint law of within-task data under an exchangeable data-generating process. Real transformer models process ordered prompts with positional embeddings, and the order of demonstrations can affect predictions (e.g., via position-dependent attention weights). As discussed in Section 1.2, we treat such order effects as implementation-level deviations from the exchangeable Bayes benchmark characterized here, rather than violations of the underlying exchangeability assumption.