Introduction
A fundamental question in deep learning is how models generalize from training data to unseen examples. For the Transformer architecture, traditional generalization bounds—which quantify the "generalization gap"—have historically depended on the input sequence length. This dependency is theoretically problematic because the number of trainable parameters in a Transformer is fixed, regardless of whether the input is a short sentence or a long document. This paper addresses this discrepancy by providing the first norm-based generalization bounds for Transformers that are entirely independent of sequence length.
Theoretical Framework
The authors utilize Rademacher complexity to measure the model's capacity to fit random noise, which in turn bounds the generalization gap. The core of their proof relies on a "covering number" approach. By developing three novel covering number bounds for vector-valued linear mappings, the authors demonstrate that the complexity of the Transformer function class does not scale with the number of input tokens.
A key insight is the decoupling of complexity from the number of input tokens. The authors show that the covering number for linear mappings over any set of inputs is equivalent to the covering number on a scaled standard basis. This allows for a bound that is $O(1)$ with respect to sequence length $T$, theoretically validating the Transformer's efficiency in handling long-range dependencies without a corresponding explosion in complexity.
Empirical Validation
To support their theoretical findings, the authors conducted experiments using a "sparse majority" task. In this setup, a model is tasked with predicting a label based on a majority vote of a sparse subset of indices within a sequence of 0s and 1s. For instance, only 9 specific positions might determine the label in a sequence of 200 tokens.
The experiments tested sequence lengths ranging from 20 to 200. The results confirmed two critical points:
- Stable Generalization: The observed generalization gap remained stable as sequence length increased.
- Bounded Weight Norms: The 1-norm of the model's parameters did not show an upward trend with longer sequences, validating the assumption that weight norms remain manageable in practice.
Discussion and Limitations
These findings suggest that Transformers possess an inherent inductive bias toward representing sparse functions, as they do not "pay" a complexity penalty for additional tokens. However, the authors note that the bounds for multi-layer Transformers are more complex and exhibit a higher dependence on the number of attention heads. Future research may focus on sharpening these bounds and exploring a wider variety of norm combinations to further refine our understanding of Transformer generalization.
Summary updated