đ€ AI Summary
A theoretical gap exists between classical statistical modelingâparticularly ordinary least squares (OLS) regressionâand modern attention mechanisms, hindering principled integration and interpretability.
Method: We rigorously reformulate OLS regression as a constrained form of attention, establishing the first exact mathematical equivalence between OLS predictions and attention outputs computed via inner-product similarity. Specifically, we show that OLS is equivalent to a sample-weighted average in embedding space, where weights are determined solely by feature-wise inner products between inputs and queries.
Contribution/Results: (1) We provide statisticians with an interpretable, geometrically intuitive lens for understanding attention; (2) we introduce a paradigm shift from explicit coefficient estimation to learned encodingâdecoding; and (3) we establish the first rigorous theoretical bridge between classical statistical modeling and Transformer architecturesâenabling new interfaces for explainable AI and fostering cross-disciplinary insight.
đ Abstract
I show that ordinary least squares (OLS) predictions can be rewritten as the output of a restricted attention module, akin to those forming the backbone of large language models. This connection offers an alternative perspective on attention beyond the conventional information retrieval framework, making it more accessible to researchers and analysts with a background in traditional statistics. It falls into place when OLS is framed as a similarity-based method in a transformed regressor space, distinct from the standard view based on partial correlations. In fact, the OLS solution can be recast as the outcome of an alternative problem: minimizing squared prediction errors by optimizing the embedding space in which training and test vectors are compared via inner products. Rather than estimating coefficients directly, we equivalently learn optimal encoding and decoding operations for predictors. From this vantage point, OLS maps naturally onto the query-key-value structure of attention mechanisms. Building on this foundation, I discuss key elements of Transformer-style attention and draw connections to classic ideas from time series econometrics.