acceptodds
Under review as a conference paper at ICLR 2027

Attention Head Specialization: Phase Transitions in Sample Complexity

Abstract

Attention heads specialize into distinct functions during training, often emerging in stages together with sharp changes in model behavior. While this phenomenon has mostly been studied as a function of training time, we ask how head specialization depends on the amount of available training data. Empirically, we find that heads specialized to syntactic relations in BERT emerge as the dataset size increases. We then study this phenomenon in a solvable high-dimensional model of multi-head attention and establish that, in this model, head specialization is a genuine phase transition in sample complexity, corresponding to a non-analyticity in the test error and other observables. Depending on data structure and regularization, specialization can follow uninformative head differentiation or occur through a cascade of phase transitions that progressively recover weaker latent features, providing a statistical form of simplicity bias. Finally, we relate these statistical transitions to the stagewise emergence of specialized heads during online learning, disentangling statistical from dynamical origins of head specialization.

Primary area:
learning theory
Keywords:
statistical physics of learning, high-dimensional statistics, high-dimensional limit, attention heads, sparse information retrieval, phase transitions, head specialization

Reviews

Among:
Shape:
1234this paper, Top 4%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 3.25 over 4 reviews, above 96% of the others.
Reviewer_5FqnOpenReview ↗
Rating
3
Confidence
4
Informativeness
2
Presentation
3
Soundness
3
Read review
Paper summary

The paper study the phenomenon of head specialization, when different heads specialize to learn different functions during training. This phenomenon has been mostly studied as a function of training time but not as a function of the number of samples in the training set.

The authors try to address this gap. In particular, they first perform an experiment on BERT small trained via masked language modelling. In this experiment, they show how the attention heads specialize to syntactic relations as the size of the training set increases. In particular, they measure the unlabel attachment score (UAS), a metric quantifying the alignment between attention and semantic structure, and show that this observable undergoes a phase transition. They then propose an high-dimensional data model to explain this phenomenology, which is analytically tractable with tools from statistical physics.

In the model, tokens are generated iid from a Gaussian distribution with zero mean and unitary variance, except for a special token, containing a planted spike in the mean. The spike is generated as a linear combination of latent features. The authors then use replica theory to obtained closed-form expression for the generalization error and the training error, as a function of training set versus the embedding dimension.

In particular, they distinguish the case where one of the latent features is kept constant and the other ones are allowed to flip the sign randomly in the sequence with the case where the features are drawn iid from a Gaussian distribution with different covariances. In the first case, depending on the regularization strength, the authors identify the emergence of three different phases: permutation symmetry (PS), where all heads behave in the same way; permutation-symmetry-broken (PSB), where all heads behave differently but they still do not align with the latent feature directions; specialized (SPEC), where each head specialize to one of the latent feature direction. For regularization strengths above the critical value, the model shows a second order phase transition from the PS to the SPEC phases as a function of the size of the training set. For regulation strengths below the critical value, the model exhibits the intermediate PSB phase, a phenomenology closer to what it has already observed in committee machines. This phase transition is qualitatively similar to the one observed in the BERT experiment. In the case of inhomogeneous features, the model shows a fourth phase (r-SPEC), where the heads specialize to the first r strongest features, generating a cascade of phase transitions.

Finally, the authors compare the equilibrium result with previous results on the same data model in the online learning regime.

Critical strengths

The paper addresses an important research question, going in the direction of better understanding what large language models learn from data.

The main strength of the paper is Result 2.1, where the authors derive a set of self-consistent equations whose solutions leads to a closed-form expression for the generalization and training error of a multi-headed attention layer in the high-dimensional limit, where the size of the training set scales proportionally with the input dimension.

The second strength of the paper is that, thanks to these equations, the authors can identify several learning phases and relate them to the generalization performance of multi-headed attention. In particular, they manage to identify and distinguish between the PS, PSB, SPEC and r-SPEC phases and how the model changes behavior between these phases, depending on the size of the training set; they also discuss the connection between this equilibrium analysis with simplicity bias observed in training time and perform the experiment on BERT small trained on masked language modelling, where they show the emergence of a syntactic phase transition when increasing the size of the training set.

Critical weaknesses

