arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.10147cs.LGcs.CLcs.ITmath.ITmath.OCstat.ML
收藏

基于表示的上下文学习:已训练Transformer的上下文泛化

In-Context Learning with Representations: Contextual Generalization of Trained Transformers

Carnegie Mellon University(卡内基梅隆大学);University of Pennsylvania(宾夕法尼亚大学);The Ohio State University(俄亥俄州立大学)

Tong Yang, Yu Huang, Yingbin Liang, Yuejie Chi

AI总结:

本文研究Transformer在非线性回归任务中的训练动态,证明一层多头Transformer能线性收敛至全局最小值并执行岭回归,首次可证明地展示其能从少量示例中学习上下文模板信息以泛化到未见示例和任务。

摘要:

上下文学习(ICL)是指预训练大型语言模型的一项显著能力,即在推理过程中,模型能够根据少量示例学习新任务。然而,对ICL的理论理解仍然十分不足,特别是Transformer是否可以通过训练泛化到提示词中未见过的示例,这要求模型获取提示词的上下文知识以实现泛化。本文通过非线性回归任务的视角,研究了Transformer通过梯度下降的训练动态。此处的上下文泛化可以通过在上下文中学习每个任务的模板函数来实现,其中所有模板函数位于具有$m$个基函数的线性空间中。我们分析了一层多头Transformer的训练动态,即在给定部分标记的提示词时,在上下文中预测未标记的输入,其中标签包含高斯噪声,且每个提示词中的示例数量不足以确定模板。在温和的假设下,我们证明了一层多头Transformer的训练损失线性收敛至全局最小值。此外,该Transformer有效地学会了在基函数上执行岭回归。据我们所知,本研究首次可证明地展示了当提示词仅包含少量查询-答案对时,Transformer能够学习上下文(即模板)信息,从而泛化到未见过的示例和任务。

英文摘要:

In-context learning (ICL) refers to a remarkable capability of pretrained large language models, which can learn a new task given a few examples during inference. However, theoretical understanding of ICL is largely under-explored, particularly whether transformers can be trained to generalize to unseen examples in a prompt, which will require the model to acquire contextual knowledge of the prompt for generalization. This paper investigates the training dynamics of transformers by gradient descent through the lens of non-linear regression tasks. The contextual generalization here can be attained via learning the template function for each task in-context, where all template functions lie in a linear space with $m$ basis functions. We analyze the training dynamics of one-layer multi-head transformers to in-contextly predict unlabeled inputs given partially labeled prompts, where the labels contain Gaussian noise and the number of examples in each prompt are not sufficient to determine the template. Under mild assumptions, we show that the training loss for a one-layer multi-head transformer converges linearly to a global minimum. Moreover, the transformer effectively learns to perform ridge regression over the basis functions. To our knowledge, this study is the first provable demonstration that transformers can learn contextual (i.e., template) information to generalize to both unseen examples and tasks when prompts contain only a small number of query-answer pairs.

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

↑