mlsanityData to 14 Oct 2026

In-Context Linear Regression Demystified: Training Dynamics and Mechanistic Interpretability of Multi-Head Softmax Attention

arXiv 2503.12734 ↗First posted 17 Mar 2025cs.LG stat.MLcited by 7

On the map: Mechanistic interpretability → Circuits and mechanistic analysis

Abstract (arXiv)

We study how multi-head softmax attention models are trained to perform in-context learning on linear data. Through extensive empirical experiments and rigorous theoretical analysis, we demystify the emergence of elegant attention patterns: a diagonal and homogeneous pattern in the key-query (KQ) weights, and a last-entry-only and zero-sum pattern in the output-value (OV) weights. Remarkably, these patterns consistently appear from gradient-based training starting from random initialization. Our analysis reveals that such emergent structures enable multi-head attention to approximately implement a debiased gradient descent predictor -- one that outperforms single-head attention and nearly achieves Bayesian optimality up to proportional factor. Furthermore, compared to linear transformers, the softmax attention readily generalizes to sequences longer than those seen during training. We also extend our study to scenarios with anisotropic covariates and multi-task linear regression. In the former, multi-head attention learns to implement a form of pre-conditioned gradient descent. In the latter, we uncover an intriguing regime where the interplay between head number and task number triggers a superposition phenomenon that efficiently resolves multi-task in-context learning. Our results reveal that in-context learning ability emerges from the trained transformer as an aggregated effect of its architecture and the underlying data distribution, paving the way for deeper understanding and broader applications of in-context learning.

Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Placed in Circuits and mechanistic analysis, one of 13 directions in Mechanistic interpretability. First posted on arXiv 17 Mar 2025.

Builds on

0 of 0 references.

No references here yet.

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 3; 2026: 4.

7 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024Understanding the differences in Foundation Models: Attention, State Space Models, and Recurrent Neural Networks
  2. 2024Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond
  3. 2026State Rank Dynamics in Linear Attention LLMs
  4. 2026Induction Heads Interpolate N-Grams
  5. 2026Underscoring the Problem: Why Softpick Fails at Initialization
  6. 2026Switching Linear Attention
  7. 2024From Attention to Activation: Unravelling the Enigmas of Large Language Models
  8. 2025Localizing Task Recognition and Task Learning in In-Context Learning via Attention Head Analysis