I think that the main weakness is the limited connection between the theoretical model and the syntactic specialization in language models. The task is a multi-feature variant of single-location regression, where attention heads are required to identify a special token, containing a planted signal, in a sequence of tokens. However, in the data model, tokens are sampled iid from a Gaussian distribution with an identity covariance matrix in the embedding space. Because of that, the model cannot capture the correlations or the syntactic structure which is precisely the structure that BERT is trying to learn when trained via masked language modelling. Despite the qualitatively similar behavior, it is then hard to conclude that the syntactic transition observed in the BERT experiment in Figure 1 is of the same nature of the specialization transition observed in the synthetic data model and emerging from the theoretical analysis. In particular, there is no a clear connection between UAS and the head-feature overlap m. These two quantities are in principle measuring two different aspects of head specialization and I would therefore appreciate if the authors can better clarify this point.

A related weakness concerns the r-SPEC phase. While the phenomenon of the cascade of phase transition based on the strength of the latent features is mathematically interesting, it is not clear to me whether this phenomenon occurs when also training language models on real language data or whether this is a particular feature of the synthetic data model considered in this work. I would thus appreciate if the authors can better discuss if this phenomenology is expected to occur in realistic learning settings.

In conclusion, I find the theoretical analysis very interesting but I think that the connection with the syntactic transition in language models should be downplayed because it seems more speculative at this point rather than a true connection. Because of that, I am rating the paper with a weak acceptance.

Questions for authors

In the main, the authors write that the theoretical analysis can be equivalently performed for generic convex regularizer and activation function, beyond the softmax. Where is it possible to see it? Because the calculation in the appendix seems restricted to softmax and L2 regularizer.

In the paper, the authors perform the analysis in a mismatched setting, where the number of heads (H) is not necessarily equal to the number of features (F). Is it possible to understand what happens in the regimes: H smaller than F, H equal to F and H larger than F?

I think there are some citations missing: In the section of related works, in the paragraph related to the theory of attention, I think one should add the works:

  • Towards a theory of how the structure of language is acquired by deep neural networks, F Cagnetta, M Wyart, Advances in Neural Information Processing Systems 37, 83119-83163
  • Mapping of attention mechanisms to a generalized Potts model, R Rende, F Gerace, A Laio, S Goldt, Physical Review Research 6 (2), 023057 At the beginning of page 5, when mentioning the extensive width limit, the authors should add the work:
  • Statistical Physics of Deep Learning: Optimal Learning of a Multilayer Perceptron near Interpolation, J Barbier, F Camilli, MT Nguyen, M Pastore, R Skerk, Physical Review X 16 (3), 031014
2 comments

We thank the reviewer for the positive evaluation of our work and for the feedback, which helped improve the manuscript. The suggestions are implemented in the updated version.

W

About token correlations: please see point 1 of our common rebuttal. About the r-SPEC phase: please point 2 of our common rebuttal. About the connection between UAS and the head-feature overlap: this is an important point. The head-feature overlap mm measures alignment of an attention head vector with planted latent directions in embedding space. UAS plays an analogous role: assuming that syntax is the relevant latent structure for masked language modeling, it provides a proxy for alignment between learned attention and this structure. First, the underlying structures differ, since syntax involves both token and embedding structure (see point 1 of our summary rebuttal). Then, UAS measures alignment with the syntactic structure through a more complicated function than an overlap (counting correctly attended syntactic pairs across heads and layers). Notably, it involves selecting a best performing head across the dataset and therefore requires specialization to syntactic relations, but does not measure meaningful differentiation between heads.

Q1

The free entropy and saddle point equations of Appendix A.1 are derived for a generic loss ℓ\ell and estimator y^\hat y. We do not make use of any particular property of ℓ\ell and y^\hat y, encompassing any non-pathological activation function. As to the regularizer, we admit that the equations are written for L2 regularization; yet deriving them for generic regularizer is standard (see Duranthon et al. 2026 for example) and would mainly require to substitute ∣∣K∣∣F2||K||_F^2 by the appropriate regularizer in the equations. We corrected this point in the revised version.

