Transformers Can Learn Posterior Predictive Distributions In-Context

Gyeonghun Kang, Changwoo J. Lee, Xiang Cheng
5/26/2026
stat.MLcs.LG

No confident code implementation found for this paper. 3 possible matches can be shown below.

Abstract

Prior-data fitted networks (PFNs) have recently emerged as a powerful approach for Bayesian prediction tasks, approximating the posterior predictive distribution (PPD) through in-context learning. Despite their strong empirical performance and ability to go beyond point predictions, theoretical understandings of the algorithmic capability of transformers to learn distributions in context are still lacking. Focusing on Gaussian process regression problems, we show by construction that transformers can implement a gradient descent algorithm targeting the posterior predictive mean and variance, followed by nonlinear mappings that yield binned probabilities of PPD. We study the error bounds of the approximated PPD in terms of attention depth and bin resolution. Based on these results, we further demonstrate the key role of normalization and the choice of attention depth in enabling the extrapolation abilities of transformers beyond the pretraining sample size range. We conduct simulations that corroborate our findings, providing insight into the expressivity of PFNs targeting PPDs and how architectural choices may influence generalization capabilities.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 3 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{kang2026transformers,
  title  = {Transformers Can Learn Posterior Predictive Distributions In-Context},
  author = {Gyeonghun Kang and Changwoo J. Lee and Xiang Cheng},
  year   = {2026},
  eprint = {2605.26713},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.26713v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.26713.svg)](https://codeofpaper.com/paper/2605.26713)

Discussion