Ordinary Least Squares is a Special Case of Transformer
Authors: Xiaojun Tan, Yuchen Zhao
Organizations: Center for Peak Performance, Department of Psychology and Behavioral Sciences, Zhejiang University · Hangzhou Higgs Asset Management Co., Ltd. · College of Control Science and Engineering, Zhejiang University
The statistical essence of the Transformer architecture has long remained elusive: Is it a universal approximator, or a neural network version of known computational algorithms? Through rigorous algebraic proof, we show that the latter better describes Transformer's basic nature: Ordinary Least Squares (OLS) is a special case of the single-layer Linear Transformer. Using the spectral decomposition of the empirical covariance matrix, we construct a specific parameter setting where the attention mechanism's forward pass becomes mathematically equivalent to the OLS closed-form projection. This means attention can solve the problem in one forward pass, not by iterating. Building upon this prototypical case, we further uncover a decoupled slow and fast memory mechanism within Transformers. Finally, the evolution from our established linear prototype to standard Transformers is discussed. This progression facilitates the transition of the Hopfield energy function from linear to exponential memory capacity, thereby establishing a clear continuity between modern deep architectures and classical statistical inference.
Figures & tables
Figure 1: Empirical validation of training reachability for the OLS-Transformer. (a) Functional Convergence : The synchronized evolution of training MSE (left axis) and relative distance to the OLS benchmark (right axis), with rapid alignment occurring within the initial 1000 epochs. (b) Structural Emergence : The trajectory of the learnable parameter L precisely recovering the theoretical optimum L∗=(n1XTX)−1/2 , which is temporally synchronized with the functional convergence of the output.