Attention Mechanism, Max-Affine Partition, and Universal Approximation

Hude Liu, Jerry Yao-Chieh Hu, Zhao Song, Han Liu · DOI

Abstract

While Transformers have revolutionized artificial intelligence, the theoretical foundations of their expressive power remain a subject of intense study. This paper investigates the absolute minimum architecture required for universal approximation. We demonstrate that a single layer of single-head attention, combined with a simple linear transformation, is sufficient to approximate any continuous sequence-to-sequence function. By interpreting the softmax attention mechanism as a "max-affine partition" tool, we show that attention alone can divide the input space into discrete subregions and assign precise values to each, achieving theoretical guarantees previously attributed only to much more complex architectures.

Introduction

Transformers have become the standard architecture for modern AI, yet our understanding of their success often relies on empirical results rather than first principles. A key question in neural network theory is "Universal Approximation": the mathematical proof that a model can represent any function given sufficient parameters. Previous proofs for Transformers often relied on multi-layer stacks, multi-head attention, or the presence of Feed-Forward Networks (FFNs) and positional encodings. This research strips away these components to isolate the core expressive power of the softmax attention module itself.

The Mechanism: Attention as a Geometric Partition

The authors employ a constructive proof strategy that reinterprets the attention mechanism as an input domain-partition mechanism. Rather than viewing attention simply as a way to "mix" tokens, it is modeled as a geometric tool that performs a Voronoi-like tessellation of the high-dimensional input space.

1. Max-Affine Partitioning

The researchers show that a single-head attention module can be engineered to act as a "max-affine" function. This process carves the input space into a grid of "cells." Each cell corresponds to a specific region where the model can define a unique behavior.

2. Indicator Generation and Softmax as a Switch

By carefully configuring the weights of the Query ($W_Q$) and Key ($W_K$) matrices, the softmax operation is forced to act as a "continuous arg max." For any given input, the attention scores converge toward a "near-one-hot" vector. This vector identifies exactly which cell of the partition the input belongs to, effectively acting as a differentiable switch.

3. Value Assignment

Once the input is localized within a specific cell, the Value matrix ($W_V$) acts as a lookup table. It provides the target function's value for that specific region. This three-step process—partitioning, selecting, and looking up—allows the model to approximate complex, non-linear functions through piecewise-linear construction.

Theoretical Results

The paper provides two primary theorems that establish the minimalist power of attention:

  • Theorem 4.1 ($L_\infty$ Universality): A single self-attention layer, preceded by a sum-of-linear transformations, can approximate any continuous function on a compact domain to an arbitrary precision $\epsilon$ under the $L_\infty$-norm (maximum error).
  • Theorem 4.2 (Cross-Attention): The authors prove that single-head cross-attention (where queries and keys originate from different sequences) shares the same universal approximation guarantees as self-attention. This establishes cross-attention as an independently powerful expressive tool.

These proofs are extended to Lebesgue integrable functions under the $L_p$-norm using Lusin’s theorem, ensuring the results hold for a broad class of mathematical functions.

Empirical Validation

To support their theoretical findings, the authors conducted several "proof-of-concept" experiments:

  • Synthetic Step Functions: Numerical tests confirmed that the max-affine functions generated by attention could learn to separate input domains based on target values.
  • Noise Sensitivity in Image Datasets: Using MNIST, CIFAR-10, and Fashion-MNIST, the researchers tested how the scale of attention weights relates to data noise. They found that as label noise increased, the scale of the learned weights ($W_K, W_Q$) decreased. This aligns with the theory: higher noise makes precise partitioning more difficult, leading the model to "blur" its partitions by effectively increasing the softmax temperature.

Discussion and Limitations

While this paper proves that a single layer can approximate any function, it does not necessarily suggest that we should use such minimalist models in practice. The "constructive" proof requires a massive number of partition regions, which translates to a very high hidden dimension. This leads to the "curse of dimensionality," where the number of parameters needed grows exponentially with the input dimension.

Furthermore, the proofs are constructive (showing a solution exists) rather than prescriptive (showing how to find it via training). In practice, standard gradient descent might struggle to find the specific, high-magnitude weight configurations required for the "near-one-hot" softmax behavior described in the proofs. Deep, multi-head models likely remain more parameter-efficient and easier to optimize than the single-layer theoretical ideal.

Conclusion

This research demonstrates that the core engine of a Transformer's intelligence resides within the attention block's ability to perform piecewise-linear approximation. By proving that a single head is a universal approximator, the authors provide a new geometric lens through which to view attention: not just as a weighting mechanism, but as a powerful tool for partitioning and mapping complex input spaces.

Summary updated

BibTeX
@inproceedings{liu2025attention,
  author = {Hude Liu and Jerry Yao-Chieh Hu and Zhao Song and Han Liu},
  title = {{Attention Mechanism, Max-Affine Partition, and Universal Approximation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=NTjr79xpX0},
}
Figure