Diffusion Transformers are Provably Optimal In-context Generators
Organizations: National University of Singapore · RIKEN AIP · The University of Tokyo · A*STAR CFAR Nanyang Technological University
Abstract
Generative foundation models are attracting interest for their ability to produce desired outputs from demonstrations given at inference time, without updating parameters. However, since a few demonstrations cannot uniquely identify the intended task, the challenge is how to learn and sample from an output distribution that reflects this task uncertainty. In this work, we theoretically analyze how a Diffusion Transformer (DiT), pretrained across diverse tasks, learns and generates predictive distributions for a new query from demonstrations. We first show that the natural target to generate from finite demonstrations is not an output derived from estimating a single task, but rather a predictive distribution that captures the task uncertainty remaining after observing the demonstrations. We then prove that a DiT can learn this predictive distribution through score estimation, using attention to aggregate information from demonstrations and diffusion to generate samples. Owing to this property, with sufficient pretraining resources and diffusion sampling steps, the resulting DiT achieves the minimax optimal rate over a Hölder class of test-time tasks. These results imply that DiT acts as a statistically grounded in-context generator capable of generating distributions adapted to new tasks while retaining the uncertainty inherent in finite demonstrations.
Figures & tables
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Active query rows and keys | Constructed attention logits | Value and residual destination | State after fixed update | |
|---|---|---|---|---|
| 1 | Summary row; keys | All zero, hence weights | to | Summary pool is |
| 2 | Every latent row; singleton key | Singleton, hence weight | to the latent pool block | Every latent row contains the same pooled vector |
| 3 | Every latent row; singleton key | Singleton, hence weight | to the latent query block | Identifier selects , and becomes |
| 4 | Output row; keys | for latent key | to | Output block is the posterior-weighted pair in 69 |
| Observed pattern | Possible bottleneck | Suggested intervention |
|---|---|---|
| The task posterior remains spread over tasks with different output laws. | Finite-prompt task uncertainty | Request additional demonstrations that distinguish the plausible task-specific output laws. |
| The oracle is concentrated, but the model remains diffuse after checking sampler convergence. | Amortization or learning error | Increase independent pretraining episodes; improve model capacity, optimization, or use of context. |
| Error relative to the oracle varies substantially with sampler steps or schedule. | Sampling error or score–sampler interaction | Refine the sampler steps and schedule; check convergence with the learned score held fixed. |
| Individual samples are plausible, but their mode frequencies disagree with the oracle. | Probability calibration error | Evaluate mode probabilities, improve episodic distributional training, and check sensitivity to the sampler. |
| Learning and sampling errors are small relative to finite-prompt task uncertainty. | Prompt information | Prioritize more informative demonstrations over further reductions in learning or sampling error. |
| A large token budget contains few independent episodes. | Limited independent training data | Track and increase independent episode count; account for within-episode dependence when allocating pretraining data. |