IDEAS home Printed from https://ideas.repec.org/p/arx/papers/2504.09663.html

Ordinary Least Squares as an Attention Mechanism

Author

Listed:
  • Philippe Goulet Coulombe

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. 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.

Suggested Citation

  • Philippe Goulet Coulombe, 2025. "Ordinary Least Squares as an Attention Mechanism," Papers 2504.09663, arXiv.org, revised Oct 2026.
  • Handle: RePEc:arx:papers:2504.09663
    as

    Download full text from publisher

    File URL: https://arxiv.org/pdf/2504.09663
    File Function: Latest version
    Download Restriction: no
    ---><---

    References listed on IDEAS

    as
    1. Sims, Christopher A, 1980. "Macroeconomics and Reality," Econometrica, Econometric Society, vol. 48(1), pages 1-48, January.
    2. Eric Fischer & Rebecca McCaughrin & Saketh Prazad & Mark Vandergon, 2023. "Fed Transparency and Policy Expectation Errors: A Text Analysis Approach," Staff Reports 1081, Federal Reserve Bank of New York.
    3. Bryan T. Kelly & Boris Kuznetsov & Semyon Malamud & Teng Andrea Xu, 2025. "Artificial Intelligence Asset Pricing Models," Swiss Finance Institute Research Paper Series 25-08, Swiss Finance Institute.
    4. Shihao Gu & Bryan Kelly & Dacheng Xiu, 2020. "Empirical Asset Pricing via Machine Learning," Review of Finance, European Finance Association, vol. 33(5), pages 2223-2273.
    5. Jens Ludwig & Sendhil Mullainathan & Ashesh Rambachan, 2026. "Large Language Models: An Applied Econometric Framework," Annual Review of Economics, Annual Reviews, vol. 18(1), pages 283-316, August.
    6. Harvey,Andrew C., 1991. "Forecasting, Structural Time Series Models and the Kalman Filter," Cambridge Books, Cambridge University Press, number 9780521405737.
    7. Aruoba, Boragan & Drechsel, Thomas, 2022. "Identifying Monetary Policy Shocks: A Natural Language Approach," CEPR Discussion Papers 17133, Centre for Economic Policy Research.
    8. Philippe Goulet Coulombe, 2024. "The macroeconomy as a random forest," Journal of Applied Econometrics, John Wiley & Sons, Ltd., vol. 39(3), pages 401-421, April.
    9. James D. Hamilton, 2018. "Why You Should Never Use the Hodrick-Prescott Filter," The Review of Economics and Statistics, MIT Press, vol. 100(5), pages 831-843, December.
    10. Byeungchun Kwon & Taejin Park & Fernando Perez-Cruz & Phurichai Rungcharoenkitkul, 2024. "Large language models: a primer for economists," BIS Quarterly Review, Bank for International Settlements, December.
    11. Philippe Goulet Coulombe & Maximilian Goebel & Karin Klieber, 2024. "Dual Interpretation of Machine Learning Forecasts," Papers 2412.13076, arXiv.org.
    12. Klieber, Karin & Coulombe, Philippe Goulet, 2025. "Opening the black box of local projections," Working Paper Series 3105, European Central Bank.
    13. Philippe Goulet Coulombe, 2022. "A Neural Phillips Curve and a Deep Output Gap," Working Papers 22-01, Chair in macroeconomics and forecasting, University of Quebec in Montreal's School of Management.
    14. Shihao Gu & Bryan Kelly & Dacheng Xiu, 2020. "Empirical Asset Pricing via Machine Learning," The Review of Financial Studies, Society for Financial Studies, vol. 33(5), pages 2223-2273.
    Full references (including those not matched with items on IDEAS)

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Mehmet Caner & Agostino Capponi & Nathan Sun & Jonathan Y. Tan, 2026. "Designing Agentic AI-Based Screening for Portfolio Investment," Papers 2603.23300, arXiv.org, revised Aug 2026.
    2. Petropoulos, Fotios & Apiletti, Daniele & Assimakopoulos, Vassilios & Babai, Mohamed Zied & Barrow, Devon K. & Ben Taieb, Souhaib & Bergmeir, Christoph & Bessa, Ricardo J. & Bijak, Jakub & Boylan, Joh, 2022. "Forecasting: theory and practice," International Journal of Forecasting, Elsevier, vol. 38(3), pages 705-871.
      • Fotios Petropoulos & Daniele Apiletti & Vassilios Assimakopoulos & Mohamed Zied Babai & Devon K. Barrow & Souhaib Ben Taieb & Christoph Bergmeir & Ricardo J. Bessa & Jakub Bijak & John E. Boylan & Jet, 2020. "Forecasting: theory and practice," Papers 2012.03854, arXiv.org, revised Jan 2022.
    3. Daniel Cunha Oliveira & Yutong Lu & Xi Lin & Mihai Cucuringu & Andre Fujita, 2024. "Causality-Inspired Models for Financial Time Series Forecasting," Papers 2408.09960, arXiv.org.
    4. Hui Chen & Antoine Didisheim & Mohammad & Pourmohammadi & Luciano Somoza & Hanqing Tian, 2025. "A Financial Brain Scan of the LLM," Papers 2508.21285, arXiv.org, revised Feb 2026.
    5. Lu, Yunzhi & Fu, Hang & Cai, Jinghan & Zhou, Kaiguo, 2026. "AI advancement and financial market spillover," Finance Research Letters, Elsevier, vol. 99(C).
    6. Klieber, Karin & Coulombe, Philippe Goulet, 2025. "Opening the black box of local projections," Working Paper Series 3105, European Central Bank.
    7. Goulet Coulombe, Philippe & Klieber, Karin, 2026. "An adaptive moving average for macroeconomic monitoring," Economics Letters, Elsevier, vol. 259(C).
    8. Zhang Chen & Chen Kay, 2026. "Historical Developments in Probability Measures for Asset Pricing: From State Prices to Modern Pricing Kernels," Papers 2605.27658, arXiv.org.
    9. Shanyan Lai, 2025. "Is attention truly all we need? An empirical study of asset pricing in pretrained RNN sparse and global attention models," Papers 2508.19006, arXiv.org, revised Jun 2026.
    10. Philippe Goulet Coulombe & Maximilian Goebel, 2023. "Maximally Machine-Learnable Portfolios," Papers 2306.05568, arXiv.org, revised Apr 2024.
    11. Eghbal Rahimikia & Hao Ni & Weiguan Wang, 2025. "Re(Visiting) Time Series Foundation Models in Finance," Papers 2511.18578, arXiv.org.
    12. Huang, Dashan & Li, Jiangyuan & Wang, Liyao, 2021. "Are disagreements agreeable? Evidence from information aggregation," Journal of Financial Economics, Elsevier, vol. 141(1), pages 83-101.
    13. Philippe Goulet Coulombe & Karin Klieber, 2025. "Opening the Black Box of Local Projections," Papers 2505.12422, arXiv.org, revised Jul 2025.
    14. Abdukakhkhor Abdurakhmonov, 2026. "Macroeconomic Forecasting Using Machine Learning Methods: An Application to Uzbekistan," IHEID Working Papers 19-2026, Economics Section, The Graduate Institute of International Studies.
    15. Zefeng Chen & Darcy Pu, 2026. "Autonomous Market Intelligence: Agentic AI Nowcasting Predicts Stock Returns," Papers 2601.11958, arXiv.org.
    16. Rafael R. S. Guimaraes, 2022. "Deep Learning Macroeconomics," Papers 2201.13380, arXiv.org.
    17. Marcos López de Prado & Joseph Simonian & Francesco A. Fabozzi & Frank J. Fabozzi, 2025. "Enhancing Markowitz's portfolio selection paradigm with machine learning," Annals of Operations Research, Springer, vol. 346(1), pages 319-340, March.
    18. Philippe Goulet Coulombe & Karin Klieber, 2025. "An Adaptive Moving Average for Macroeconomic Monitoring," Papers 2501.13222, arXiv.org.
    19. Daniel Borup & Philippe Goulet Coulombe & Erik Christian Montes Schütte & David E. Rapach & Sander Schwenk-Nebbe, 2022. "The Anatomy of Out-of-Sample Forecasting Accuracy," FRB Atlanta Working Paper 2022-16, Federal Reserve Bank of Atlanta.
    20. Christian Fieberg & Gerrit Liedtke & Thorsten Poddig, 2025. "Recurrent double-conditional factor model," OR Spectrum: Quantitative Approaches in Management, Springer;Gesellschaft für Operations Research e.V., vol. 47(1), pages 205-254, March.

    More about this item

    NEP fields

    This paper has been announced in the following NEP Reports:

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:arx:papers:2504.09663. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: arXiv administrators (email available below). General contact details of provider: https://arxiv.org/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.