Attention-based PCA
Rodrigo Maulen-Soto, Claire Boyer
NeurIPS 2026
TL;DR. Rank-one attention trained on Gaussian data performs PCA: it learns the top eigenvector of the covariance. This holds in infinite and finite prompts (up to noise) and extends to an in-context spiked setting, recovering the signal direction.
Abstract. We study attention mechanisms through the lens of a canonical unsupervised problem: principal component analysis (PCA). We show that, when trained on Gaussian data, both softmax and linear attention layers learn parameters that align with the principal eigenvectors of the covariance matrix, thereby establishing a direct and explicit connection with PCA.
Our analysis covers both finite and infinite prompt regimes. In the infinite-prompt limit, we prove convergence to globally optimal solutions aligned with the leading spectral direction, while in the finite-prompt setting we show that the same behavior emerges up to sampling effects. We further extend the analysis to an in-context setting with spiked Wishart covariances, where attention successfully recovers the underlying signal direction.
These results demonstrate that attention inherently performs PCA-like computations under unsupervised objectives, providing a theoretical foundation for its representation-learning capabilities.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (spotlight) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:43 UTC.
- Decision
- Accept (spotlight)
Read decision
Meta-review
The paper investigates the attention mechanism in an unsupervised learning setting through the lens of Principal Component Analysis (PCA). With a rank-one attention setting and a Gaussian data assumption, the paper demonstrates the relation between attention and PCA. It also establishes a formal connection between attention mechanisms and classical spectral methods like Oja's flow. These theoretical connections are promising for providing more insights into the attention mechanism. The paper could be limited by the strong assumptions, notably the Gaussian assumption and rank-one update, leaving a gap between the analyses and practical choices. It will be helpful if the authors point out how the current analyses could be extended to better connect to practical models. See the review comments for details.
Final justification
The rebuttal has addressed most concerns, and the reviewers have leaned toward accepting the work.
Read meta-review
Meta-review
The paper investigates the attention mechanism in an unsupervised learning setting through the lens of Principal Component Analysis (PCA). With a rank-one attention setting and a Gaussian data assumption, the paper demonstrates the relation between attention and PCA. It also establishes a formal connection between attention mechanisms and classical spectral methods like Oja's flow. These theoretical connections are promising for providing more insights into the attention mechanism. The paper could be limited by the strong assumptions, notably the Gaussian assumption and rank-one update, leaving a gap between the analyses and practical choices. It will be helpful if the authors point out how the current analyses could be extended to better connect to practical models. See the review comments for details.
Final justification
The rebuttal has addressed most concerns, and the reviewers have leaned toward accepting the work.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 2/4
- Contribution type
- theory
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper studies the ability of a softmax self-attention module to perform PCA on independent Gaussian tokens. In the infinite-prompt limit, the authors leverage the fact that softmax self-attention converges to a linear operator on tokens. The authors prove in the infinite-prompt setting that gradient flow converges to global minimizers which recover the top eigenvector of the data covariance matrix up to sign; they also show in this setting that, at global minimizers, the self-attention operator projects tokens onto the top eigenvector of the data covariance matrix. In the finite-prompt setting, the authors recover the same results up to finite sampling error.
Strengths and weaknesses
Strengths:
- The mathematical theory of transformers is a central topic in learning theory, and results for unsupervised learning tasks such as PCA are heavily underdeveloped compared to those on regression/classification.
- The paper is very well-written. It is easy to understand the central contributions of the paper and the broader context in which they exist.
- The paper seems to require some nontrivial mathematical results, particularly the concentration results for softmax attention, due to correlations between the context and query.
Weaknesses:
- The main weakness is that the core results of the paper hold for Gaussian tokens generated from a static covariance matrix. That a softmax attention module can succeed at this task is not very surprising since, as the authors prove, the attention weights learn the top eigenvector of a specific covariance ,instead of encoding a generic rule to perform PCA. While I appreciate the authors acknowledging this limitation with the spiked covariance model in Section 4, these results are analogous to the static case since the attention weights learn the unit vector that defines the scale matrix in the Wishart distribution. Thus, I think the paper still leaves many questions open about the mechanistic abilities of transformers performing PCA.
Questions
-
Does the linearity of softmax in the infinite prompt limit extend to multi-layer models? My initial guess is, since linear maps preserve Gaussianity, that compositions of softmax attention on Gaussian data are also linear in the infinite prompt setting. However, this seems counterintuitive, as it suggests that deep softmax models are not much more expressive than shallow ones.
-
Have you considered studying linear attention models, which may have valid infinite prompt limits for non-Gaussian data?
-
If you instead parameterize as a rank matrix with do you expect the optimal attention parameters to be a projection onto the top eigenvectors of ?
Limitations
Yes
Final justification
The author response led me to raise my score. The current work is an impressive study of the representation learning capabilities of softmax attention for a tractable unsupervised learning task. Extensions to in-context learning and algorithmic learning constitute important directions for future work, but I no longer feel that a lack of such results undermines the paper's contribution. I also appreciate the additional experiments by the authors and their thoughtful responses to my questions.
Formatting concerns
None
3 comments
I thank the authors for their thorough response to my review. I agree with the authors that studying in-context or algorithmic learning is probably beyond the scope of the paper, and the current results on representation learning capabilities of attention are a precise fit for ICLR. I found the responses to my questions to be enlightening and I am encouraged by the additional experimental results. I will raise my score and recommend acceptance.
Thank you for your positive feedback and for updating your evaluation!
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- theory
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper studies attention training dynamics on i.i.d. Gaussian data with covariance . The main result is that if we constrain our attention matrices to be rank one then the result will approximate the rank one matrix made by the top eigenvector of .
The paper deals with the softmax attention dynamics by a reduction to a linear linear operator in the infinite context limit, this is done from recent developments of analyzing attention dynamics. Specifically for the loss objective defined in the paper uses the exact expression and its gradient can be written as an expression of the covariance matrix and the current weights. The Landscape of the loss have the eigenvectors as discrete critical points, the top eigenvector is a global minimizer and the rest are strict saddles. This proves that the gradient flow dynamics will converge to the top eigenvector almost surely. Interestingly the paper also provides a convergences rate through proving the a Lojasiewicz inequality. After proving the result for the infinite context limit by concentration arguments the paper extends this result to sufficiently large finite context.
The theorems are supported by numerical simulated experiments and the paper also provides full analysis of the linear attention dynamics. Interestingly the dynamics of linear attention for this distribution of context are similar to Oja’s flow which is a continuous method for finding the top eigenvector of a covariance matrix.
Strengths and weaknesses
Strengths:
- Significance: The paper provides a novel simplified insightful setting where the attention dynamics are theoretically tractable approach an interesting solution.
- Quality: The work provides numerical experiments and a solid presentation of the theorems.
- Clarity: The paper is well-written and the comparison with Oja's flow adds to the clarity of the paper.
- Originality: The paper is technically novel.
Weaknesses:
- The analysis is for a extremely simplified setting along with the choice of rank 1 attention.
- The reduction to a linear operator main workhorse for the analysis was done in previous work which also computed the operator for a Gaussian.
- The statement: "These results demonstrate that attention inherently performs PCA-like computations under unsupervised objectives, providing a theoretical foundation for its representation-learning capabilities." is debatable in this simplified setting there is no signal other than the covariance and rank one weights.
Questions
- If you have the attention matrix be of general rank what is the result at least empirically? Does it approximate the best rank approximation of or not?
- What are the theoretical challenges to extend the analysis to this case?
I currently believe that the work is worthy of acceptance. My score will likely remain unchanged unless technical flaws will be discovered at the reviewing process.
Limitations
yes
Final justification
The simplified model seems enlightening and the paper seems to perform a complete study of it.
In my view there are a lot of works studying the representational power of the transformers, showing that they can implement a task efficiently, however the majority of those works do not actually show a learnability result that softmax attention will converge to the task even in simplified settings.
This work provides a complete proof about the learnability result as well.
I recommend acceptance.
The paper was already in very good shape before the rebuttal, as reflected in the limited number of reviewer concerns. The authors also provided clear and convincing responses to all of the reviewers’ questions.
Formatting concerns
No major formatting, anonymity, or other submission-policy concerns noted.
2 comments
Rebuttal
We thank the reviewer for this remark and fully agree that the considered model is intentionally simplified.
Our objective is not to model the full complexity of modern Transformer architectures, but rather to identify the simplest attention mechanism for which a complete mathematical analysis can be carried out. The rank-one setting enables us to derive a complete characterization of the optimization landscape, establish convergence of gradient flow to the global minimizers, quantify finite-prompt effects, and explicitly connect the learned solution to the leading principal component. We view this work in the same spirit as classical theoretical studies of PCA, matrix factorization, and online learning, where simplified models are first analyzed rigorously before progressively incorporating additional architectural features.
Importantly, the mathematical framework developed here naturally suggests higher-rank extensions through matrix-valued attention parameterizations, which we believe constitute one of the most promising directions for future work.
We agree that the infinite-prompt linearization for Gaussian measures builds upon previous work.
However, this linearization should be viewed as the starting point rather than the main contribution of the present paper. While the infinite-prompt analysis provides the analytical representation of the attention operator, our work develops the optimization theory built upon this representation. In particular, the characterization of the optimization landscape, convergence of gradient flow, finite-prompt transfer guarantees, distributional characterization of the learned parameters, and the connection with PCA and generalized Oja dynamics are, to the best of our knowledge, all new contributions.
We will make this distinction clearer in the revised manuscript.
We agree that our original wording may have been stronger than warranted.
Our theoretical results establish that the rank-one attention mechanism studied in this paper recovers the leading principal component under the considered unsupervised Gaussian objective. They do not imply that arbitrary attention architectures universally perform PCA. To avoid overgeneralization, we will soften the corresponding statement in the revised version of the manuscript.
We believe this is one of the most interesting extensions of the present work.
Replacing the rank-one parameterization by a matrix factorization , where , naturally leads to a higher-rank attention mechanism. In the Gaussian infinite-prompt regime, the attention operator remains linear, suggesting that the corresponding population objective depends on the positive semidefinite matrix . Because this matrix is invariant under left multiplication of by an orthogonal matrix, the optimization naturally identifies a principal -dimensional subspace.
To investigate this setting, we performed additional numerical experiments using the higher-rank parameterization together with a simple regularization encouraging the rows of to become orthogonal, namely where and denote rows of . Across a large collection of randomly generated Gaussian covariance matrices, the optimization consistently recovered solutions whose normalized rows were strongly aligned with the first principal eigenvectors of the covariance matrix, up to permutation and sign. These experiments therefore provide strong empirical evidence that the higher-rank attention model successfully recovers the leading principal eigenspace while empirically selecting one representative basis.
From a theoretical perspective, however, extending our analysis to this setting is considerably more challenging. The parameter space becomes matrix-valued, the objective exhibits rotational symmetries leading to non-isolated minimizers and flat directions, and the finite-prompt concentration analysis must be generalized to matrix-valued derivatives. Consequently, characterizing the complete optimization landscape appears substantially more difficult than in the rank-one case.
An intriguing open question is whether the optimization dynamics possess an implicit bias that selects a canonical basis among all equivalent parameterizations of the same subspace. Our preliminary experiments suggest that the proposed regularization induces such a bias, leading empirically to vectors aligned with the principal eigenvectors. Establishing this phenomenon theoretically remains an interesting direction for future work.
I thank the authors for the detailed responses. The simplified model seems enlightening and the paper seems to perform a complete study of it.
I am in favor of softening the wording: "These results demonstrate that attention inherently performs PCA-like computations under unsupervised objectives, providing a theoretical foundation for its representation-learning capabilities."
In my view there are a lot of works studying the representational power of the transformers, showing that they can implement a task efficiently, however the majority of those works do not actually show a learnability result that softmax attention will converge to the task even in simplified settings.
This work provides a complete proof about the learnability result as well.
I recommend acceptance.
- Rating
- 5/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 4/4
- Contribution type
- theory
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper investigates the attention mechanism in an unsupervised learning setting, more specifically, through the lens of Principal Component Analysis (PCA). By limiting the attention mechanism to be a rank-one attention and containing the input data to be Gaussian, the work shows that this simple rank-one attention mechanism performs the PCA, which recovers the leading eigenvectors of the data covariance matrix. For both softmax and linear attention, rigorous analysis shows that a rank-one attention layer converges to global minimizers aligned with principal components in infinite-prompt limits, and characterizes further its finite-prompt behavior via concentration arguments and landscape analysis. Interestingly, the proposed framework is also extended to spiked Wishart covariance models for in-context learning, and establishes a formal connection between attention mechanisms and classical spectral methods like Oja's flow.
Strengths and weaknesses
The key strength of the paper lies in its rigorous theoretical derivation that explicitly connects attention mechanisms to PCA through a classic residual minimization framework. It provides the seem-to-be first formal characterization of how unsupervised attention layers recover principal components. This analysis is particularly insightful and comprehensive, as it spans both infinite and finite prompt regimes. Furthermore, it also includes detailed analysis of convergence rates and landscape characterizations. Finally, the proposed interpretation is extended to in-context learning settings with spiked covariance models, and establishes a solid mathematical foundation for understanding attention's representation-learning capabilities.
The main weakness of the work is its reliance on highly simplified attention architectures, including rank-one parameters. The presented analysis assumes idealized conditions, particularly Gaussian input data, while the attention mechanism is mostly effective on sequential (natural language) or semantical inputs (natural image or video). Thus, one biggest open question is how well can the results presented in this paper be generalized to real-world attention environments.
Questions
-
The rank-one assumption of the simple attention mechanism seems to be limited. Can the derivation/analysis be extended to multiple dimensional case, just like principal subspace analysis? Can the authors either discuss or articulate further connections to PCA/PSA?
-
As noticed, the analysis of the work relies on the assumption that the input data is Gaussian. However conventionally, the attention mechanism is effective on sequential or semantical inputs. Is the analysis presented in the paper applicable for non-Gaussian input? Even weaker, is there any concrete observation that indicates the connections between rank-one attention layer and PCA being still valid for non-Gaussian input?
-
Common practice of attention mechanism adopt significantly the structure of the multi-head, high-dimensional attention mechanisms in practice. How can the current analysis be applied to multi-head, high-dimensional attention mechanisms? Can you elaborate this potential a bit?
Limitations
Yes.
Final justification
Based on the detailed rebuttal from the authors, I keep my rating as Accept.
Formatting concerns
No clear violation of formatting.
2 comments
Rebuttal
We sincerely thank the reviewer for the positive assessment of our work and for these insightful questions. They point toward several natural extensions of our analysis, and we will expand the discussion accordingly in the revised manuscript.
We deliberately restricted our analysis to the recovery of a single principal component, corresponding to a rank-one attention parameterization, because this is the simplest setting in which the optimization landscape can be characterized completely. A natural next step is to extend the framework to principal subspace analysis.
From a theoretical perspective, replacing the rank-one parameterization by the matrix factorization , where , naturally yields a higher-rank attention mechanism. In the Gaussian infinite-prompt regime, the attention operator remains linear, suggesting that the corresponding population objective depends on the positive semidefinite matrix . Since is invariant under left multiplication of by an orthogonal matrix, the optimization naturally identifies a -dimensional subspace rather than a unique basis.
Motivated by this observation, we performed additional numerical experiments using this higher-rank parameterization. More precisely, we optimized the population reconstruction objective with respect to while introducing a simple regularization term encouraging the rows of to become orthogonal, namely where and denote rows of . Across a wide range of randomly generated Gaussian covariance matrices and several values of , the optimization consistently converged to solutions whose rows were strongly aligned with the first principal eigenvectors of the covariance matrix, up to permutation and sign. The regularization prevented the different rows from collapsing onto the dominant eigendirection and empirically selected one representative of the principal eigenspace.
These experiments provide strong empirical evidence that the PCA connection established in the rank-one setting naturally extends to higher-rank attention parameterizations. We will include these additional experiments in the revised manuscript.
From a theoretical standpoint, however, this higher-rank setting introduces several new mathematical challenges. The parameter space becomes matrix-valued, the objective possesses rotational symmetries leading to non-isolated minimizers and flat directions, and the finite-prompt concentration analysis must be extended to matrix-valued derivatives. Characterizing the complete optimization landscape therefore appears substantially more difficult than in the rank-one case and remains an interesting direction for future work.
We agree that the Gaussian assumption is an important limitation of the present work. It is primarily introduced because it yields an exact characterization of the infinite-prompt attention operator. In particular, the measure-based formulation implies that, for Gaussian inputs, the nonlinear softmax attention converges exactly to the linear operator $ T^\mu_\infty(x)=\lambda\Sigma\mu\mu^\top x,$ which makes the optimization problem analytically tractable. This exact linearization is the key ingredient allowing us to characterize all critical points and prove convergence toward the leading eigenvector.
We conjecture that the PCA behavior identified in this work corresponds to the universal first-order approximation of attention, while higher-order corrections appear for more general input distributions. Consequently, we expect the leading eigenspace to remain the dominant solution whenever these higher-order corrections remain sufficiently small.
Empirically, preliminary experiments (not included in the current submission) indicate that the learned direction remains strongly aligned with the first principal component for several non-Gaussian distributions, including sub-Gaussian and Gaussian-mixture data. These observations suggest that the phenomenon is considerably more robust than the current theory predicts. Extending the analysis beyond the Gaussian setting is one of the directions we find most promising for future work.
Our objective in this paper was deliberately to isolate the elementary optimization mechanism underlying attention. A single rank-one attention layer represents the minimal setting for which a complete mathematical analysis can currently be carried out.
Nevertheless, we believe that our analysis provides useful insight into higher-dimensional attention mechanisms. In particular, the higher-rank formulation discussed above naturally leads to principal subspace learning through the matrix parameterization . Moreover, the connection established in Section~2.4 with generalized Oja dynamics is particularly suggestive, since Oja's rule admits well-known matrix-valued extensions for principal subspace analysis. We therefore expect analogous matrix-valued Oja flows to arise from higher-rank attention.
Accordingly, we will expand the discussion in the revised manuscript to better explain how the present rank-one analysis should be viewed as the first step toward a mathematical theory of higher-rank attention mechanisms.
The authors addressed all my three questions properly. A revised version with these extended discussions should be sufficient for the acceptance at ICLR.
Hence I keep my rating as Accept.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
Weaknesses. We thank the reviewer for this thoughtful comment.
Our objective is indeed not to show that a Transformer learns a universal algorithm for PCA from data. Rather, our goal is to understand, in the simplest mathematically tractable setting, the optimization objective implicitly solved by a single attention layer when trained under an unsupervised reconstruction loss.
From this perspective, our main contribution is to establish that the optimization dynamics of rank-one attention are intrinsically connected to spectral methods: the global minimizers coincide with the leading eigendirection, the gradient flow converges to these minimizers, and, in the infinite-prompt regime, the dynamics reduce to a generalized version of Oja's flow. To the best of our knowledge, this provides the first explicit optimization-theoretic connection between softmax attention and PCA.
We fully agree that this does not yet explain how deep Transformers could implement a generic PCA algorithm capable of adapting to arbitrary covariance matrices. In fact, we view this distinction as an important conceptual point: the present work studies representation learning, whereas algorithmic in-context PCA would require the attention parameters to infer the covariance from each prompt and adapt online. This is a substantially different problem and constitutes an exciting direction for future work.
Regarding the spiked Wishart model, we also agree that the learned parameter ultimately aligns with the latent direction defining the covariance distribution. Our intention in Section~4 was therefore not to claim a fundamentally different mechanism, but rather to demonstrate that our analysis extends beyond a single deterministic covariance matrix to a distribution over covariance matrices. Moreover, this framework removes the distinct-eigenvalues assumption required in the deterministic setting. We will clarify this motivation more explicitly in the revised manuscript.
Q1. This is an excellent observation.
Indeed, under the assumptions of our paper, the answer is essentially yes. Since the infinite-prompt attention operator is linear on Gaussian measures, its output remains Gaussian. Consequently, the next attention layer again operates on Gaussian inputs and therefore also reduces to a linear operator. By induction, a stack of infinite-prompt attention layers without additional nonlinearities (without MLPs) remains globally linear.
Rather than being paradoxical, we believe this highlights the specificity of the Gaussian setting. The expressive power of deep Transformers arises not only from attention itself, but also from finite-prompt effects, feed-forward nonlinearities, normalization layers, residual connections, positional encodings, and, more fundamentally, from the fact that real data are not Gaussian. Once these ingredients are incorporated, the overall architecture is no longer expected to remain linear.
We will add a discussion of this point in the revised manuscript, as it illustrates both the strength and the limitations of the Gaussian infinite-prompt approximation.
Q2. Yes. In fact, we analyze a simplified linear attention model in the appendix as a warm-up before studying softmax attention.
More generally, we believe linear attention provides an attractive framework for extending the analysis beyond Gaussian distributions. Unlike softmax attention, whose infinite-prompt limit depends on the moment-generating function of the data, linear attention depends only on first- and second-order moments, making it considerably less tied to Gaussianity. This suggests that analogous PCA-type results may hold under substantially weaker assumptions.
While such a setting departs from current attention-based architectures, it offers a mathematically appealing framework for extending the analysis beyond the Gaussian regime and toward more general data distributions.
Q3. Yes, this is our current expectation, and it is supported by new numerical experiments.
Replacing the rank-one parameterization μμ⊤ by a matrix factorization Q⊤Q, where Q∈Rk×d, naturally leads to a higher-rank attention mechanism. In the Gaussian infinite-prompt regime, the attention operator remains linear, suggesting that the corresponding population objective depends on the positive semidefinite matrix Q⊤Q. Since Q⊤Q is invariant under left multiplication of Q by an orthogonal matrix, the optimization is naturally expected to recover the principal k-dimensional eigenspace of the covariance matrix.
To investigate this setting, we performed additional numerical experiments using this higher-rank parameterization together with a simple regularization encouraging the rows of Q to become orthogonal, namely ∑i<j⟨qi,qj⟩2 where qi and qj denote rows of Q. Across numerous randomly generated Gaussian covariance matrices, the optimization consistently converged to solutions whose normalized rows were strongly aligned with the first k principal eigenvectors of the covariance matrix, up to permutation and sign. These experiments therefore provide strong empirical evidence that the higher-rank formulation successfully recovers the leading principal eigenspace while empirically selecting one representative basis.
From a theoretical perspective, however, this extension introduces several new mathematical challenges. The parameter space becomes matrix-valued, the objective exhibits rotational symmetries leading to non-isolated minimizers and flat directions, and the finite-prompt concentration analysis must be generalized to matrix-valued derivatives. Characterizing the complete optimization landscape therefore appears substantially more difficult than in the rank-one case and remains an interesting direction for future work.
We thank the reviewer for these insightful questions. We believe they identify precisely the next theoretical challenges beyond the present work, and we will revise the manuscript to better distinguish the representation-learning setting studied here from the broader question of whether deep Transformers can implement a generic PCA algorithm.