NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The Initialization Determines Whether In-Context Learning Is Gradient Descent

Shifeng Xie, Rui Yuan, Simone Rossi, Thomas Hannagan

Abstract

In-context learning (ICL) in large language models (LLMs) has been frequently theorized as a form of implicit gradient descent (GD). While this equivalence holds under simplified conditions—such as zero-mean Gaussian priors and zero initialization—it often breaks down in more realistic, biased data environments. This paper investigates the mechanisms of multi-head linear self-attention (LSA) in linear regression tasks with non-zero Gaussian priors. We demonstrate that standard LSA fails to match GD performance due to an "initialization bottleneck." We propose $y_q$-LSA, a modification incorporating a trainable "initial guess" ($y_q$), which theoretically and empirically bridges the gap between ICL and GD. Furthermore, we show that providing an initial guess improves the performance of real-world LLMs on semantic similarity tasks.

Introduction

The ability of Transformers to perform in-context learning—adapting to new tasks via few-shot prompting—remains a central mystery of deep learning. A prominent hypothesis suggests that the self-attention mechanism performs a forward-pass optimization akin to Gradient Descent (GD). However, recent critiques highlight that this equivalence relies on restrictive assumptions, such as zero-mean data distributions. In the presence of bias (non-zero priors), standard linear self-attention (LSA) exhibits a persistent performance gap compared to one-step GD. This study explores why this gap exists and how a simple architectural tweak can resolve it.

The Initialization Bottleneck

The core reason standard attention fails to emulate GD in biased settings is not a lack of processing capacity, but a lack of a proper starting point. In GD, the optimization begins from an initial weight vector; in standard LSA, the implicit starting point for a query's prediction is effectively zero.

Impact of prior mean norm on loss.

As shown in Figure 2, the performance gap between standard LSA and GD grows linearly with the square of the prior mean's norm ($\|w_\star\|^2$). This suggests that as the task becomes more biased (i.e., the ground truth weights deviate further from zero), the model's inability to "guess" a non-zero starting point becomes increasingly detrimental.

Multi-Head Saturation

A natural question is whether increasing the number of attention heads can overcome this bottleneck. We provide a theoretical upper bound, proving that for a $d$-dimensional linear regression problem, the expressivity of multi-head LSA saturates at $d+1$ heads.

Saturation of performance with increasing attention heads.

Empirical results in Figure 4 confirm this saturation. Even with a large number of heads, the model's loss plateaus at a level significantly higher than the GD baseline. This confirms that "wider" models cannot compensate for a fundamentally misaligned initialization in biased environments.

Proposed Solution: $y_q$-LSA

To address this, we introduce $y_q$-LSA, a minimal generalization of single-head LSA. We add a trainable parameter $w$ that provides an initial guess ($y_q = w^\top x_q$) for the query. This $y_q$ acts as the starting point for the implicit optimization process.

Mathematically, this allows the model to account for the non-zero prior mean of the task. In synthetic linear regression tests, $y_q$-LSA perfectly matches the performance of one-step GD, effectively closing the gap that multi-head LSA could not bridge.

Generalization to Large Language Models

To test if this "hunch" hypothesis applies to complex natural language tasks, we evaluated Meta-LLaMA-3.1-8B and Qwen-2.5-7B on the STS-Benchmark (Semantic Textual Similarity). We provided these models with an initial similarity score (a "guess") generated by a smaller, separate model.

Both LLMs showed consistent improvements in Mean Squared Error (MSE) when provided with this initial guess. This suggests that ICL in modern LLMs can be viewed as an iterative refinement process that benefits significantly from a well-aligned prior belief or starting point.

Conclusion

Our findings clarify the relationship between ICL and GD, demonstrating that initialization is the deciding factor in their equivalence. By incorporating a trainable initial guess, we can align self-attention more closely with optimization-based inference. Future work will explore how these principles apply to non-linear attention mechanisms and how models might internally generate their own reliable initial guesses.

Summary updated

BibTeX
@article{xie2025initialization,
  author = {Shifeng Xie and Rui Yuan and Simone Rossi and Thomas Hannagan},
  title = {{The Initialization Determines Whether In-Context Learning Is Gradient Descent}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=fvqSKLDtJi},
}
Figure