Source-linked AI summary
Unifying ICL, SFT, KL-Regularized RL Through a Bayesian Lens
Junxin Fan
TL;DR
The paper asks how ICL, SFT, and KL-regularized RL methods can be understood within one framework. It constructs Bayes or Gibbs posteriors from reference models and utility signals, then views learning as forward-KL projection, showing shared objectives and update forms while preserving differences in learning signals. The framework also motivates supervised cold starts and connects training-time amortization with test-time reasoning procedures.
Problem
ICL, SFT, and KL-regularized RL are often treated as fundamentally different despite needing a common account of their relationships and differing learning signals.
Source: Final Conclusions · p. 18Method
The paper builds Bayes or Gibbs posteriors from reference models and utility signals, then analyzes in-context and parameterized learning as forward-KL projections onto model families.
Source: Final Conclusions · pp. 17–18Results
KL-regularized RL, reward-weighted SFT, reward-weighted ICL, and advantage-weighted SFT share forward-KL projection objectives and corresponding first-order weighted-score updates.
Source: §4.3 · p. 12, Final Conclusions · p. 17Takeaways & Limitations
The framework treats RLHF/RLVR as posterior design followed by projection and clarifies why supervised cold starts commonly precede high-variance on-policy updates.
Source: §5.2 · p. 15, Final Conclusions · pp. 17–18The equivalences concern objectives and first-order updates, while supervision source and granularity remain different across SFT, RL, and ICL.
Source: Final Conclusions · p. 18
Abstract
from arXiv · showhide
Large language models are now trained and evaluated under a diverse set of paradigms: supervised fine-tuning (SFT), few-shot in-context learning (ICL), KL-regularized RLHF/RLVR, on-policy distillation (OPD), and test-time reasoning with search and chain-of-thought. These methods are often discussed as fundamentally different, and recent empirical results--such as the mixed impact of few-shot prompting on RL-tuned reasoning models--can appear puzzling. This note develops a Bayesian perspective that puts these procedures on the same footing. At the core is a two-step template: (i) construct a (generalized) Bayes or Gibbs posterior q* over outputs or actions given a context, using a prior/reference model and a utility signal (log-likelihood, reward, or advantage); and (ii) approximate q* by a forward-KL projection onto a parametric family, either in-weights (SFT/RL) or in-context (ICL). Part I formalizes few-shot ICL and SFT as amortized and-weights projections onto the Bayes posterior predictive. Parts II-IV show that KL-regularized RLHF/RLVR, reward-weighted SFT, reward-weighted ICL (RW-ICL), and advantage-weighted SFT (AWSFT) are all instances of forward-KL projection onto posteriors induced by rewards or advantages. We disentangle where these equivalences hold (objectives and first-order updates) and where they do not (source and granularity of the learning signal). Part V sketches implications for modern reasoning pipelines: RLHF/RLVR recipes as "posterior design + projection", why cold-start or supervised warm-up is practically unavoidable for importance-weighted KL projections, and DeepSeek-R1 and o1-style reasoning models as combining test-time Bayesian search with training-time KL amortization.
Part I: Few-shot ICL ≈SFT (Bayesian View)
The paper frames few-shot ICL and SFT as different approximations to the same Bayesian target: the Bayes posterior predictive. ICL amortizes this prediction in a forward pass, while SFT performs a forward-KL projection onto a parametric model; analogous projections extend to reward-based RL objectives.
SFT projection
- SFT learns the teacher or Bayes predictive distribution as its forward-KL projection onto the parametric model family.The projection is equivalent to maximum-likelihood training and can use direct samples from the target predictive distribution or an empirical approximation.Source: §1.1 · p. 2, §1.4 · p. 5
Bayesian target
- The Bayes posterior predictive is the normative target for few-shot in-context prediction.Source: §1.2 · p. 3, §1.4 · p. 5
Amortized ICL
- A sufficiently expressive pretrained Transformer can amortize this target, approximating it directly from the context during its forward pass.This formulation does not require test-time gradient descent, although prior work also interprets ICL through first-order or meta-learning updates.Source: §1.3 · p. 4, §1.4 · p. 5
ICL–SFT connection
- Thus, ICL and SFT are different approximations to the same underlying Bayesian predictor rather than identical procedures.Source: §1.4 · p. 5
Reward-based extension
- KL-regularized RL produces a Gibbs posterior from a reference policy and reward, while reward-weighted SFT is its forward-KL projection onto the policy family.The paper states this equivalence at the target-posterior and projection level, not as a claim that every practical RLHF implementation reaches the closed-form optimum.Source: §2.1 · pp. 6–7, §2.2 · p. 8
Part III: Reward-weighted Few-shot ICL (RW-ICL)
Reward-weighted ICL constructs a context-dependent Gibbs posterior from a reference model and reward, then trains an in-context predictor as its forward-KL projection. This matches KL-regularized RLHF/RLVR at the distribution level, up to projection error.
- RW-ICL defines a Gibbs posterior using the reference model as prior and exp(R/β) as a reward-based pseudo-likelihood.The reward aggregates information from human preferences, verifiers, or reward models conditioned on the context and query.Source: §3.1 · p. 9
- The RW-ICL population objective trains a meta-predictor Mθ to approximate this generalized posterior across tasks and contexts.The expectation follows the same hierarchical meta-distribution used for ordinary ICL, together with the process generating rewards.Source: §3.2 · p. 9
- RW-ICL is a forward-KL projection of the generalized Gibbs posterior onto the in-context model family.Stochastic gradient ascent implements the projection using reference-model samples reweighted by exp(R/β).Source: §3.2 · p. 9
- At the first-order update level, RW-ICL, reward-weighted SFT, and KL-regularized RL share reward-weighted score-gradient structure.The correspondence concerns update forms, with the model and signal changing across ICL, SFT, and RL.Source: §3.2 · p. 10
- At the distribution level, reward-weighted ICL approximately matches the KL-regularized RLHF/RLVR optimum, up to approximation error in the KL projection.Source: §3.2 · p. 10
Part IV: Process-level KL-RLVR and Advantage-weighted SFT
Process-level KL-regularized RL produces statewise Gibbs policies over actions, and advantage-weighted SFT projects those policies onto a parametric family. The same weighted-update structure extends to trajectory-level RW-ICL, while the paradigms retain different learning-signal granularities.
Process-level KL-RLVR
- The KL-regularized policy-improvement optimum is a Gibbs posterior over actions, with Q(s, a)/β determining action preference relative to a reference policy.Source: §4.1 · pp. 10–11
- Advantage baselines shift Q by state-dependent constants that are absorbed into normalization, leaving the normalized policy unchanged.Source: §4.1 · p. 11
Advantage-weighted SFT
- AWSFT is the forward-KL projection of the statewise KL-RLVR Gibbs optimum onto the parametric policy family.The empirical objective uses estimated advantages as exponentiated weights over state-action pairs.Source: §4.2 · p. 11
Trajectory-level RW-ICL
- Trajectory-level RW-ICL uses per-step advantage weights and produces updates matching AWSFT, subject to state-distribution and context-window choices.Source: §4.3 · p. 12
Learning signals and credit assignment
- Across SFT, RL, and ICL, the equivalence concerns posterior objectives and first-order updates, not the source or granularity of supervision.SFT has dense token-level labels, RL begins with sparse trajectory rewards and explicit credit assignment, and ICL adapts in activations after dense pretraining supervision.Source: §4.4 · p. 14
Part V: Implications for Reasoning Models and Training Recipes
The framework interprets RLHF/RLVR pipelines as Gibbs-posterior design followed by forward-KL projection, clarifying why cold starts support stable importance weighting. It also explains reasoning models as combining test-time posterior search with training-time amortization, while few-shot prompting can shift the targeted posterior.
Posterior design and projection
- RLHF/RLVR can be viewed as designing a Gibbs posterior from a reference model and reward, then projecting it into a deployable policy.Projection may use reward- or advantage-weighted SFT or an optimizer such as PPO.Source: §5.1 · p. 15
Design knobs
- Reward shaping, temperature β, and sampling regime control posterior concentration, reference-policy movement, and the stability–exploration trade-off.Small β concentrates the posterior, while offline and on-policy methods trade data reuse and stability against exploration.Source: §5.1 · p. 15
Cold start and on-policy distillation
- When the sampling distribution has little overlap with the high-reward Gibbs region, importance weights collapse and gradients become unstable.Source: §5.2 · p. 16
- A small supervised or behavior-cloning warm-up moves the policy toward the high-reward region, making Gibbs-posterior projection statistically feasible.Source: §5.2 · p. 16
Compute allocation and reasoning models
- Reasoning models combine test-time search over solution paths with training-time RL, OPD, or SFT that amortizes high-reward behavior into model weights.DeepSeek-R1 and o1-style systems are described as combining these inference-time and training-time regimes.Source: §5.3 · pp. 16–17
Few-shot prompting and posterior mismatch
- Few-shot prompting can degrade RL-tuned reasoning models when its richer contextual posterior differs from the posterior trained under zero-shot or lightly structured prompts.RW-ICL suggests defining rewards at the contextual level and training the model directly on that Gibbs posterior.Source: §5.3 · p. 17
Final Conclusions
The paper unifies ICL, SFT, and KL-regularized RL as posterior construction followed by forward-KL projection, while restricting the equivalence to distributional objectives and first-order updates. It distinguishes these shared forms from differences in learning-signal source and granularity.
- Few-shot ICL approximates the Bayes posterior predictive through an amortized forward-KL/MLE projection.Source: Final Conclusions · pp. 17–18
- KL-regularized RL defines a Gibbs posterior, while reward-weighted SFT, AWSFT, and RW-ICL project onto corresponding reward- or advantage-induced posteriors.Source: Final Conclusions · pp. 17–18
- The equivalence holds at posterior-target and first-order-update levels, not as an identity between practical algorithms.Source: Final Conclusions · p. 18
- Learning processes remain different: SFT uses dense token supervision, RL uses sparse rewards with credit assignment, and ICL adapts through forward activations without test-time gradients.Source: Final Conclusions · p. 18
- The common mechanism is a Bayesian or generalized Bayesian update followed by forward-KL projection onto a parameterized policy family.Source: Final Conclusions · p. 18
Appendix A: Bayesian ICL Results Used in the Main Text
The appendix summarizes prior theoretical and empirical work supporting the paper’s Bayesian account of in-context learning. It uses these results as foundations rather than reproducing their full technical development.
- The appendix reviews Wakayama and Suzuki and Reuter et al. as the main prior foundations for the paper’s Bayesian ICL arguments.Source: Appendix A · p. 20
- Full technical details and proofs are deferred to the original papers.Source: Appendix A · p. 21
A.1 Risk decomposition and non-asymptotic bounds (Wakayama & Suzuki)
Wakayama and Suzuki decompose ICL risk into a model-dependent Bayes Gap and irreducible Posterior Variance, establishing the Bayes predictor as the normative target. Their bounds characterize approximation and pretraining-generalization effects, while task mixtures and distribution shift alter the Bayes Gap.
- The ICL risk decomposition separates Bayes Gap, measuring distance from the Bayes predictor, from Posterior Variance, determined by task uncertainty and context length.Source: §A.1 · p. 21
- The Bayes-optimal predictor uniquely minimizes risk, making its posterior predictive the normative target for in-context prediction.Source: §A.1 · p. 21
- The non-asymptotic bound contains approximation error controlled by feature dimension and pretraining generalization error depending jointly on context length and prompt count.Source: §A.1 · p. 21
- In mixed-task settings, posterior task identification concentrates quickly as context grows, enabling rapid specialization to the true task family.Source: §A.1 · p. 21
- Under input-distribution shift, the out-of-distribution penalty increases the Bayes Gap, while Posterior Variance remains intrinsic to the target domain.Source: §A.1 · p. 21
- The paper uses these results to assume that sufficiently expressive, many-task-trained Transformers can approximate the Bayes predictor with a small Bayes Gap.Source: §A.1 · p. 21
A.2 Transformers as amortized Bayesian inference (Reuter et al.)
Reuter et al. test whether in-context Transformers can approximate Bayesian posterior inference over latent variables and responses. Across synthetic and real-world settings, suitably trained Transformers often approach Bayesian baselines, supporting the paper’s amortized-inference assumption.
- Reuter et al. study whether in-context Transformers can approximate full Bayesian posterior inference over latent variables.Source: §A.2 · p. 22
- They train learners that map datasets to predictive distributions or posterior samples over latent variables and responses.Source: §A.2 · p. 22
- They compare Transformer samples with HMC, SGLD, and variational approximations using C2ST, MMD, Wasserstein distance, and RMSE.Source: §A.2 · p. 22
- The experiments investigate robustness under training–test distribution shift and report that the in-context learner often remains close to Bayesian baselines.Source: §A.2 · p. 22
- Suitably trained Transformers often match or approach fully Bayesian baselines and sometimes outperform classical approximations on distributional metrics.Source: §A.2 · p. 22
- These findings support approximating the Bayes posterior predictive through a single forward pass.Source: §A.2 · p. 22
A.3 Relation to the main text (and to meta-learning views)
This appendix situates the Bayesian ICL and SFT framework within prior work on Bayes-optimal prediction, amortized inference, and meta-learning interpretations of Transformer computation.
- Part I treats the Bayes posterior predictive as the canonical target for in-context prediction and decomposes ICL risk into Bayes Gap and posterior variance.Source: §A.3 · p. 22
- The amortized-inference view holds that a Transformer can approximate a dataset-level Bayesian posterior in a single forward pass.Source: §A.3 · p. 22
- Prior analyses show that, in linear and linearized regimes, Transformers can implement one-step gradient updates and attention can represent accumulated gradient corrections.Source: §A.3 · p. 22
- The appendix interprets these gradient-based results as algorithmic realizations of the Bayesian predictor rather than reproducing their derivations.Source: §A.3 · p. 22
A.4 Task–prior representation under within-task exchangeability
The task–prior model underlying the Bayesian ICL analysis is justified by within-task exchangeability, rather than introduced as an independent neural-architecture assumption.
- Within-task exchangeability is an assumption about the data-generating process, not about the neural architecture implementing in-context learning.Source: §A.4 · p. 23
- The appendix uses de Finetti–Hewitt–Savage representation to derive the hierarchical task–prior model from exchangeability.Source: §A.4 · p. 23
- The observations are modeled as sample pairs in X × Y generated within a single task episode.Source: §A.4.1 · p. 23
A.4.1 Within-task exchangeability.
Within each task episode, the appendix assumes an exchangeable observation sequence: reordering examples leaves their joint distribution unchanged, while i.i.d. sampling is only a special case.
- A finite sequence is exchangeable when its joint distribution is invariant under every permutation of its indices.Source: §A.4.1 · p. 23
- An infinite sequence is exchangeable when every finite prefix is exchangeable.Source: §A.4.1 · p. 23
- Exchangeability means that only the multiset of observations matters, and it is strictly weaker than the i.i.d. assumption.Source: §A.4.1 · p. 23
- Within-task exchangeability assumes that the conceptual infinite sequence of observation pairs (X_i, Y_i) is exchangeable.Source: §A.4.1 · p. 23
- The framework treats the observed dataset D_k as a finite prefix of an exchangeable sequence, with the infinite extension serving as a probability-theoretic idealization.Source: §A.4.1 · p. 23
- The standard Borel structure of typical supervised-learning spaces permits application of the general de Finetti–Hewitt–Savage theorem.Source: §A.4.1 · p. 23
A.4.2 A de Finetti–Hewitt–Savage representation.
Under within-task exchangeability, de Finetti–Hewitt–Savage represents each task episode as a mixture of i.i.d. sequences, yielding the hierarchical task–prior model used for Bayesian ICL.
A de Finetti–Hewitt–Savage representation
- The representation theorem states that an infinite exchangeable sequence is conditionally i.i.d. given a random probability measure, whose mixing law is unique.Source: §A.4.2 · p. 24
- Under the exchangeability assumption, each episode therefore admits a mixture-of-i.i.d. representation.Source: §A.4.2 · p. 24
From a random measure to a task prior
- The random measure is identified with a task f, and its mixing distribution Π is renamed the task prior P(f).Source: §A.4.3 · p. 24
- This task–prior representation is a canonical reparameterization of the exchangeable joint law, not an additional ad hoc modeling assumption.Source: §A.4.3 · p. 25, §A.4.4 · p. 25
- The construction identifies each task with a probability measure on X × Y and permits the conditional task-function view f: X → Δ(Y).Source: §A.4.3 · p. 25
Remarks and scope
- For finite datasets, the infinite-sequence formulation requires an exchangeable extension, while finite de Finetti results provide a conceptual approximate alternative.Source: §A.4.4 · p. 25
- The task–prior model is presented as an effective theory whose empirical plausibility for real pretraining corpora remains an open question, and practical transformers may exhibit order effects.Source: §A.4.4 · pp. 25–26