@inproceedings{
zhang2023trained,
title={Trained Transformers Learn Linear Models In-Context},
author={Ruiqi Zhang and Spencer Frei and Peter Bartlett},
booktitle={R0-FoMo:Robustness of Few-shot and Zero-shot Learning in Large Foundation Models},
year={2023},
url={https://openreview.net/forum?id=MpDSo3Rglq}
}
Attention-based neural network sequence models such as transformers have the capacity to act as supervised learning algorithms: They can take as input a sequence of labeled examples and output predictions for unlabeled test examples.  Indeed, recent work by Garg et al. has shown that when training GPT2 architectures over random instances of linear regression problems, these models' predictions mimic those of ordinary least squares.  Towards understanding the mechanisms underlying this phenomenon, we investigate the dynamics of in-context learning of linear predictors for a transformer with a single linear self-attention layer trained by gradient flow.  We show that despite the non-convexity of the underlying optimization problem, gradient flow with a random initialization finds a global minimum of the objective function.  Moreover, when given a prompt of labeled examples from a new linear prediction task, the trained transformer achieves small prediction error on unlabeled test examples.  We further characterize the behavior of the trained transformer under distribution shifts.
Trained Transformers Learn Linear Models In-Context
Ruiqi Zhang Spencer Frei Peter Bartlett