acceptodds
Under review as a conference paper at ICLR 2027

Transformers as In-Context Samplers: From Closed-Form Diffusion to Estimation-Free Sampling

Abstract

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 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 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-shaped pattern. We then prove that transformers can approximate an energy-based sampler, constructing the same U-shaped energy across the layers.

Primary area:
generative models
Keywords:
Transformers, In-context learning, Diffusion models

Reviews

Among:
Shape:
1234this paper, Bottom 27%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 2.00 over 3 reviews, above 27% of the others.
Reviewer_rqFwOpenReview ↗
Rating
1
Confidence
3
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper investigates whether transformers can act as in-context samplers, generating new samples from an unknown distribution based on examples provided in the input context, without updating model parameters. The authors theoretically demonstrate that transformers can simulate closed-form diffusion samplers and approximate an estimation-free sampling (EFS) procedure through specifically constructed attention and feedforward operations. The paper presents synthetic point-cloud experiments to demonstrate in-context sampling and analyzes the layerwise representations of pretrained language models.

Critical strengths
  1. The paper explores a theoretical connection between transformers and generative sampling algorithms. Extending in-context learning from conventional prediction tasks to distribution sampling is a potentially meaningful research direction.

  2. The theoretical constructions are technically sound, particularly the interpretation of softmax attention as computing Gaussian responsibility weights and feedforward layers as implementing iterative sampling updates.

Critical weaknesses
  1. The experiments do not convincingly demonstrate the central claimed capability of in-context sampling. The primary empirical evidence is the smile experiment in Figure 1, where a transformer trained without the smile component generates points along a smile-shaped curve provided through in-context samples. However, I do not think this experiment is sufficient to establish meaningful generalization to unseen distributions. First, the smile-shaped curve is geometrically similar to the circular face boundary included in the training distribution. Both consist of smooth circular arcs. Therefore, generating points along the smile does not necessarily require learning a new distributional structure. The model may simply transfer a familiar local geometric pattern to a different spatial location. Second, and more importantly, the in-context samples in Figure 1(d) already appear to cover the entire region occupied by the predicted tokens. The generated points are located within the geometry defined by the provided samples, rather than demonstrating the ability to infer substantially new structures. Simple interpolation, nearest-neighbor resampling, or kernel density estimation (KDE) could also explain this behavior. None of these explanations requires the transformer to learn a sophisticated or generalizable sampling algorithm. Third, the paper does not compare the transformer with these simple baselines. Without such comparisons, it is difficult to determine whether the transformer demonstrates any meaningful capability beyond local interpolation or empirical-distribution resampling. More convincing experiments would involve training and testing on distributions with substantially different geometric structures, such as training on circular distributions and testing on triangular or multimodal distributions. Importantly, the evaluation should examine whether the generated samples reproduce the target probability distribution, rather than merely following the geometric outline of the in-context points. Overall, Figure 1 provides evidence that the model's outputs depend on the in-context samples, but this is substantially weaker than demonstrating generalizable in-context sampling. Since this capability is central to the paper's motivation, I consider the lack of convincing empirical validation a major weakness.

  2. The theoretical results do not explain the mechanisms learned by trained transformers. The theoretical contributions show that specifically constructed transformer parameters can implement closed-form diffusion and EFS-inspired sampling algorithms. However, demonstrating that a transformer architecture can represent a particular algorithm is different from showing that a transformer trained on data actually learns that algorithm. The paper does not connect the constructed transformer parameters to those obtained through the training procedure. In particular, there is no direct evidence that the trained transformers perform the iterative sampling updates described in the theoretical sections.

  3. The evaluation lacks quantitative evidence of distribution-level generalization. In-context sampling should be evaluated by whether the generated samples follow the probability distribution specified by the context, rather than simply whether they appear geometrically plausible. For example, two distributions may share exactly the same triangular support but assign different probability masses to different edges. A model that generates points along the triangle boundary may appear successful visually, even if it fails to reproduce the correct probability density. The paper does not systematically evaluate such cases. Quantitative metrics such as MMD or Wasserstein distance, together with experiments varying context size, distribution geometry, and probability density, would be necessary to establish the extent of the model's sampling capability.

