Attention Mechanism, Max-Affine Partition, and Universal Approximation
Hude Liu, Jerry Yao-Chieh Hu, Zhao Song, Han Liu
TL;DR
This work proves that a minimalist attention block—comprising a single-layer, single-head self- or cross-attention preceded by a linear layer—has universal sequence-to-sequence approximation power under $L_\infty$ (and $L_p$ for $1\le p<\infty$) norms, even without positional encodings or FFNs. It introduces a max-affine partition interpretation of attention, where attention scores encode partition indicators and reassign values across partition cells, enabling piecewise-constant and piecewise-linear approximations of target functions. The results establish a constructive, theory-grounded view of Transformer expressivity, showing cross-attention shares the same universality as self-attention under a minimalist design. Practical extensions and proof-of-concept experiments further illustrate how these partition-based mechanisms behave under noise and in data-limited regimes, highlighting both the potential and current limitations of attention-centric universal approximation in real-world settings.
Abstract
We establish the universal approximation capability of single-layer, single-head self- and cross-attention mechanisms with minimal attached structures. Our key insight is to interpret single-head attention as an input domain-partition mechanism that assigns distinct values to subregions. This allows us to engineer the attention weights such that this assignment imitates the target function. Building on this, we prove that a single self-attention layer, preceded by sum-of-linear transformations, is capable of approximating any continuous function on a compact domain under the $L_\infty$-norm. Furthermore, we extend this construction to approximate any Lebesgue integrable function under $L_p$-norm for $1\leq p <\infty$. Lastly, we also extend our techniques and show that, for the first time, single-head cross-attention achieves the same universal approximation guarantees.
