Understanding Generalization in Transformers: Error Bounds and Training Dynamics Under Benign and Harmful Overfitting
Yingying Zhang, Zhenyu Wu, Jian Li, Yong Liu
TL;DR
This work tackles how transformers generalize under benign and harmful overfitting when trained with labeled flip noise. It develops a generalization theory for a two-layer transformer, separating training dynamics into three stages for each regime and providing stage-specific error bounds under varying SNR. The authors also present a comprehensive experimental study that confirms the theoretical predictions, reveals a phase transition boundary governed by data size and signal-to-noise ratio, and analyzes factors such as learning rate and V-matrix initialization. The results extend benign overfitting theory from linear and CNN settings to transformers, relax certain assumptions, and offer practical insights into training dynamics and generalization in over-parameterized transformer models.
Abstract
Transformers serve as the foundational architecture for many successful large-scale models, demonstrating the ability to overfit the training data while maintaining strong generalization on unseen data, a phenomenon known as benign overfitting. However, research on how the training dynamics influence error bounds within the context of benign overfitting has been limited. This paper addresses this gap by developing a generalization theory for a two-layer transformer with labeled flip noise. Specifically, we present generalization error bounds for both benign and harmful overfitting under varying signal-to-noise ratios (SNR), where the training dynamics are categorized into three distinct stages, each with its corresponding error bounds. Additionally, we conduct extensive experiments to identify key factors that influence test errors in transformers. Our experimental results align closely with the theoretical predictions, validating our findings.