Questions for authors
  1. How does the smile experiment establish genuine in-context sampling rather than interpolation? The smile geometry resembles the circular boundary in the training distribution, and the predicted samples in Figure 1(d) appear to lie within the region already covered by the in-context samples. Could the authors compare against interpolation, nearest-neighbor resampling, and KDE baselines? Could the authors also evaluate test distributions with substantially different geometries from those encountered during training?

  2. Can the authors show that the generated samples reproduce the target probability distribution, not just its geometric support? For example, can the model distinguish distributions with identical geometric support but different probability densities? Quantitative comparisons using MMD or Wasserstein distance, along with evaluations across different context sizes, would help establish whether the model learns generalizable distribution-sampling behavior.

  3. What evidence connects the theoretical sampling constructions to the actual computations performed by trained transformers? The theorems establish that transformer parameters can implement diffusion or EFS-inspired procedures, but they do not show that training produces these mechanisms. Can the authors provide direct comparisons between learned layerwise updates and the updates prescribed by the proposed sampling algorithms?

3 comments

The smile experiment may reflect familiar geometry, interpolation, or resampling. Tests on different geometries and comparisons with simple baselines are needed.

We added triangular-mouth tests using a transformer trained on circular outlines and eyes, without mouths; Figures F.1 and F.2 show the results.

We have compared the trained models with copying the last point, context resampling, local interpolation, and KDE in Appendix F of the revised submission draft. In these experiments, the transformer’s sampling patterns and MMD values differ from those of copying the last point, random context resampling, KDE, and local interpolation. We therefore do not believe that the transformer output can be explained solely by copying or direct resampling of context points.

The constructions show that transformers can implement the proposed algorithms, but they do not show that training learns these algorithms.

When the U-shaped profile holds for the energy function, we can prove that the implemented algorithm is approximately EFS. This conclusion follows from the gradient theorem. Let

Δℓ=Xℓ+1−Xℓ,γ(s)=Xℓ+sΔℓ,0≤s≤1.\Delta_\ell = X_{\ell+1}-X_\ell, \qquad \gamma(s) = X_\ell + s\Delta_\ell,\quad 0\le s\le 1.

Assuming EE is continuously differentiable, we have

E(Xℓ+1)−E(Xℓ)=∫01⟨∇E(γ(s)),γ′(s)⟩F,ds=⟨G‾ℓ,Δℓ⟩F.E(X_{\ell+1})-E(X_\ell) = \int_0^1 \langle \nabla E(\gamma(s)),\gamma'(s)\rangle_F\\,ds = \langle \overline{G}_\ell,\Delta_\ell\rangle_F.

G‾ℓ=∫01∇E(Xℓ+sΔℓ),ds.\overline{G}_\ell = \int_0^1 \nabla E(X_\ell+s\Delta_\ell)\\,ds.

Here G‾ℓ\overline{G}_\ell is the gradient averaged along the segment between consecutive layer representations. When energy decreases, the update has a negative projection onto this averaged gradient. When energy increases, the projection is positive. Consequently, a U-shaped sequence of energies implies

  1. A negative projection onto the averaged gradient of energy during the descending phase. If energy decreases by at least aℓ>0a_\ell > 0 in layer ℓ\ell, then ⟨−G‾ℓ,Δℓ⟩F≥aℓ\langle-\overline{G}_\ell,\Delta_\ell\rangle_F \ge a_\ell.

  2. A positive projection onto the averaged gradient of energy during the ascending phase. If energy increases by at least bℓ>0b_\ell > 0 in layer ℓ\ell, then ⟨G‾ℓ,Δℓ⟩F≥bℓ\langle\overline{G}_\ell,\Delta_\ell\rangle_F \ge b_\ell.

This gives a precise relation between the U-shaped energy profile and EFS. The transformer’s energy first decreases and then increases across layers, consistent with the gradient descent and ascent phases of EFS.

We will therefore clarify the scope of our claims. The constructions prove that transformers can implement the proposed EFS sampling algorithms. The U-shaped profiles provide a reason to investigate EFS as a method closely resembling the learned algorithm.

Evaluation should measure probability density as well as geometric support, including different context sizes.

