TL;DR
Why is dot-product softmax attention so astonishingly good at learning complex functions? This paper reveals a neat mathematical secret: native softmax attention naturally builds a mesh-free "partition of unity," chopping complex spaces into soft, overlapping local neighborhoods and stitching local predictions into a seamless global whole. Using just two standard encoder blocks, Transformers can approximate continuous functions—even on curved manifolds—and escape the curse of dimensionality without relying on deep layer stacks or architectural hacks.
What Problem Does This Paper Address?
Transformers dominate modern AI, yet our theoretical grasp of why they work lags behind their empirical success. Specifically, what exact role does softmax attention play in approximating functions?
Classical neural network theory usually relies on a "local-to-global" strategy: chop the input domain into a rigid grid (like Cartesian boxes or triangles), approximate the target function locally inside each piece using ReLU layers, and glue them together using a partition of unity (POU)—a set of localized weight functions that sum to 1 everywhere.
However, rigid grids break down on curved, low-dimensional surfaces (Riemannian manifolds) unless you manually construct complex coordinate charts. Furthermore, prior Transformer theories often "cheated" by swapping native softmax for ReLU/hardmax attention, dropping sinusoidal positional encodings, or letting deep feed-forward networks do all the heavy lifting. Whether a native, shallow Transformer could natively adapt to curved geometries using standard softmax attention remained an open puzzle.
Methods
The authors introduce a constructive framework called Softmax Partition of Unity (Softmax POU) and map it directly onto a standard, 2-block dense Transformer with sinusoidal positional encodings.
Instead of rigid grids, imagine scattering a set of reference centers $\{ \boldsymbol{c}_i \}$ across your input space. To approximate a function at an input $\boldsymbol{x}$, you want to weight each center's value by how close $\boldsymbol{x}$ is to $\boldsymbol{c}_i$, using Gaussian-like exponential decay: $\exp(-M_g \|\boldsymbol{x} - \boldsymbol{c}_i\|_2^2)$.
Here is the mathematical magic trick: when you normalize these weights so they sum to 1 (creating a softmax), expand the squared Euclidean distance: $\|\boldsymbol{x} - \boldsymbol{c}_i\|_2^2 = \|\boldsymbol{x}\|_2^2 - 2\langle \boldsymbol{x}, \boldsymbol{c}_i \rangle + \|\boldsymbol{c}_i\|_2^2$. Because $\exp(-M_g \|\boldsymbol{x}\|_2^2)$ appears in both the numerator and every term of the denominator, the quadratic $\|\boldsymbol{x}\|_2^2$ term algebraically cancels out!
What’s left in the exponent is purely linear (affine) in $\boldsymbol{x}$: $2M_g\langle \boldsymbol{x}, \boldsymbol{c}_i \rangle - M_g\|\boldsymbol{c}_i\|_2^2$. And what is a Transformer's dot-product attention best at? Computing inner products and passing them through a softmax!
The authors construct a 2-encoder-block Transformer where the sequence length $P$ acts as a parallel index for the covering centers:
- Block 1 uses multi-head attention and a single-hidden-layer ReLU feed-forward network (FFN) to extract local spatial features (the affine inner products) and local function values, while preserving sinusoidal positional identities.
- Block 2 uses a single attention head to apply the softmax, dynamically computing the POU weights and aggregating the local values into a global prediction.
Datasets
Because this is primarily a theoretical paper, no standard real-world benchmarks are used. For empirical validation, the authors create a synthetic noiseless regression dataset on the unit circle (a 1D manifold embedded in 2D space). They jointly fit eight continuous, periodic, piecewise-linear target functions using 1,024 uniformly sampled training points and evaluate on 4,096 equally spaced points.
Key Insights and Ideas
- Attention is a Mesh-Free Spatial Localizer: By canceling out input-dependent quadratic terms, softmax dot-product attention measures relative Euclidean distances using only affine transformations. Tokens dynamically compete via the softmax denominator to carve up space without needing explicit grids or triangulations.
- Width (Sequence Length) Over Depth: Previous constructive proofs required network depth to grow as target error $\varepsilon$ shrank ($\mathcal{O}(\log(1/\varepsilon))$). Here, depth is fixed at 2 blocks; representational power lives entirely in the sequence length $P$ (the number of local centers).
- Effortless Manifold Adaptivity: Because small ambient Euclidean distances closely approximate geodesic (surface) distances on smooth manifolds, Softmax POU works right out of the box on curved data geometries—no local coordinate charts required.
Key Results
- Approximation & Generalization Bounds: For $\alpha$-Hölder continuous functions (a measure of smoothness where $\alpha \in (0, 1]$) on $[0,1]^d$, the 2-block Transformer achieves uniform error $\varepsilon$ using $\mathcal{O}(\varepsilon^{-d/\alpha})$ parameters. Training via empirical risk minimization on $n$ samples yields a near minimax-optimal generalization error rate of $\mathcal{O}(n^{-\frac{2\alpha}{2\alpha+d}} \log n)$.
- Beating the Curse of Dimensionality: When data lies on a $d$-dimensional manifold inside a high-dimensional ambient space $\mathbb{R}^{\bar{d}}$, both parameter complexity and sample convergence rates depend exclusively on the intrinsic dimension $d$, completely dodging the ambient dimension $\bar{d}$.
- Emergent Localization in Training: In their unit-circle experiment, a 2-block Transformer trained from scratch with Adam and L-BFGS achieved a normalized mean squared error of $9.07 \times 10^{-4}$. Without any locality penalties or pre-assigned centers, diffuse initial attention weights spontaneously evolved into sharp, overlapping, Gaussian-like bumps—mirroring the theoretical Softmax POU construction.
Limitations and Future Work
- Smoothness Cap ($\alpha \le 1$): Because the local approximants at each center are just constants ($g(\boldsymbol{c}_i)$), the theoretical guarantees are restricted to functions with Hölder smoothness $\alpha \in (0, 1]$ (e.g., Lipschitz functions). Capturing higher-order smoothness ($\alpha > 1$) would require local Taylor polynomials rather than constants.
- Future Direction—In-Context Learning: While many researchers view in-context learning as Transformers running implicit gradient descent, the authors suggest their Softmax POU framework offers a fresh lens: viewing in-context inference as adaptive, on-the-fly local-to-global function approximation.
Summary updated