Token Sample Complexity of Attention

Léa Bohbot, Cyril Letrouit, Gabriel Peyré, François-Xavier Vialard

TL;DR

This paper introduces token sample complexity, a framework that quantifies how quickly the attention mechanism converges to its infinite-token limit as the input sequence length ($n$) grows. The authors reveal that instead of the standard parametric rate of $1/\sqrt{n}$, attention maps and moments converge at a slower, sub-parametric rate ($n^{-\beta}$, where $\beta < 1/2$) governed by an "attention horizon." This implies steep diminishing returns when feeding increasingly massive contexts into Transformers at inference time.

What Problem Does This Paper Address?

Modern Large Language Models (LLMs) boast context windows expanding from 100K to over 10M tokens. While this enables processing entire codebases or books, it raises a fundamental question: How efficiently does the attention mechanism utilize these massive contexts?

Traditional statistical learning theory focuses on sample complexity—how much training data a model needs to generalize. This paper shifts the focus to inference time, introducing token sample complexity. By fixing the model's trained parameters, the authors investigate how many context tokens are required for a finite sequence's attention output to accurately approximate the true, infinite-token limit distribution.

Methods

The authors formalize the infinite-token limit of self-attention by treating a sequence of $n$ tokens as an empirical probability distribution ($\nu_n$) that converges toward an underlying continuous token distribution ($\nu$).

To map out the convergence rates, they analyze two levels:

  1. Pointwise uniform convergence of the attention map over a bounded region.
  2. Convergence of moments (like mean and covariance) of the transformed token distribution.

Because the softmax kernel is not uniformly Lipschitz, standard central limit theorems fail. The authors overcome this by using advanced tools from empirical process theory, specifically Dudley’s entropy integral and chaining methods.

A core contribution of their methodology is defining the Attention Horizon ($H$): $$H := \|\Sigma^{1/2}A\Sigma^{1/2}\|_2$$ where $\Sigma$ is the covariance matrix of the token distribution and $A = K^\top Q$ represents the attention weights. $H$ effectively measures the interaction between data anisotropy (the shape of the token space) and the model's attention geometry. The authors also use Gaussian extreme value theory to analyze the "hardmax" regime ($H \to \infty$).

Datasets

The paper validates its theoretical bounds using both synthetic data and real-world text corpora:

  • Synthetic Data: Centered Gaussian distributions and uniform distributions on a unit sphere.
  • Text Corpora: WikiText-103, Wikipedia (in English, German, and Chinese), and CC-News.
  • Downstream Task: The arxiv-classification dataset (11 categories) was used to evaluate end-to-end performance under sparse token sampling.

Key Insights and Ideas

  • The Sub-Parametric Slowdown: For sub-Gaussian token distributions, the convergence rate scales as $O(n^{-\beta})$ with $\beta < 1/2$. This is systematically slower than the $1/\sqrt{n}$ rate one might naively expect from standard Monte Carlo sampling.
  • The Role of the Attention Horizon ($H$): The slowdown is explicitly driven by $H$. When the directions emphasized by the attention weights align with the high-variance directions of the token distribution, $H$ grows, and convergence slows down dramatically.
  • The Hardmax Penalty: In the extreme regime where softmax approaches a hardmax selection, the convergence rate deteriorates to a painful logarithmic crawl: $1/\sqrt{\ln n}$. This is due to an asymptotic cancellation effect between the sample maximum and minimum for symmetric distributions.

Key Results

  • Empirical Validation of the Horizon Effect: Testing on BERT and BigBird models across multiple languages confirmed that the convergence rate $|\beta|$ systematically degrades as the attention horizon $H$ increases.
Figure 4. Mean convergence rate |β| versus horizon H across BigBird’s layers 0–11 and all text distributions. Markers repre- sent (layer, text configuration) pairs; shapes denote text sources (Wikipedia EN/DE/ZH and CC-News) and colors indicate layers. Larger |β| implies faster convergence. Star markers denote the configurations whose detailed convergence curves are displayed in
  • Downstream Impact: On the arXiv document classification task, the authors replaced dense attention with random sampling of $n$ keys per query. The downstream metrics (logit error, prediction agreement, and accuracy) followed the predicted sub-parametric power laws.
  • Diminishing Context Returns: Crucially, the downstream experiments showed that using just 25% of the keys ($n=1101$) recovered 84.5% accuracy (close to the dense model's 86.4%). Doubling the context tokens beyond this point yielded a meager +0.7% accuracy gain, demonstrating massive inference-time diminishing returns.
Figure 2. Downstream token sample complexity. BigBird–RoBERTa–base is fine-tuned on arxiv-classification and evaluated by replacing dense attention with n i.i.d. sampled keys per query. Curves are stratified by attention horizon H. Logit error, agreement with the dense model, and classification accuracy all show horizon-dependent convergence and diminishing returns as n increases. Shaded bands indicate ±3σ over Monte Carlo repetitions.

Limitations and Future Work

  • The i.i.d. Assumption: The theoretical proofs assume that input tokens are sampled i.i.d. from an underlying distribution, ignoring natural language's sequential/Markovian dependencies. However, the authors note that empirical window-based sampling tests still exhibit the same sub-parametric slowdown.
  • Tightness of Bounds: While the upper bounds match empirical results well, proving the mathematical tightness of the sub-Gaussian upper bound in the Gaussian setting remains an open problem.
  • Extension to Non-Gaussian Text: Future work includes identifying specific structural classes of real-world text distributions that map to exact, tight convergence rates.

Summary updated

BibTeX
@inproceedings{bohbot2026token,
  author = {Léa Bohbot and Cyril Letrouit and Gabriel Peyré and François-Xavier Vialard},
  title = {{Token Sample Complexity of Attention}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=K5blb595KX},
}
Figure