mlsanityData to 7 Oct 2026

Transformers Don't In-Context Learn Least Squares Regression

arXiv 2507.09440 ↗First posted 13 Jul 2025cs.LG cs.AIcited by 2

Not on the map. Why?

Abstract (arXiv)

In-context learning (ICL) has emerged as a powerful capability of large pretrained transformers, enabling them to solve new tasks implicit in example input-output pairs without any gradient updates. Despite its practical success, the mechanisms underlying ICL remain largely mysterious. In this work we study synthetic linear regression to probe how transformers implement learning at inference time. Previous works have demonstrated that transformers match the performance of learning rules such as Ordinary Least Squares (OLS) regression or gradient descent and have suggested ICL is facilitated in transformers through the learned implementation of one of these techniques. In this work, we demonstrate through a suite of out-of-distribution generalization experiments that transformers trained for ICL fail to generalize after shifts in the prompt distribution, a behaviour that is inconsistent with the notion of transformers implementing algorithms such as OLS. Finally, we highlight the role of the pretraining corpus in shaping ICL behaviour through a spectral analysis of the learned representations in the residual stream. Inputs from the same distribution as the training data produce representations with a unique spectral signature: inputs from this distribution tend to have the same top two singular vectors. This spectral signature is not shared by out-of-distribution inputs, and a metric characterizing the presence of this signature is highly correlated with low loss.

Key facts. Cited by 2 papers in the map (data through 7 Oct 2026). Builds on 12 of its 20 references that are in the map. First posted on arXiv 13 Jul 2025.

Builds on

12 of 20 references.

References · 12

  1. 2017Attention Is All You Needcited by 59,932
  2. 2020Language Models are Few-Shot Learnerscited by 32,199
  3. 2022In-context Learning and Induction Headscited by 930
  4. 2022Transformers learn in-context by gradient descentcited by 714
  5. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  6. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  7. 2023Embers of Autoregression: Understanding Large Language Models Through the Problem They are Trained to Solvecited by 175
  8. 2019Predictive Multiplicity in Classificationcited by 162
  9. 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 138
  10. 2023Understanding Catastrophic Forgetting in Language Models via Implicit Inferencecited by 138
  11. 2019More Data Can Hurt for Linear Regression: Sample-wise Double Descentcited by 37
  12. 2024Bayesian scaling laws for in-context learningcited by 18

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 2.

2 papers.