Ordinary Least Squares as an Attention Mechanism
Not on the map. Why?
Abstract (arXiv)
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. The connection comes from viewing OLS as a similarity-based prediction rule in a learned embedding space. In this representation, least squares does not estimate coefficients per se. Instead, it selects an embedding that minimizes squared prediction error by matching training and test vectors through inner products. This maps directly onto the query-key-value structure of attention mechanisms. I then discuss extensions to dimensionality reduction, nonlinearity, and time series econometrics. Monte Carlo simulations and real-data experiments on UCI/OpenML benchmarks show that nonlinear Attention Regression performs competitively against standard machine learning baselines. In the reverse direction, I replace the attention sublayer of a transformer for tabular data with an explicit regression on polynomial features. The resulting model performs comparably to the standard transformer at a fraction of its parameter count.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 29 of its 56 references that are in the map. First posted on arXiv 13 Apr 2025.
Builds on
29 of 56 references.
References · 29
- 2017Attention Is All You Needcited by 59,932
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,616
- 2014Neural Machine Translation by Jointly Learning to Align and Translatecited by 4,530
- 2013Efficient Estimation of Word Representations in Vector Spacecited by 4,346
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2020Reformer: The Efficient Transformercited by 1,658
- 2020Rethinking Attention with Performerscited by 1,584
- 2017Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV)cited by 1,309
- 2021Revisiting Deep Learning Models for Tabular Datacited by 725
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
17 more
- 2021Random Feature Attentioncited by 350
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
- 2025TabICL: A Tabular Foundation Model for In-Context Learning on Large Datacited by 267
- 2019Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernelcited by 211
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
- 2023Transformers as Support Vector Machinescited by 67
- 2024Large Language Models: An Applied Econometric Frameworkcited by 30
- 2020Global Models for Time Series Forecasting: A Simulation Studycited by 21
- 2020The Macroeconomy as a Random Forestcited by 15
- 2024Attention layers provably solve single-location regressioncited by 15
- 2021Deep Learning Statistical Arbitragecited by 11
- 2023Exploring the Space of Key-Value-Query Models with Intentioncited by 7
- 2020To Bag is to Prunecited by 5
- 2022A Neural Phillips Curve and a Deep Output Gapcited by 5
- 2024Dual Interpretation of Machine Learning Forecastscited by 2
- 2024Maximally Forward-Looking Core Inflationcited by 1
Built on by
Not cited yet.