Training Dynamics of In-Context Learning in Linear Attention

Yedi Zhang, Aaditya K. Singh, Peter E. Latham, Andrew Saxe
1/27/2025
cs.LG

No official code found. Best implementation: yedizhang/linattn-icl (4 stars, last commit 2026-04-05).

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.

View on arXivView PDF

Code Implementations(1)

[ICML 2025 Spotlight] Training Dynamics of In-Context Learning in Linear Attention.

43Python, Jupyter NotebookOct 11, 20246 months ago

Similar Papers

Cite this paper

@article{zhang2025training,
  title  = {Training Dynamics of In-Context Learning in Linear Attention},
  author = {Yedi Zhang and Aaditya K. Singh and Peter E. Latham and Andrew Saxe},
  year   = {2025},
  eprint = {2501.16265},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2501.16265v2},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2501.16265.svg)](https://codeofpaper.com/paper/2501.16265)

Discussion