arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.18187cs.LGcs.AI
收藏

论 Transformer 前馈层在非线性上下文学习中的作用

On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning

Massachusetts Institute of Technology(麻省理工学院)

Haoyuan Sun, Ali Jadbabaie, Navid Azizan

AI总结:

本文研究了Transformer在非线性函数类上的上下文学习(ICL),证明了纯线性自注意力无法胜任非线性任务,并揭示结合前馈层可实现基于多项式核回归的梯度下降,深度网络通过跨块分布计算克服了单块维度限制,从而提供可扩展的非线性表征机制。

摘要:

基于 Transformer 的模型展现出了卓越的上下文学习(ICL)能力,它们能够在没有参数更新的情况下,通过少量提示示例适应未见过的任务。近期的研究阐明了 Transformer 如何执行 ICL,表明当在随机线性回归任务上进行训练时,最优线性自注意力(LSA)机制能够针对线性最小二乘目标实现一步梯度下降。在此基础上,我们研究了非线性函数类的 ICL。我们首先证明,LSA 在非线性任务上本质上无法超越线性预测器,这强调了为何先前的解决方案无法轻易扩展到这些问题。为了克服这一限制,我们分析了一个由 LSA 和受门控线性单元(GLU)启发的前馈层组成的 Transformer 块,这是现代 Transformer 的标准组件。我们证明,该块通过在多项式核回归损失上实现一步梯度下降来完成非线性 ICL。此外,我们的分析揭示,单个块的表达能力本质上受限于其维度。我们随后表明,深度 Transformer 可以通过将更丰富核函数的计算分布到多个块中,在一个单个块无法表示的高维特征空间中执行块坐标下降,从而克服这一瓶颈。我们的发现强调,前馈层为 Transformer 表达 ICL 的非线性表示提供了一个关键且可扩展的机制。

英文摘要:

Transformer-based models demonstrate a remarkable ability for in-context learning (ICL), where they can adapt to unseen tasks from a few prompt examples without parameter updates. Recent research has illuminated how Transformers perform ICL, showing that the optimal linear self-attention (LSA) mechanism can implement one step of gradient descent for linear least-squares objectives when trained on random linear regression tasks. Building on this, we investigate ICL for nonlinear function classes. We first prove that LSA is inherently incapable of outperforming linear predictors on nonlinear tasks, underscoring why prior solutions cannot readily extend to these problems. To overcome this limitation, we analyze a Transformer block consisting of LSA and feed-forward layers inspired by the gated linear units (GLU), which is a standard component of modern Transformers. We show that this block achieves nonlinear ICL by implementing one step of gradient descent on a polynomial kernel regression loss. Furthermore, our analysis reveals that the expressivity of a single block is inherently limited by its dimensions. We then show that a deep Transformer can overcome this bottleneck by distributing the computation of richer kernel functions across multiple blocks, performing block-coordinate descent in a high-dimensional feature space that a single block cannot represent. Our findings highlight that the feed-forward layers provide a crucial and scalable mechanism by which Transformers can express nonlinear representations for ICL.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