Efficient and Minimax Optimal In-context Nonparametric Regression with Transformers

Michelle Ching, Ioana Popescu, Nico Smith, Tianyi Ma, William G. Underwood, Richard J. SamworthICML 2026

Introduction

In-context learning (ICL) allows Large Language Models to solve novel tasks simply by observing a few examples in a prompt, without any weight updates. While empirically successful, the theoretical mechanisms enabling ICL remain an active area of research. This paper demonstrates that Transformers can achieve the minimax optimal rate of convergence for nonparametric regression through ICL using surprisingly few parameters—scaling only logarithmically relative to the number of examples ($\Theta(\log n)$). The authors prove that Transformers achieve this by internally approximating a classical statistical method called local polynomial estimation through a series of gradient descent steps implemented within their attention layers.

The Problem: In-Context Nonparametric Regression

The authors investigate nonparametric regression: predicting a value based on examples where the underlying relationship is "smooth" (specifically $\alpha$-Hölder smooth) but does not follow a simple linear formula.

Previous theoretical work suggested that for a Transformer to be statistically optimal at this task, it required a massive number of parameters—growing polynomially with the number of examples ($n$). This paper challenges that assumption, asking whether a much smaller, more efficient Transformer can still reach the theoretical limit of accuracy, known as the minimax rate.

Methodology: Transformers as Meta-Optimizers

The researchers combine approximation theory and statistical learning theory to prove their results. Instead of relying on standard benchmarks, they utilize synthetic data generated from a rigorous mathematical mechanism (regression functions drawn from a Hölder ball) and simulation data drawn from random Fourier series.

Their key technical approach involves:

  • Algorithmic Approximation: The authors prove that a Transformer architecture, utilizing linear attention and ReLU feed-forward networks (FFNs), can be "programmed" to implement a local polynomial estimator.
  • Internal Gradient Descent: Rather than attempting complex matrix inversions—which are notoriously difficult for Transformers—the model uses its layers to perform $\Theta(\log n)$ steps of gradient descent. This allows it to efficiently solve the weighted least squares problem required for local polynomial regression.
  • Risk Decomposition: Using empirical process theory and covering number bounds, they show that a Transformer trained via empirical risk minimization (ERM) will converge to this optimal solution.
  • Parameter Efficiency: By leveraging the fact that FFN layers can approximate polynomials exponentially fast and attention layers can implement iterative optimization, the total parameter count only needs to grow logarithmically with $n$.

Key Insights and Theoretical Results

The paper yields several profound insights into how Transformers process information and optimize tasks internally:

  • Optimal Convergence: The Transformer achieves the minimax optimal mean squared error rate of $O(n^{-2\alpha/(2\alpha+d)})$.
  • The Power of Logarithmic Scaling: The most striking finding is that a model does not need to be "wide" or "deep" (in terms of $n$) to be statistically optimal. A model with $\Theta(\log n)$ parameters is sufficient to hit the minimax limit, drastically improving upon previous bounds that required $\Theta(n^{d/(2\alpha+d)})$ or even $\Theta(n)$ parameters.
  • Substantially Lower Pretraining Requirements: Because the model is highly parameter-efficient, the theory demonstrates it requires significantly fewer pretraining sequences ($\Omega(n^{2\alpha/(2\alpha+d)} \log^3 n)$) than previously estimated to learn these capabilities.
  • Empirical Validation: In simulations, the pretrained Transformer not only matched the performance of classical local polynomial estimators but actually outperformed them, demonstrating a more robust adaptation to the data.

Limitations and Future Directions

While the theoretical guarantees are strong, the paper notes a few limitations. First, it proves that an optimal Transformer exists and that ERM will find it, but it does not fully analyze the training dynamics (i.e., whether standard optimizers like SGD or Adam will reliably converge to this specific algorithmic structure in practice). Second, while the model is optimal, the convergence rate still suffers from the "curse of dimensionality" (represented by $d$ in the exponent). Future work could explore exploiting low-dimensional structures, such as the manifold hypothesis, to bypass this limitation. Finally, extending this regression-focused study to the specific "next-token" autoregressive setup used by modern LLMs remains a promising next step.

Summary updated

BibTeX
@inproceedings{ching2026efficient,
  author = {Michelle Ching and Ioana Popescu and Nico Smith and Tianyi Ma and William G. Underwood and Richard J. Samworth},
  title = {{Efficient and Minimax Optimal In-context Nonparametric Regression with Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=3hD1gzThtY},
}
Figure