arXiv:2504.09663cs.LGecon.EM2025-04

普通最小二乘法可看作一种受限注意力机制,打通了统计学与Transformer的桥梁。

Ordinary Least Squares as an Attention Mechanism

  • 将OLS重写为基于相似性的注意力模块,用嵌入空间内积替代系数估计
  • 在变换后的特征空间中,通过优化编码解码实现最小化预测误差
  • 适合有统计背景但想理解注意力机制的学者,也启发时序计量经济学新视角

本文表明,普通最小二乘法(OLS)的预测结果可重写为一种受限注意力模块的输出,类似大型语言模型的核心结构。这一联系提供了一种超越传统信息检索框架的注意力新视角,使具有经典统计背景的研究者更易理解。当将OLS视为在变换后的回归变量空间中的相似性方法时,其本质发生转变:不再直接估计系数,而是通过优化训练与测试向量的比较嵌入空间,以最小化平方预测误差。本质上,这是学习最优的编码与解码操作。从这一视角看,OLS自然映射到注意力机制的查询-键-值结构。在此基础上,本文探讨了Transformer式注意力的关键要素,并与经典时间序列计量经济学思想建立关联。

原文摘要 · Abstract (English)

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.

最小二乘注意力机制统计学习Transformer

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。