O. Duranthon, P. Marion, C. Boyer, B. Loureiro, and L. Zdeborová. Statistical advantage of softmax attention: Insights from single-location regression. ICLR, 2026

Q2

In the non-isotropic Gaussian model (the flipping spike model is less generic for this question), two heads are needed to recover each additional spike. In the underparameterized regime H<2FH<2F, heads recover the ⌊H/2⌋\lfloor H/2 \rfloor strongest features. In the matching case H=2FH=2F, FF pairs of heads recover each feature. In the overparameterized regime H>2FH>2F, once all spikes have been recovered, H−2FH- 2F heads are redundant and still have zero alignment with all features. As the number of samples increases, we also observe these heads differentiating from all others without specialization.

Q3

We thank the reviewer for the suggested citations. We added them in the updated manuscript.

Thank you for the clarification. My concerns have been addressed.

Reviewer_m4T3OpenReview ↗
Rating
4
Confidence
3
Informativeness
2
Presentation
3
Soundness
3
Read review
Paper summary

The paper provides a feature-learning analysis of multi-head attention, analyzing how multi-head attention learns in spiked data models and, specifically, at what sample complexity different heads specialize in learning specific features of the data. Their results include phase transitions beyond which the heads specialize in different features. The authors numerically validate these results in synthetic experiments and observe qualitatively similar behavior in BERT.

Critical strengths
  1. The core question that the paper studies is highly relevant and builds on the current literature by analyzing feature learning and multi-head specialization as a function of sample complexity. The spiked model they consider is interesting and, from the analysis, seems to capture how a multi-head model learns, showing that with enough data the multiple heads can specialize in different features of the data.

  2. The reported theoretical results agree closely with the synthetic experiments across several settings. The BERT experiments provide additional motivation, and the paper clearly states important limitations of the theoretical analysis.

Critical weaknesses
  1. While this is a great improvement on the current literature, I personally think that the more important model should include richer dependencies between tokens, rather than concentrating the informative structure in only one token. This does not mean that the conclusions are not valuable, but I mostly think that this model should be generalized in some way to include additional, more complex feature structure that can describe the complexity of token interactions in language models.
Questions for authors
  1. Could the authors explain what they mean by “As the latent ϵ\epsilon and θ\theta are sampled at every sequence/context, deducing them can also be seen as a simple case of in-context learning”? In particular, what is learned during training, and what is inferred from each new context?

  2. Looking at the attention model you consider, it uses a fixed, sequence-independent query rather than the usual input-dependent query–key interaction. could the authors explain this model choice more clearly and discuss how it affects the conclusions about head specialization?

  3. Could the authors provide more intuition for why increasing the number of samples leads to specialization? In particular, what prevents the heads from learning the additional features below the critical sample complexity, and what changes when this threshold is crossed?

  4. Just for readability purposes, the authors should link the main contributions to the corresponding results through explicit references.

1 comment

We thank the reviewer for the positive evaluation of our work and for the feedback, which helps improve the manuscript. The suggestions are implemented in the updated version.

W1

We agree with this remark. Please see point 1 of our summary rebuttal.

Q1

During training the features kf∗k_f^* remain fixed and are learned by the attention heads. For each new context the weights θ\theta and the structured-token index ϵ\epsilon are resampled; the structured token’s mean k^\hat{k} and the relevant position ϵ\epsilon must therefore be inferred from context.

Q2

Our model is motivated by cross-attention or regression tasks, where the position of the output token is encoded in a fixed sequence-independent manner. More precisely, we assume that in the sequence there is an additional fixed query embedding Xquery∈RDX_\mathrm{query}\in\mathbb R^D that determines the position where to output the relevant token. Then, attention between XqueryX_\mathrm{query} and X∈RL×DX\in\mathbb R^{L\times D} with the usual quadratic query–key interaction gives Xquery⊤WqWk⊤X⊤X_\mathrm{query}^\top W_qW_k^\top X^\top We absorb the part Xquery⊤WqWk⊤X_\mathrm{query}^\top W_qW_k^\top, that does not depend on XX, into a single effective vector of weights khk_h per head. This leads to attention scores linear in the input sequence k⊤X⊤k^\top X^\top.

