揭示Transformer前馈层在非线性上下文学习中的关键作用
On the Role of Transformer Feed-Forward Layers in Nonlinear In-Context Learning
- 用多项式核回归损失分析前馈层如何实现非线性上下文学习
- 单层表达能力受限于维度,深层结构可突破此瓶颈
- 适合研究大模型机制、非线性表示与上下文学习的学者
基于Transformer的模型展现出强大的上下文学习(ICL)能力,能在不更新参数的情况下,仅凭少量示例适应新任务。已有研究发现,最优线性自注意力(LSA)机制在随机线性回归任务上可实现一步梯度下降。本文进一步探讨非线性函数类的ICL问题,证明LSA在非线性任务中无法超越线性预测器,因此难以直接推广。为克服该限制,我们分析了包含LSA与受门控线性单元(GLU)启发的前馈层的标准Transformer块,发现其可通过一步梯度下降实现多项式核回归。此外,我们揭示单个块的表达能力受维度限制,而深层Transformer可通过多层分布式计算实现更丰富的核函数,相当于在高维特征空间中执行块坐标下降,这是单层无法实现的。研究结果表明,前馈层提供了关键且可扩展的非线性表示机制,支撑Transformer的非线性上下文学习能力。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。