We tested the same triangle with edge probabilities (1/3,1/3,1/3)(1/3,1/3,1/3) and (0.7,0.2,0.1)(0.7,0.2,0.1). For the second case, the transformer produces nearest-edge masses of approximately (0.578,0.295,0.127)(0.578,0.295,0.127), showing sensitivity to density. Figure F.4 and Table F.6 report results for context sizes 16, 32, and 64.

I thank the authors for their response, which addresses some of my concerns, but the main issues are still unresolved. Specifically, the transformer still performs worse than simple baselines, which makes me concerned about its ability to learn a generalizable sampling algorithm. I will maintain my original ratings.

We agree that the baselines achieve lower distributional error. This is what we expect; if it wasn't like that, we would be surprised. For copying and resampling, there is a mathematical reason to expect a small MMD. Let X1,…,XnX_1,\dots,X_n be independent draws from PP, and let JJ be a uniformly chosen index independent of the prompt. For any measurable set AA,

Pr⁡(XJ∈A)=1n∑j=1nPr⁡(Xj∈A)=P(A)=Pr⁡(Xn∈A).\Pr(X_J\in A)=\frac{1}{n}\sum_{j=1}^{n}\Pr(X_j\in A)=P(A)=\Pr(X_n\in A).

Thus both uniform resampling and copying the last point have output law PP across prompts. MMD compares the mean kernel features of two distributions, so their population discrepancy is MMDk(P,P)=0\mathrm{MMD}_k(P,P)=0. Even a sampler producing fresh, exact draws from PP can only tie that score.

For the face experiments, we compare BB outputs from independent prompts with MM independent target points. For either copying rule, the expected empirical squared MMD is

