TL;DR
Standard neural networks with ReLU activations can only construct piecewise linear functions, meaning they always incur approximation errors when fitting smooth non-linear curves like polynomials. This paper proves that a single-head self-attention transformer can compute any degree-$q$ polynomial with zero approximation error using just $q$ transformer blocks. Crucially, the attention and feed-forward blocks require no training at all—only the input embedding and output linear head need to be learned.
What Problem Does This Paper Address?
Despite the widespread success of Transformers in vision and natural language processing, their theoretical foundations remain less understood than those of classical multilayer perceptrons (MLPs). In statistical learning theory, fitting a target function typically involves a trade-off between approximation error (how well the model class can express the ground truth) and estimation/sample error (variance from finite training data).
For traditional ReLU networks, exact representation of polynomials is impossible with finite width and depth because ReLU networks produce piecewise linear outputs. The authors investigate whether the dot-product operation at the heart of self-attention mechanisms can fundamentally alter this dynamic by allowing exact polynomial representation with fixed, finite network structures.
Methods
The authors propose an adapted single-head self-attention architecture:
- Global Feature Pre-processing: Instead of patchifying inputs, the model computes global ridge projections $t = Fx \in \mathbb{R}^n$, where $F$ is a learnable matrix. The inputs are structured into sparse vectors $z_i \in \mathbb{R}^{n+q+2}$ holding $t_i$, a one-hot feature indicator (acting as positional encoding), and placeholder zeros for block outputs.
- Hard Max Attention: The standard softmax function in self-attention is replaced by a "one-hot maximum" operator that routes attention exclusively to the maximum matching key-query score while setting other values to zero.
- Untrained, Fixed Encoder Blocks: By setting fixed, sparse query ($W^Q$), key ($W^K$), value ($W^V$), and MLP weights ($W_1, W_2, b_1, b_2$), each transformer block computes the exact product of two elements via the attention dot-product and ReLU algebra, storing higher-order terms in the allocated zero positions.
- Ridge Representation Theorem: Leveraging a classical result from Zhou (2018), any multivariate degree-$q$ polynomial can be expressed as a linear combination of ridge powers $(\xi_k \cdot x)^s$ for $s \le q$. With $q$ transformer blocks computing these powers successively, a linear readout head $\beta$ and bias $b$ reconstruct the polynomial exactly.
Only $F$, $\beta$, and $b$ contain free, trainable parameters; the transformer blocks themselves remain frozen.
Datasets
The authors evaluate their architecture on:
- Synthetic Polynomial Regression:
- 2D quadratic: $f_{\rho,1}(x) = x_1^2 + x_2^2$ ($d=2, q=2$)
- 10D quintic: $f_{\rho,2}(x) = x_1^5 + 3x_2^4 + 2x_3^3 + 5x_3x_4 + 3x_5^2 + 2x_6x_7x_8 + 2x_9$ ($d=10, q=5$)
- Additional stress-test polynomials: $f_{\rho,3}(x) = (\sum_{i=1}^5 x_i)^5$ and $f_{\rho,4}(x) = x_1^3 + x_2^3$.
- Household Electric Power Consumption Benchmark: Real-world UCI regression benchmark ($>2$ million records) predicting global active power from voltage, current intensity, and power metrics.
- CIFAR-10: Standard 10-class image classification benchmark (50,000 training, 10,000 test images).
Key Insights and Ideas
- Attention as an Exact Multiplier: The core bottleneck of ReLU MLPs is their inability to perform true element-wise multiplication $x \cdot y$. Because self-attention inherently computes pairwise dot products ($\langle q_i, k_j \rangle$), it acts as a native multiplier.
- Zero Approximation Error: When the target is a polynomial of degree $q$, a $q$-block single-head transformer matches the target function identically on bounded sets ($\|x\| \le B$).
- Elimination of the Bias-Variance Trade-Off: Because approximation error is identically zero, the model completely bypasses the classic trade-off in mean squared error analysis. The regression risk converges at a rate of $\mathcal{O}\left(\frac{\log N}{N}\right)$, governed purely by sample size $N$.
- Freezing Encoder Weights: All internal attention and MLP block parameters are static algebraic gadgets; learning is restricted to a small set of linear parameters (less than $d^{q+1} + q d^q + 1$).
Key Results
- Synthetic Fitting & Noise Robustness: On $f_{\rho, 1}$, the proposed model achieves a test MSE of 0.02 with only 19 free parameters, whereas depth- and width-matched ReLU MLPs score 134.23 and 10,237.27, respectively. On the 10D quintic polynomial $f_{\rho, 2}$, the attention model achieves 0.109 test MSE (converging in 212 epochs / 1.9 GPU-minutes) compared to 103.92 for deep MLPs and 35.66 for wide MLPs.
- Sample Error Scaling: Empirical test MSE monotonically drops toward zero as sample size $N$ increases from $10^3$ to $10^5$, matching the predicted $\mathcal{O}\left(\frac{\log N}{N}\right)$ rate.
- Household Power Consumption: The model achieves lower test MSE (0.0094) than parameter-comparable deep MLPs (0.9017) and wide MLPs (0.0097).
- CIFAR-10 from Scratch: A 2-layer attention hybrid model reaches 85.43% test accuracy, outperforming a 12-layer Vision Transformer (ViT) baseline trained from scratch (81.26%).
Limitations and Future Work
- Modified Attention Mechanics: The mathematical proofs depend on swapping the continuous softmax function for a hard one-hot argmax operator, which deviates from standard Transformers deployed in industry.
- Prior Bound Requirements: The theoretical construction assumes an a priori bound $M$ (or $B$) on input features to guarantee that the one-hot selection condition separates correctly.
- Single-Head Scope: The formal theory covers only single-head self-attention; extending the exact algebra to multi-head attention and exploring how layer normalization interacts with these properties remain open questions.
Summary updated