Universal Approximation with Softmax Attention

Jerry Yao-Chieh Hu, Hude Liu, Hong-Yu Chen, Weimin Wu, Han Liu
4/22/2025
cs.LGcs.AIstat.ML

No official code found. Best implementation: MAGICS-LAB/UAP_Attention (2 stars, last commit 2025-04-26).

Abstract

We prove that with linear transformations, both (i) two-layer self-attention and (ii) one-layer self-attention followed by a softmax function are universal approximators for continuous sequence-to-sequence functions on compact domains. Our main technique is a new interpolation-based method for analyzing attention's internal mechanism. This leads to our key insight: self-attention is able to approximate a generalized version of ReLU to arbitrary precision, and hence subsumes many known universal approximators. Building on these, we show that two-layer multi-head attention alone suffices as a sequence-to-sequence universal approximator. In contrast, prior works rely on feed-forward networks to establish universal approximation in Transformers. Furthermore, we extend our techniques to show that, (softmax-)attention-only layers are capable of approximating various statistical models in-context. We believe these techniques hold independent interest.

View on arXivView PDF

Code Implementations(1)

Universal Approximation with Softmax Attention

21PythonApr 18, 20251 years ago

Similar Papers

Cite this paper

@article{hu2025universal,
  title  = {Universal Approximation with Softmax Attention},
  author = {Jerry Yao-Chieh Hu and Hude Liu and Hong-Yu Chen and Weimin Wu and Han Liu},
  year   = {2025},
  eprint = {2504.15956},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2504.15956v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2504.15956.svg)](https://codeofpaper.com/paper/2504.15956)

Discussion