Transformers are Expressive, But Are They Expressive Enough for Regression?
Swaroop Nath, Harshad Khadilkar, Pushpak Bhattacharyya
TL;DR
The paper investigates whether Transformers are universal function approximators, challenging prevailing claims by showing they struggle to approximate smooth functions and instead rely on piecewise-constant representations with small δ. It combines a theoretical bound—demonstrating that achieving good approximation forces a resolution factor δ that drives the layer count to $O(m(1/\delta)^{dm})$—with extensive synthetic experiments on both regression of smooth functions and classification of piecewise-constant targets. The experimental results with the full Transformer corroborate the theory for the encoder, showing limited ability to approximate smooth functions, while achieving relatively better performance on coarse piecewise-constant tasks. The work highlights fundamental expressivity limits of standard Transformer architectures and motivates architectural changes to attain universal function approximation in practice.
Abstract
Transformers have become pivotal in Natural Language Processing, demonstrating remarkable success in applications like Machine Translation and Summarization. Given their widespread adoption, several works have attempted to analyze the expressivity of Transformers. Expressivity of a neural network is the class of functions it can approximate. A neural network is fully expressive if it can act as a universal function approximator. We attempt to analyze the same for Transformers. Contrary to existing claims, our findings reveal that Transformers struggle to reliably approximate smooth functions, relying on piecewise constant approximations with sizable intervals. The central question emerges as: ''Are Transformers truly Universal Function Approximators?'' To address this, we conduct a thorough investigation, providing theoretical insights and supporting evidence through experiments. Theoretically, we prove that Transformer Encoders cannot approximate smooth functions. Experimentally, we complement our theory and show that the full Transformer architecture cannot approximate smooth functions. By shedding light on these challenges, we advocate a refined understanding of Transformers' capabilities. Code Link: https://github.com/swaroop-nath/transformer-expressivity.
