arXiv:2410.03011stat.MLcs.LG2024-10ICLR被引 9

揭示Transformer在上下文学习中预测下一个词的通用机制

Towards Understanding the Universality of Transformers for Next-Token Prediction

  • 通过因果核下降法构建Transformer,实现对动态函数f的在线学习
  • 理论证明可仅用历史信息准确预测下一个token,与希尔伯特空间中的卡茨马尔兹算法相关
  • 实验验证方法对线性、周期性序列有效,适用于更广泛函数映射

因果Transformer通过给定上下文来预测下一个词。尽管普遍认为自注意力对编码序列因果结构至关重要,但其在上下文自回归学习中的具体机制仍不清晰。本文通过研究Transformer在下一词预测任务中的逼近能力,逐步揭示这一现象。我们考察了当 $ x_{t+1} = f(x_t) $ 且 $ f $ 为依赖上下文的函数时,因果Transformer预测 $ x_{t+1} $ 的能力,其中 $ (x_1, \dots, x_t) $ 作为提示。理论上,我们分析了 $ f $ 为线性或序列 $ (x_t)_{t \geq 1} $ 周期的情况,显式构造出使用线性、指数或Softmax注意力的Transformer,通过因果核下降法在上下文中学习映射 $ f $。该方法在理论上保证仅基于过去和当前观测 $ (x_1, \dots, x_t) $ 估计 $ x_{t+1} $,并与希尔伯特空间中的卡茨马尔兹算法具有关联。实验结果验证了理论发现,并暗示其对更一般函数 $ f $ 的适用性。

原文摘要 · Abstract (English)

Causal Transformers are trained to predict the next token for a given context. While it is widely accepted that self-attention is crucial for encoding the causal structure of sequences, the precise underlying mechanism behind this in-context autoregressive learning ability remains unclear. In this paper, we take a step towards understanding this phenomenon by studying the approximation ability of Transformers for next-token prediction. Specifically, we explore the capacity of causal Transformers to predict the next token $x_{t+1}$ given an autoregressive sequence $(x_1, \dots, x_t)$ as a prompt, where $ x_{t+1} = f(x_t) $, and $ f $ is a context-dependent function that varies with each sequence. On the theoretical side, we focus on specific instances, namely when $ f $ is linear or when $ (x_t)_{t \geq 1} $ is periodic. We explicitly construct a Transformer (with linear, exponential, or softmax attention) that learns the mapping $f$ in-context through a causal kernel descent method. The causal kernel descent method we propose provably estimates $x_{t+1} $ based solely on past and current observations $ (x_1, \dots, x_t) $, with connections to the Kaczmarz algorithm in Hilbert spaces. We present experimental results that validate our theoretical findings and suggest their applicability to more general mappings $f$.

Transformer自回归理论分析

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