Training Dynamics of In-Context Learning in Linear Attention
Yedi Zhang, Aaditya K. Singh, Peter E. Latham, Andrew Saxe
TL;DR
The paper investigates how gradient-descent training induces in-context learning (ICL) in linear attention architectures, contrasting a merged key-query parametrization with a separate key-query parametrization. It reveals two distinct dynamical regimes: ATTN_M features two fixed points and a single abrupt loss drop, while ATTN_S exhibits exponentially many fixed points and a cascade of saddle-to-saddle transitions, with ICL materializing as principal component regression in context when early-stopped. A key contribution is the mapping of ATTN_M to a two-layer linear network with a cubic feature map, and the interpretation of ATTN_S as a sum of three-layer convolutional linear networks, enabling precise analysis of fixed points, plateaus, and convergence behavior. The results show that parametrization critically shapes the evolution of ICL during training and provide a theoretical foothold for understanding how ICL abilities evolve in practice, including potential extensions to softmax attention and more complex data regimes.
Abstract
While attention-based models have demonstrated the remarkable ability of in-context learning (ICL), the theoretical understanding of how these models acquired this ability through gradient descent training is still preliminary. Towards answering this question, we study the gradient descent dynamics of multi-head linear self-attention trained for in-context linear regression. We examine two parametrizations of linear self-attention: one with the key and query weights merged as a single matrix (common in theoretical studies), and one with separate key and query matrices (closer to practical settings). For the merged parametrization, we show that the training dynamics has two fixed points and the loss trajectory exhibits a single, abrupt drop. We derive an analytical time-course solution for a certain class of datasets and initialization. For the separate parametrization, we show that the training dynamics has exponentially many fixed points and the loss exhibits saddle-to-saddle dynamics, which we reduce to scalar ordinary differential equations. During training, the model implements principal component regression in context with the number of principal components increasing over training time. Overall, we provide a theoretical description of how ICL abilities evolve during gradient descent training of linear attention, revealing abrupt acquisition or progressive improvements depending on how the key and query are parametrized.
