Transformers as Measure-Theoretic Associative Memory: A Statistical Perspective and Minimax Optimality

Ryotaro Kawata, Taiji Suzuki

Introduction

While Transformers are renowned for their ability to process massive contexts, mathematical analyses typically treat these contexts as fixed-length sequences of vectors. This creates a theoretical gap: how do we rigorously analyze a model's capacity to handle variable or "unbounded" context lengths? Furthermore, the "associative memory" property of Transformers—using a query to retrieve specific information from a large memory—is often studied using simplified linear attention or frozen (non-learnable) kernels.

This paper bridges this gap by providing a statistical foundation for Transformers that treats "context" as a continuous probability distribution (a measure) rather than a finite sequence. The authors prove that a shallow Transformer with learned softmax attention can optimally retrieve and process information from these infinite-dimensional contexts, achieving a "minimax optimal" convergence rate governed by the smoothness of the underlying data.

The Measure-Theoretic Framework

The authors recast the Transformer's associative memory function as a recall-and-predict task operating on probability measures.

The recall-and-predict framework for measure-theoretic associative memory

In this framework:

  1. Context as a Measure: A context is viewed as a mixture of distributions $\nu = \frac{1}{I} \sum \mu^{(i)}$, where each component $\mu^{(i)}$ represents a distinct piece of information or "document."
  2. The Task: Given a query $x_q$, the model must first recall the specific component $\mu^{(i^*)}$ associated with that query, and then predict a value based on that recalled distribution.
  3. The Architecture: The authors analyze a depth-2 "Measure-Theoretic Transformer." The first layer utilizes an MLP and learned softmax attention to perform the recall step (filtering the mixture down to the relevant component). The second layer uses another MLP to compute the final prediction.

To handle the infinite-dimensional nature of these measures, the analysis employs Reproducing Kernel Hilbert Spaces (RKHS), assuming the data densities are "smooth" with Mercer eigenvalues decaying exponentially ($\lambda_j \approx \exp(-cj^\alpha)$).

Key Insights and Theoretical Results

By treating context as a distribution, the analysis becomes inherently "length-invariant." Whether processing a thousand tokens or a million, the underlying probability measure remains a stable target for statistical learning.

  • The "Effective Dimension": Despite the infinite-dimensional input space, the smoothness of the data (parameterized by $\alpha$) induces an "effective dimension" $D_{eff} \approx (\log n)^{1/(\alpha+1)}$. This dimension, rather than the raw token count, dictates the learning speed.
  • The Necessity of Softmax: The study highlights that softmax attention is crucial for "spiky" or "one-hot" recall. Linear attention struggles to isolate a single component from a mixture unless the components are perfectly orthogonal, which is rarely true for real-world data.
  • Minimax Optimality: The authors establish that for a Transformer trained via Empirical Risk Minimization (ERM), the population risk converges at a sub-polynomial rate: $R(F^*, \hat{F}_n) \lesssim \exp\left(-\Omega\left((\log n)^{\alpha/(\alpha+1)}\right)\right)$. Crucially, they also prove a matching minimax lower bound with the same exponent $\frac{\alpha}{\alpha+1}$. This proves the Transformer's architecture is statistically "sharp" and optimal for this class of problems.

Empirical Validation

While primarily a theoretical work, the authors validate their findings with a synthetic experiment. They generated densities using an orthonormal trigonometric basis and drew Monte Carlo samples to simulate a "long context." Training a minimal MLP-Attention-MLP architecture to recover hidden coefficients confirmed that the empirical risk follows the sub-polynomial decay predicted by their theorems.

Limitations and Future Directions

  • Smoothness Assumptions: The proofs rely on "very smooth" densities with exponential spectral decay. Real-world data might exhibit heavier-tailed polynomial decay, potentially leading to slower learning rates.
  • Architecture Depth: The analysis focuses on a depth-2 Transformer to isolate the recall-and-predict mechanism. Analyzing how greater depth affects the effective dimension is a natural next step.
  • Separation Constraints: The theory assumes context vectors are sufficiently "well-separated" to enable successful recall. The model's behavior when context components overlap significantly remains an open question.

Summary updated

BibTeX
@inproceedings{kawata2026transformers,
  author = {Ryotaro Kawata and Taiji Suzuki},
  title = {{Transformers as Measure-Theoretic Associative Memory: A Statistical Perspective and Minimax Optimality}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=2JilrTRyhh},
}
Figure