[Paper Review] Transformers Trained via Gradient Descent Can Provably Learn a Class of Teacher Models
The paper shows that one-layer transformers with a simplified position-only attention can provably learn a broad class of teacher models by gradient descent, achieving convergence to the teacher’s parameters and good out-of-distribution generalization, with matching upper and lower bounds.
Transformers have achieved great success across a wide range of applications, yet the theoretical foundations underlying their success remain largely unexplored. To demystify the strong capacities of transformers applied to versatile scenarios and tasks, we theoretically investigate utilizing transformers as students to learn from a class of teacher models. Specifically, the teacher models covered in our analysis include convolution layers with average pooling, graph convolution layers, and various classic statistical learning models, including a variant of sparse token selection models [Sanford et al., 2023, Wang et al., 2024] and group-sparse linear predictors [Zhang et al., 2025]. When learning from this class of teacher models, we prove that one-layer transformers with simplified "position-only'' attention can successfully recover all parameter blocks of the teacher models, thus achieving the optimal population loss. Building upon the efficient mimicry of trained transformers towards teacher models, we further demonstrate that they can generalize well to a broad class of out-of-distribution data under mild assumptions. The key in our analysis is to identify a fundamental bilinear structure shared by various learning tasks, which enables us to establish unified learning guarantees for these tasks when treating them as teachers for transformers.
Motivation & Objective
- Motivate understanding of transformers via theoretical guarantees when learning from a class of teacher models.
- Define a unified bilinear-structure framework that covers CNNs, GCNs, sparse token selection, and group-sparse predictors as teacher models.
- Establish convergence and generalization guarantees for a one-layer transformer trained by gradient descent in this setting.
- Demonstrate through synthetic and real-data experiments that the theory aligns with observed training dynamics and attention patterns.
Proposed method
- Define teacher models of the form f* (X) = sigma(V* X S*) with bilinear structure and various instantiations (CNN, GCN, STS, GSLP).
- Adopt a simplified one-layer transformer with position-only self-attention: TF(Z; WV; WKQ) = sigma(WV X S) where S is learned attention scores.
- Train via gradient descent on population loss with zero initialization for WV and WKQ and Gaussian input X, deriving iterative updates (3.3)-(3.4).
- Theoretically analyze convergence to ground-truth components (V*, S*) and provide tight bounds on excess loss and parameter convergence (Theorem 3.1).
- Extend to out-of-distribution (OOD) generalization bounds under mild moment assumptions (Theorem 3.2).
- Validate with synthetic and real-data experiments, including CNN, GCN, STS, and GSLP tasks, and MNIST-based setup.
Experimental results
Research questions
- RQ1Can a one-layer transformer trained with gradient descent recover all parameter blocks of a broad class of teacher models with bilinear structure?
- RQ2What are the convergence rates for the learned attention scores and value matrices, and how does excess loss scale with iterations?
- RQ3Do learned transformers generalize to out-of-distribution data beyond the training distribution?
- RQ4How do the theoretical results manifest across CNN, GCN, sparse token selection, and group-sparse predictor teacher models?
- RQ5Do empirical experiments reflect the predicted parameter and loss dynamics and attention patterns?
Key findings
- Gradient descent training of a one-layer transformer can recover the teacher’s value matrix V* and softmax scores S* with precise convergence guarantees.
- Attention scores converge to the ground-truth S* at rate ||S(T)−S*||F = Theta(D^{5/2} / (||V*|| sqrt(eta T))).
- Value matrix converges to the ground-truth V* at rate ||WV^(T)−V*||F = Theta(D^2 sqrt(K/(eta T))).
- Excess loss L(WV^(T); WKQ^(T)) − L_opt is bounded both above and below by Theta(K D^4 /(eta T)).
- The framework covers diverse teacher models including CNNs with average pooling, GCNs on regular graphs, sparse token selection, and group-sparse linear predictors, and confirms the theory with synthetic experiments showing convergent loss and aligned attention patterns.
- The OOD generalization bound shows the trained transformer’s OOD loss is within epsilon of the teacher’s OOD loss under bounded second moments, establishing robust generalization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.