Abstract
Transformers demonstrate exceptional performance on high-dimensional data, yet the theoretical basis for their ability to circumvent the "curse of dimensionality" has remained elusive. This paper establishes a theoretical framework for sequence-to-sequence Transformers with infinite-dimensional inputs. We prove that Transformers act as dynamic feature selectors, achieving convergence rates independent of input dimensionality by exploiting anisotropic and piecewise smoothness in target functions.
Introduction
In classical statistical learning theory, the "curse of dimensionality" posits that the amount of data required to learn a function grows exponentially with the number of input features. Despite this, Transformers excel in domains like computer vision and natural language processing where dimensionality is vast—processing entire books or high-resolution images with ease. While previous research explored how fully connected or convolutional networks handle high dimensions, the theoretical "secret sauce" of Transformers in sequence-to-sequence (seq2seq) tasks with infinite-dimensional inputs remained murky.
Methodology
The authors employ rigorous mathematical analysis to evaluate the approximation (representational capacity) and estimation (learning efficiency) of Transformers. They analyze a variant incorporating sliding window attention, sinusoidal positional encoding, and parameter sharing across layers.
Key to their approach are two assumptions about the target functions:
- Anisotropic Smoothness: The function is "smoother" in some directions than others, meaning only a few features in a sequence actually matter for the output.
- Piecewise Smoothness: A novel function class where the "important" features can change depending on the input. For example, in one image, pixels representing a zebra's head are vital; in another, the tail might be the key feature.
Dynamic Feature Extraction
A central finding is that the self-attention mechanism functions as a dynamic feature selector. Unlike a fixed filter in a CNN, the Transformer can "decide" which parts of an infinite sequence are important on the fly.
This mechanism allows the model to "memorize" extracted features across layers using positional encodings, preventing redundant computations and enabling the approximation of complex, shift-equivariant functions. This explains why Transformers can recognize patterns regardless of where they appear in a sequence.
Key Results
- Beating the Curse: The paper proves that Transformers achieve a near-optimal convergence rate of approximately $n^{-\frac{2a^\dagger}{2a^\dagger+1}}$ (where $a^\dagger$ represents function smoothness). Crucially, this rate is independent of the input dimension.
- Shift-Equivariance: The authors successfully derived approximation errors for functions where shifting the input sequence results in a corresponding shift in the output, matching the behavior of real-world models like BERT or GPT.
- Sparsity Validation: Numerical experiments using ImageNet-1k and a pre-trained ViT-Base showed that masking up to 90% of an image’s patches still allows for correct classification, provided the "important" patches are kept, supporting the theoretical piecewise smoothness model.
Limitations and Future Work
While providing a robust foundation, the analysis focuses on fixed sinusoidal encodings and sliding window attention. Future work may extend these proofs to learnable positional embeddings and global attention mechanisms. Additionally, the gap between the theoretical existence of an optimal Empirical Risk Minimization (ERM) estimator and the practical challenges of non-convex optimization in training remains an open challenge.
Summary updated