Transformer作为上下文采样器研究
Transformers as In-Context Samplers: From Closed-Form Diffusion to Estimation-Free Sampling
这篇论文揭示了Transformer在数据生成方面的能力,展示了如何通过上下文学习实现无参数估计的采样过程。
该论文证明冻结的Transformer模型能够通过上下文样本模拟迭代生成采样器。研究显示Transformer可实现闭式扩散采样器和平滑闭式扩散采样器,其中softmax注意力计算责任权重和加权经验平均值。研究团队在语义主题采样任务中发现,Transformer隐藏状态呈现两阶段几何结构:中间层向均匀球形参考移动,输出层返回结构化主题相关表示。
Transformers as In-Context Samplers: From Closed-Form Diffusion to Estimation-Free Sampling
A growing body of work establishes that large language models are not mere statistical memorizers, but are capable of in-context learning: performing inference at test time using only examples provided in the prompt, without any parameter updates. Prior theoretical work has shown that this capability extends to supervised learning tasks such as linear regression. We prove that in-context learning extends further to \emph{data generation}: frozen transformers can simulate iterative generative samplers from in-context samples. We first show that transformers can realize closed-form and smoothed closed-form diffusion samplers. The construction identifies a concrete generative role for softmax attention: it computes responsibility weights and weighted empirical averages, while feedforward layers implement Euler updates. To empirically relate these constructions to pretrained language models, we study \emph{semantic-topic sampling}: prompts consisting of words drawn from a common semantic category, such as animals, foods, or cities. Across transformer layers, the normalized hidden states exhibit a two-stage geometry: they move toward a uniform spherical reference in intermediate layers and then return to structured, topic-dependent representations near the output. We further measure an interacting-particle energy on these hidden-state clouds and observe the same U-shape pattern. We then prove that transformers can approximate an energy-based sampler, constructing the same U-shape energy across the layers.