arXiv:2510.10425cs.LG2025-10被引 3

揭示Transformer如何用Softmax实现上下文学习的梯度机制

Softmax $\geq$ Linear: Transformers may learn to classify in-context by kernel gradient descent

  • 通过核特征空间中的梯度下降实现分类学习
  • Softmax注意力使学习率随上下文自适应调整
  • 理论结合实证,拓展对大模型学习机制的理解

Transformer在仅通过输入提示中的示例学习新概念的能力——即上下文学习(ICL)——是智能行为的关键。本文聚焦于理解Transformer在上下文中学习所采用的算法。现有理论研究多基于线性自注意力与连续回归任务的简化假设,发现Transformer可通过梯度下降实现上下文学习。然而,实际Transformer常用于离散且复杂的分类任务,且采用非线性(关键为Softmax)激活函数。我们发现,即使在该设定下,Transformer仍能以核特征空间中的泛函进行梯度下降,并在Softmax Transformer中实现上下文自适应学习率。理论分析表明,Softmax注意力具有更强的上下文适应能力,我们通过消融实验进行验证与深入研究。整体而言,本工作推动了在更真实场景下对上下文学习算法的理论理解,深化直觉,并为更大模型的理论衔接提供基础。

原文摘要 · Abstract (English)

The remarkable ability of transformers to learn new concepts solely by reading examples within the input prompt, termed in-context learning (ICL), is a crucial aspect of intelligent behavior. Here, we focus on understanding the learning algorithm transformers use to learn from context. Existing theoretical work, often based on simplifying assumptions, has primarily focused on linear self-attention and continuous regression tasks, finding transformers can learn in-context by gradient descent. Given that transformers are typically trained on discrete and complex tasks, we bridge the gap from this existing work to the setting of classification, with non-linear (importantly, softmax) activation. We find that transformers still learn to do gradient descent in-context, though on functionals in the kernel feature space and with a context-adaptive learning rate in the case of softmax transformer. These theoretical findings suggest a greater adaptability to context for softmax attention, which we empirically verify and study through ablations. Overall, we hope this enhances theoretical understanding of in-context learning algorithms in more realistic settings, pushes forward our intuitions and enables further theory bridging to larger models.

Transformer上下文学习Softmax梯度下降

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