E[MMD^k,2]=(1B+1M)(1−E[k(X,X′)])≤1B+1M,\mathbb{E}\big[\widehat{\mathrm{MMD}}_k^{\\,2}\big]=\left(\frac{1}{B}+\frac{1}{M}\right)\big(1-\mathbb{E}[k(X,X')]\big)\leq\frac{1}{B}+\frac{1}{M},

where X,X′X,X' are independent draws from PP. This uses the Gaussian kernel and the estimator with diagonal terms in Appendix F.3. In the scalar experiments, the reference is drawn from the pooled contexts. Uniform resampling also reproduces that pool in expectation. These observations explain why copying and resampling are strong baselines.

Fu et al. (came on arxiv after the ICLR deadline) study a related setting where the model must generate an output for a new query. Copying a demonstration output need not give the correct distribution for that query. Their theorem gives a total-variation guarantee for a transformer pretrained across tasks. Fu et al., Diffusion Transformers are Provably Optimal In-context Generators

Reviewer_zf8BOpenReview ↗
Rating
2
Confidence
2
Informativeness
2
Presentation
3
Soundness
1
Read review
Paper summary

In this paper, the authors study the capability of transformers to implement certain iterative sampling algorithms that allow the model to sample new tokens from new distributions just by providing the model with samples from the target distribution in-context. More specifically, the authors show that transformers can simulate closed-form diffusion (Theorem 1) and EFS (Theorem 2) algorithms. The authors also conduct two kinds of experimental results: (i) they provide mechanistic evidence that real-world transformer-based LLMs might implement something related to the EFS algorithm of Theorem 2 by showing that the repulsive-interactive energy of word embeddings in real-world pretrained LLMs follows the U-shaped curve predicted by the theory (Figure 5); and (ii) they train a transformer on synthetic data and verify that the output tokens from the model follow the in-context distribution (Figure 1).

Critical strengths

In my opinion the greatest strength of the paper lies in the theoretical results, which prove that transformers can efficiently implement iterative sampling algorithms. Even though the results are only representational and do not prove that transformers eventually learn such configurations by gradient descent, they still rely on interesting and clever constructions and are worthy of publication.

Critical weaknesses

The weak part of the work is in my opinion the experimental section.

The experiments in Sections 4 and 5.1 show an intriguing trend across transformer layers but they do not by themselves prove that real-world pretrained LLMs actually implement iterative sampling algorithms such as EFS internally. In fact, it is not clear why general-purpose LLMs would learn to implement such an algorithm in the first place.

But most of all, I am concerned about the experiment on synthetic data shown in Figure 1, in particular the one in subfigure (d). Usually in previous in-context learning studies on transformers, in order for the models to learn to implement in-context strategies at inference, it is required to train them on data sampled from mixture distributions. This is to avoid that the model simply learns a specific data distribution, see, e.g., the works on transformers learning to predict Markov distributions in-context [1,2,3]. Somehow Figure 1(d) shows that the model is able to predict the "smile" portion of the distribution in-context after having been fully trained on iid samples from a fixed distribution that does not include the smile portion. I do not see a way for the model to avoid to simply learn to output a new sample from the training distribution, instead of implementing some complex iterative sampling strategy. Or even worse, it might be learning to just copy or average the input tokens.


References

[1] E. Edelman et al., "The evolution of statistical induction heads: In-context learning Markov chains", 2024.

[2] N. Rajaraman et al., "Transformers on Markov data: Constant depth suffices", 2024.

[3] Eshaan Nichani et al., "How Transformers Learn Causal Structure with Gradient Descent", 2024.

Questions for authors

My main concerns are on the experimental section of the paper:

  1. Can you provide more evidence that in the experiment in Figure 1(d) the model is not simply learning a copying or averaging mechanism but it is actually learning some more advanced interactive sampling algorithm?
  2. The experiment in Figure 5 is interesting but not sufficient to corroborate the thesis that pretrained LLMs internally implement something akin to a EFS algorithm. A more convincing experiment would be to track the energy gradient directions across layers instead of the scalar energy. Could you provide some experimental results along these lines?
  3. Why did you choose to normalize the token embeddings in the way you did in the experiments shown in Figures 4 and 5, and would different normalisation choices (for example, a fixed normalisation instead of a per-token one) significantly affect the resulting curves?

I will be happy to increase my score if my concerns are addressed satisfactorily.

3 comments

With a fixed training distribution, the smile experiment may reflect copying or averaging rather than an in-context sampling algorithm.

We have compared the trained models with copying the last point, context resampling, local interpolation, and KDE in Appendix F of the revised submission draft. In these experiments, the transformer’s sampling patterns and MMD values differ from those of copying the last point, random context resampling, KDE, and local interpolation. We therefore do not believe that the transformer output can be explained solely by copying or direct resampling of context points.

Scalar energy curves do not establish EFS in pretrained LLMs. Can layerwise updates be compared with energy-gradient directions?

When the U-shaped profile holds for the energy function, we can prove that the implemented algorithm is approximately EFS. This conclusion follows from the gradient theorem. Let

Δℓ=Xℓ+1−Xℓ,γ(s)=Xℓ+sΔℓ,0≤s≤1.\Delta_\ell = X_{\ell+1}-X_\ell, \qquad \gamma(s) = X_\ell + s\Delta_\ell,\quad 0\le s\le 1.

Assuming EE is continuously differentiable, we have

E(Xℓ+1)−E(Xℓ)=∫01⟨∇E(γ(s)),γ′(s)⟩F,ds=⟨G‾ℓ,Δℓ⟩F.E(X_{\ell+1})-E(X_\ell) = \int_0^1 \langle \nabla E(\gamma(s)),\gamma'(s)\rangle_F\\,ds = \langle \overline{G}_\ell,\Delta_\ell\rangle_F.

G‾ℓ=∫01∇E(Xℓ+sΔℓ),ds.\overline{G}_\ell = \int_0^1 \nabla E(X_\ell+s\Delta_\ell)\\,ds.

Here G‾ℓ\overline{G}_\ell is the gradient averaged along the segment between consecutive layer representations. When energy decreases, the update has a negative projection onto this averaged gradient. When energy increases, the projection is positive. Consequently, a U-shaped sequence of energies implies

  1. A negative projection onto the averaged gradient of energy during the descending phase. If energy decreases by at least aℓ>0a_\ell > 0 in layer ℓ\ell, then ⟨−G‾ℓ,Δℓ⟩F≥aℓ\langle-\overline{G}_\ell,\Delta_\ell\rangle_F \ge a_\ell.

  2. A positive projection onto the averaged gradient of energy during the ascending phase. If energy increases by at least bℓ>0b_\ell > 0 in layer ℓ\ell, then ⟨G‾ℓ,Δℓ⟩F≥bℓ\langle\overline{G}_\ell,\Delta_\ell\rangle_F \ge b_\ell.

This gives a precise relation between the U-shaped energy profile and EFS. The transformer’s energy first decreases and then increases across layers, consistent with the gradient descent and ascent phases of EFS.

We will therefore clarify the scope of our claims. The constructions prove that transformers can implement the proposed EFS sampling algorithms. The U-shaped profiles provide a reason to investigate EFS as a method closely resembling the learned algorithm.

Why normalize each token separately, and do other normalizations change the curves?

We normalize each token vector to the same length because our energy analysis assumes the vectors lie on a sphere. To test how this choice affects the results, in our new experiments we compared three methods across all 40 Cerebras-GPT-13B blocks, using 30 prompts per topic for animals, foods, and cities (Appendix F.6.2).

  1. Per-token unit norm with centering. Subtract the mean of each token vector’s coordinates, then scale that vector to unit length.
  2. Cloud-RMS. Subtract the mean token vector within each prompt, then divide all centered vectors by their root-mean-square length. Individual token lengths can differ.
  3. Per-token unit norm without centering. Scale each token vector directly to unit length.

Both per-token methods reproduce the U-shaped energy profile from our previous simulations. Centering has little effect on either curve, and both energy and MMD reach their minima at block 24 for all three topics. Under cloud-RMS, energy peaks at block 15 for animals and foods and at block 16 for cities (Figure F.5). This normalization holds the quadratic energy term constant across blocks, so the peak comes from the logarithmic repulsion term. Figure F.6 shows the corresponding reference checks.

I thank the authors for their response. However, my main concerns remain unresolved.

  1. In-context sampling. The new experiments rule out exact copying and simple averaging, but the transformer performs worse than all the simple baselines in terms of distributional accuracy (Tables F.2–F.5).

  2. EFS mechanism. The gradient-theorem argument does not establish that the transformer approximately implements EFS. A decrease in energy only implies a negative projection onto the averaged gradient, not that the update approximately follows that gradient.

  3. Normalization. The new experiments are useful, but Figure F.5 shows that cloud-RMS normalization produces an approximately inverted-U energy curve. This suggests that the central geometric observation is strongly dependent on the normalization choice.

Overall, I am still not convinced that the experiments prove the connection between pre-trained transformers and iterative sampling algorithms such as EFS.

Thank you for following up.

In-context sampling. We agree that the baselines achieve lower distributional error. This is what we expect; if it wasn't like that, we would be surprised. For copying and resampling, there is a mathematical reason to expect a small MMD. Let X1,…,XnX_1,\dots,X_n be independent draws from PP, and let JJ be a uniformly chosen index independent of the prompt. For any measurable set AA,

Pr⁡(XJ∈A)=1n∑j=1nPr⁡(Xj∈A)=P(A)=Pr⁡(Xn∈A).\Pr(X_J\in A)=\frac{1}{n}\sum_{j=1}^{n}\Pr(X_j\in A)=P(A)=\Pr(X_n\in A).

Thus both uniform resampling and copying the last point have output law PP across prompts. MMD compares the mean kernel features of two distributions, so their population discrepancy is MMDk(P,P)=0\mathrm{MMD}_k(P,P)=0. Even a sampler producing fresh, exact draws from PP can only tie that score.

For the face experiments, we compare BB outputs from independent prompts with MM independent target points. For either copying rule, the expected empirical squared MMD is

E[MMD^k,2]=(1B+1M)(1−E[k(X,X′)])≤1B+1M,\mathbb{E}\big[\widehat{\mathrm{MMD}}_k^{\\,2}\big]=\left(\frac{1}{B}+\frac{1}{M}\right)\big(1-\mathbb{E}[k(X,X')]\big)\leq\frac{1}{B}+\frac{1}{M},

where X,X′X,X' are independent draws from PP. This uses the Gaussian kernel and the estimator with diagonal terms in Appendix F.3. In the scalar experiments, the reference is drawn from the pooled contexts. Uniform resampling also reproduces that pool in expectation. These observations explain why copying and resampling are strong baselines.

Fu et al. (came on arxiv after the ICLR deadline) study a related setting where the model must generate an output for a new query. Copying a demonstration output need not give the correct distribution for that query. Their theorem gives a total-variation guarantee for a transformer pretrained across tasks. Fu et al., Diffusion Transformers are Provably Optimal In-context Generators

EFS mechanism. We agree that the gradient theorem gives ⟨G‾ℓ,Δℓ⟩F=E(Xℓ+1)−E(Xℓ)\langle\overline{G}_\ell,\Delta_\ell\rangle_F=E(X_{\ell+1})-E(X_\ell). This fixes the inner product with the averaged gradient and leaves the perpendicular component unrestricted. Our construction proves that one set of transformer weights can approximate the output of the EFS-inspired iteration across admissible prompts. Whether pretrained language models learn that iteration remains open.

Normalization. Both per-token normalizations give a U-shaped energy profile. Cloud-RMS centers the vectors within each prompt and fixes their mean squared length. If the normalized vectors are z1,…,znz_1,\ldots,z_n with root-mean-square length rr, their quadratic energy term is

1n(n−1)∑i≠j12∥zi−zj∥2=nn−1r2.\frac{1}{n(n-1)}\sum_{i\ne j}\frac{1}{2}\lVert z_i-z_j\rVert^2=\frac{n}{n-1}r^2.

This term is constant across layers for a given prompt. The middle-layer peak under cloud-RMS therefore comes from the logarithmic term. We will state explicitly that the observed U-shape depends on normalizing each token to a common length.

Reviewer_ctC5OpenReview ↗
Rating
3
Confidence
2
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper studies in-context sampling: whether a frozen transformer can use samples supplied in its context to generate samples from a prompt-specified distribution. The authors construct transformers that exactly implement finite-step closed-form diffusion and its smoothed variant, using softmax attention to compute Gaussian responsibility weights and weighted empirical averages. They further establish an approximation result for an explicit EFS-inspired forward–backward particle recurrence. Experiments on synthetic distributions demonstrate adaptation to unseen prompt geometry, while analyses of pretrained language models reveal a frequently U-shaped layerwise profile in spherical MMD and interaction energy.

Critical strengths
  • The paper introduces an interesting perspective on in-context learning by extending it to sampling from prompt-specified distributions.
  • The explicit connection between softmax attention and Gaussian responsibility weights is elegant and provides a concrete explanation of the architecture’s suitability for sampling.
  • Synthetic experiments and layerwise observations across pretrained models motivate the proposed transport interpretation. The appendices carefully clarify the scope of the theoretical guarantees.
Critical weaknesses
  • The gap between expressivity and learned mechanism remains: the constructions establish implementability, while the U-shaped profiles do not uniquely identify EFS.
  • Synthetic sampling results are mainly qualitative. Since the OT training targets largely overlap with the inputs, comparisons with copying, resampling, and interpolation baselines would strengthen the evidence.
  • The layerwise diagnostics need further controls for normalization and reference support. MMD and interaction energy are mathematically related, limiting their value as independent evidence.
Questions for authors
  • Can the authors quantify synthetic sampling quality against direct context resampling and local interpolation, including both distributional accuracy and distance from context points?
  • How is randomness introduced in the trained synthetic model? With a fixed context, can repeated evaluations produce different samples, and what independence properties are intended by “IID” in the figures?
2 comments

The constructions establish implementability, while the U-shaped profiles do not uniquely identify EFS.

When the U-shape profile holds for the energy function, we can prove that the implement algorithm is approximately EFS. This conclusion follows from the gradient theorem. Let

Δℓ=Xℓ+1−Xℓ,γ(s)=Xℓ+sΔℓ,0≤s≤1.\Delta_\ell = X_{\ell+1}-X_\ell, \qquad \gamma(s) = X_\ell + s\Delta_\ell,\quad 0\le s\le 1.

Assuming EE is continuously differentiable, we have

E(Xℓ+1)−E(Xℓ)=∫01⟨∇E(γ(s)),γ′(s)⟩F,ds=⟨G‾ℓ,Δℓ⟩F.E(X_{\ell+1})-E(X_\ell) = \int_0^1 \langle \nabla E(\gamma(s)),\gamma'(s)\rangle_F\\,ds = \langle \overline{G}_\ell,\Delta_\ell\rangle_F.

G‾ℓ=∫01∇E(Xℓ+sΔℓ),ds.\overline{G}_\ell = \int_0^1 \nabla E(X_\ell+s\Delta_\ell)\\,ds.

Here G‾ℓ\overline{G}_\ell is the gradient averaged along the segment between consecutive layer representations. When energy decreases, the update has a negative projection onto this averaged gradient. When energy increases, the projection is positive. Consequently, a U-shaped sequence of energies implies

  1. A negative projection onto the averaged gradient of energy during the descending phase. If energy decreases by at least aℓ>0a_\ell > 0 in layer ℓ\ell, then ⟨−G‾ℓ,Δℓ⟩F≥aℓ\langle-\overline{G}_\ell,\Delta_\ell\rangle_F \ge a_\ell.

  2. A positive projection onto the averaged gradient of energy during the ascending phase. If energy increases by at least bℓ>0b_\ell > 0 in layer ℓ\ell, then ⟨G‾ℓ,Δℓ⟩F≥bℓ\langle\overline{G}_\ell,\Delta_\ell\rangle_F \ge b_\ell.

This gives a precise relation between the U-shaped energy profile and EFS. The transformer’s energy first decreases and then increases across layers, consistent with the gradient descent and ascent phases of EFS.

We will therefore clarify the scope of our claims. The constructions prove that transformers can implement the proposed EFS sampling algorithms. The U-shaped profiles provide a reason to investigate EFS as a method closely resembling the learned algorithm.

The overlap between OT training targets and inputs makes comparisons with copying, resampling, and interpolation important.

We have compared the trained models with copying the last point, context resampling, local interpolation, and KDE in the Appendix F of the revised submission draft. In these experiments, the transformer’s sampling patterns and MMD values differ from those of copying the last point, random context resampling, KDE, and local interpolation. We therefore do not believe that the transformer output can be explained solely by copying or direct resampling of context points.

Layerwise diagnostics need controls for normalization and reference support.

We normalize each token vector to the same length because our energy analysis assumes the vectors lie on a sphere. To test how this choice affects the results, in our new experiments we compared three methods across all 40 Cerebras-GPT-13B blocks, using 30 prompts per topic for animals, foods, and cities (Appendix F.6.2).

  1. Per-token unit norm with centering. Subtract the mean of each token vector’s coordinates, then scale that vector to unit length.
  2. Cloud-RMS. Subtract the mean token vector within each prompt, then divide all centered vectors by their root-mean-square length. Individual token lengths can differ.
  3. Per-token unit norm without centering. Scale each token vector directly to unit length.

Both per-token methods reproduce the U-shaped energy profile from our previous simulations. Centering has little effect on either curve, and both energy and MMD reach their minima at block 24 for all three topics. Under cloud-RMS, energy peaks at block 15 for animals and foods and at block 16 for cities (Figure F.5). This normalization holds the quadratic energy term constant across blocks, so the peak comes from the logarithmic repulsion term. Figure F.6 shows the corresponding reference checks.

MMD and interaction energy are related, limiting their value as independent evidence.

We agree and will only include the energy profile in future versions.

Can sampling quality be compared with resampling and interpolation using both distributional accuracy and distance from context points?

We have compared the trained models with copying the last point, context resampling, local interpolation, and KDE in the Appendix F of the revised submission draft. In these experiments, the transformer’s sampling patterns and MMD values differ from those of copying the last point, random context resampling, KDE, and local interpolation. We therefore do not believe that the transformer output can be explained solely by copying or direct resampling of context points.

Where does randomness enter the synthetic model? What does “IID” mean in the figures?

For a fixed checkpoint, evaluation is deterministic. Repeating the same ordered context returns the same point. Randomness is due to the generation of the contexts. We revise “Predicted IID tokens.” to “Model outputs from independent prompts”.

I appreciate the authors’ feedback. This work broadens my understanding of what in-context learning can do beyond function prediction. However, the evidence for the proposed mechanism remains largely empirical, and the theoretical results only offers one plausible explanation for the observed behavior. It is not enough for me to raise my score to Accept. Therefore, I maintain my Weak Accept recommendation.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.