As to the effect on head specialization, we expect a model with sequence-depend query-key to lead to a similar phenomenology with sharp transitions between unspecialized and specialized phases, in the spirit of multi-indices models (see e.g. Cui 2024 for a model with quadratic attention).

H. Cui, F. Behrens, F. Krzakala, and L. Zdeborová. A phase transition between positional and semantic learning in a solvable model of dot-product attention. NeurIPS, 2024

Q3

Please see point 3 of our summary rebuttal.

Q4

We thank the reviewer for this suggestion. We have added references to the main contributions in the updated manuscript.

Reviewer_rtUiOpenReview ↗
Rating
3
Confidence
1
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

The paper provides a deep analysis of head specialization in multi-head attention in the limit of infinite data and infinite parameters. They do experiments on BERT. They predict the thresholds for specialization, successive feature recovery, and provide a connection to training dynamics in the limit.

Critical strengths

The spike model is pretty interesting. There is actually a differentiation between a meaningful notion of feature specialization and just the differentiation between heads. There is a tight coupling between the theoretical results and the synthetic experiments. The feature-recovery cascade offers a compelling statistical account of simplicity bias.

Critical weaknesses

The theoretical characterization relies on us believing that there is a transition point but while the BERT results are suggestive but do not isolate statistical transitions from optimization and early-stopping effects. The dynamics correspondence requires restrictive limits.

Questions for authors

Why is specialization fundamentally a function of training samples? Does this mean it is impossible for data-efficient learning to result in head specialization? Ex if we epoched 10000 times on a dataset of 100 math problems?

1 comment

We thank the reviewer for the positive evaluation of our work and for the feedback, which helps improve the manuscript. The suggestions are implemented in the updated version.

W The theoretical characterization relies on us believing that there is a transition point but while the BERT results are suggestive but do not isolate statistical transitions from optimization and early-stopping effects.

In Figure 9 of the old manuscript, Figure 11 of the updated manuscript, we follow the training dynamics for BERT_Small at large training times, and observe that specialization remains. After the specialization the UAS plateaus and early-stopping does not impact it. In Figure 12 of the updated manuscript, we observe that specialization is robust to changes in the optimization dynamics, with emergence and plateau in UAS present for varying learning rates.

W The dynamics correspondence requires restrictive limits.

Our correspondance to the dynamical transition requires large regularization indeed. Yet, as shown by Figure 10 of the correspondance, a regularization λ=3\lambda=3 is enough to have a good match, and the ERM train and test losses are already close (~1% of relative difference, not shown). The limit of large λ\lambda allows to have a clean and exact correspondance; smaller values can still be approached thanks to our theory and should be thought as a perturbation of the limiting case.

Q Why is specialization fundamentally a function of training samples?

Please see point 3 of our summary rebuttal.

Q Does this mean it is impossible for data-efficient learning to result in head specialization? Ex if we epoched 10000 times on a dataset of 100 math problems?

In Appendix A.3 of the updated manuscript, we added a characterization of the Bayes-optimal (BO) estimator: for our task and data model, it is the optimal (and therefore most data efficient) estimator. The attention model we study requires more samples than the BO estimator to exploit head specialization. Better models could approach the thresholds of BO, with more data efficient learning still possibly resulting in head specialization. Yet, below a critical sample complexity, the BO solution is unspecialized; it cannot distinguish the different relevant directions of the data; and data-efficient learning cannot result in head specialization.

Reviewer_tyUpOpenReview ↗
Rating
3
Confidence
2
Informativeness
2
Presentation
3
Soundness
3
Read review
Paper summary

In this paper the authors investigate how specialization of attention heads emerge with the amount of data. They motivate this question by noting that in small BERT models, head alignment to specific syntactic features of the data show a sudden jump as a function of dataset size, while the training loss suddenly drops. To study this sudden emergence of head specialization they characterize the asymptotic behavior of a minimal multi-head attention model trained to minimize empirical risk in a spike detection task. This analysis revealed a phase transition where heads moved from a shared to a specialized regime, and demonstrated a cascade effect where stronger latents were learned first. Finally, they connect the amount of data to training dynamics by showing that, in both perspectives, attention head specialization is governed by the same loss curve.

Critical strengths

Strong Points:

The technical part of the paper is carefully derived and closely validated by simulations and does reveal rich regimes of model behavior given different amounts of data Overall, I think the attempt to connect solutions at different dataset sizes to phenomena often attributed to training dynamics is very worthwhile. This comes across most clearly in the results on cascading feature specialization and in the explicit linking of training dynamics and dataset statistics in section 4.

Critical weaknesses

Weak Points: I found the connection to BERT to be weak overall. In general, the syntactic relations that emerge in specialized BERT heads are much more complicated functions of the data than the toy problem where analytic results are derived. In connection to the first point, the theory’s predictions for larger models remain qualitative and/or untested. The most distinctive predictions, such as a cascade in which different relations emerge at different dataset sizes, or a phase where heads differentiate without specializing, are either not observed (Fig. 10 shows the main relations emerging at the same N) or not examined.

Questions for authors

I find the theoretical contribution of the paper and the overall goal compelling enough to accept. However, I believe the paper would be SIGNIFICANTLY strengthened if the authors could demonstrate more convincingly that this model is sufficiently similar or predictive of large models or realistic tasks that are of broader interest to the community.

Therefore, my main question for improving the paper would be to demonstrate such a connection. Are there other larger models that show phase shifts in attention head specialization which do genuinely cascade? Can you make empirical predictions about model behavior from your model and test those predictions in simulation?

Minor Points: lambda_tric appears in Sec. 3 and Fig. 3 without being defined. Typos: Line 072: “without recovering distinct latent feature” should be “distinct latent features.” Line 350: “The two heads differs” should be “differ.” Line 360: “supported trough agreement with simulations” should be “through.”

1 comment

We thank the reviewer for the positive evaluation of our work and for the feedback, which helped improve the manuscript. The suggestions are implemented in the updated version.

W I found the connection to BERT to be weak overall. In general, the syntactic relations that emerge in specialized BERT heads are much more complicated functions of the data than the toy problem where analytic results are derived.

Please see point 1 of our summary rebuttal.

W the theory’s predictions for larger models remain qualitative and/or untested. The most distinctive predictions, such as a cascade in which different relations emerge at different dataset sizes, or a phase where heads differentiate without specializing, are either not observed (Fig. 10 shows the main relations emerging at the same N) or not examined.

Please see point 2 of our summary rebuttal. Yes, in the case of Syntactic Attention Structure we examined individual relations as a check, and indeed found a single specialization threshold (both in training time and in the number of samples). Our interpretation is that these relations rely on strongly correlated attention structure and are acquired as one capability. Observing separated thresholds would require identifying distinct attention structures or capabilities. In the case of SAS, the introduction of a syntactic regularizer and control of relations prevalence in the data in Chen et al.; 2024a (leading to shifts in the overall threshold) could provide an initial basis for such tests. We hope that the further predictions of our model will inspire future work, requiring new ideas of how to probe such phenomenology in practice.

Q Are there other larger models that show phase shifts in attention head specialization which do genuinely cascade? Can you make empirical predictions about model behavior from your model and test those predictions in simulation?

Please see point 2 of our summary rebuttal. This is a really good suggestion worth detailed investigation that we hope will be undertaken in future work.

Minor points and typos: We thank the reviewer for the careful reading. We have addressed these points in the updated manuscript.

A. Chen, R. Shwartz-Ziv, K. Cho, M. Leavitt, and N. Saphra. Sudden drops in the loss: Syntax acquisition, phase transitions, and simplicity bias in MLMs. ICLR 2024a

Comments on the paper

2 comments
AuthorsOpenReview ↗

Common rebuttal

We thank all reviewers for their detailed and constructive feedback. Below, we address three of the common concerns raised by the reviewers. The other points are addressed in specific answers to the reviewers. We warmly welcome any further question.

Token correlations: As noted by reviewers tyUp and 5Fqn, syntactic relations in BERT involve a richer attention structure than our solvable model, notably correlations between tokens. In the Single Location Regression model, we isolate the effects of attention-matrix structure from the need for multiple heads, with the aim of identifying a minimal statistical mechanism for head specialization. Motivated by Marion et al. (2025), this model already captures two features relevant to language processing: sparsity of informative tokens and linear structure in learned representations. As suggested by reviewer m4T3, a natural next step would be to study the effects of richer attention structure, such as correlations between tokens, on head specialization. This would be feasible within our theoretical framework, through the introduction of multiple correlated structured tokens in the sampled sequences.

We therefore view the toy problem as the simplest setting that isolates the head specialization phenomenon, leading to a prediction of specialization being a phase transition in sample complexity. We then confirm that this prediction is consistent with the behavior of BERT in experiments. The key goal of the model is not to capture every detail of a real setting, but to isolate the key ingredients allowing us to understand specialization in sufficient detail and make predictions that then transfer to practice. In this sense, the model succeeded.

Head specialization in larger models: Reviewers tyUp and 5Fqn ask whether the specialization phases identified in our model, particularly the cascade of transitions, also occur in larger language models.

In larger models, stagewise head differentiation to different roles for next token prediction accompanied by drops in the loss have been reported in Olsson et al. (2022) and Hoogland et al. (2025).

A central obstacle in obtaining theoretical predictions for larger models is identifying the ground truth structure to which attention heads should specialize. In the case of syntactic attention structure (SAS), the known importance of syntax for language tasks is what makes BERT experiments particularly relevant. Another example for a controlled setting is given by sparse attention patterns (Yüksel et al.; 2026), in which heads specializing to increasingly longer context lengths and successive drops in the loss are observed as a function of training time. In Appendix E3 of the updated manuscript, our additional experiment establish that specialization cascade in this setting also occurs as the number of training samples increases. This tests the successive specialization phase-transitions and simplicity-bias predictions with correlated tokens and autoregressive loss.

To our knowledge, a learning phase analog to the PSB phase has not been identified in large language model experiments. Its diagnosis is difficult without knowledge of the ground-truth features. By stating its theoretical existence, we stress the fact that head differentiation need not imply meaningful specialization.

Specialization with increasing samples: Reviewers rtUi and m4T3 ask for intuition on why increasing the number of samples leads to specialization.

We identify specialization as an equilibrium phase transition: an abrupt change in the properties of minima of the regularized empirical loss in the high-dimensional limit. Just as phase transition in physics, the origin of such an abrupt change defies intuition. Indeed, the nature of phase transitions, such as water freezing or evaporating, was a subject of intense debate in 20th-century physics. The discovery that nothing needs to change microscopically in order to see an abrupt change macroscopically in the limit of large system size gave rise to a myriad of other related non-intuitive phenomena. In physics, temperature is a level of noise controlling the appearance of a phase transition; in machine learning, fewer samples imply larger statistical noise and uncertainty. Put together with the large-dimensional limit, this brings the neural network to a situation analogous to the one in physics, and the appearance of a phase transition is then natural.

AuthorsOpenReview ↗

Common rebuttal

Updated manuscript: We upload an updated version of manuscript containing the changes mentioned in rebuttal:

  • corrected typos pointed by the reviewers
  • references in main contributions
  • citations suggested by reviewers
  • characterization of the Bayes-optimal in appendix A.3
  • experiments on sparse attention patterns (Yuksel et al.; 2026) in appendix E.3
  • experiments on training BERT_Small with varying learning rates in appendix E.2

References:

  • P. Marion, R. Berthier, G. Biau, and C. Boyer. Attention layers provably solve single-location regression. ICLR 2025
  • O. K. Yüksel, R. A. Lucendo, and N. Flammarion. Incremental learning of sparse attention patterns in transformers. arXiv:2602.19143
  • C. Olsson, N. Elhage, N. Nanda, N. Joseph, N. DasSarma, T. Henighan, B. Mann, A. Askell, Y. Bai, A. Chen, et al. In-context learning and induction heads. arXiv:2209.11895
  • J. Hoogland, G. Wang, M. Farrugia-Roberts, L. Carroll, S. Wei, and D. Murfet. Loss landscape degeneracy and stagewise development in transformers. TMLR
  • Oguz Kaan Yuksel, Rodrigo Alvarez Lucendo, and Nicolas Flammarion. Incremental learning of sparse attention patterns in transformers. arXiv preprint arXiv:2602.19143, 2026

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.