arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.10616cs.LG
收藏

Transformer如何超越简单函数进行上下文学习?基于表示学习的案例研究

How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representations

UC Berkeley(加州大学伯克利分校);University of Michigan(密歇根大学);Salesforce AI Research(赛富时人工智能研究院)

Tianyu Guo, Wei Hu, Song Mei, Huan Wang, Caiming Xiong, Silvio Savarese, Yu Bai

AI总结:

本文通过构造组合结构的合成ICL问题,从理论和实验两方面证明Transformer能通过表示函数转换输入、上层执行线性ICL,实现近最优的复杂上下文学习。

摘要:

尽管基于Transformer架构的大语言模型已展现出显著的上下文学习(ICL)能力,但对此类能力的理解仍处于早期阶段,现有理论和机制性理解主要集中于简单场景,如学习简单函数类。本文通过研究基于表示的学习,迈出了理解更复杂场景下ICL的初步步伐。具体而言,我们构建了具有组合结构的合成上下文学习问题,其中标签通过一个可能复杂但固定的表示函数作用于输入,再与每个实例中不同的线性函数复合而成。通过构造,最优ICL算法首先通过表示函数转换输入,然后在转换后的数据集上执行线性ICL。我们从理论上证明了存在深度和规模适中的Transformer能够近似实现此类算法。在实验上,我们发现训练后的Transformer在此设置中始终能达到接近最优的ICL性能,并展现出理想的层次分解:较低层转换数据集,较高层执行线性ICL。通过广泛的探针实验和一种新的拼接实验,我们进一步揭示了训练后Transformer内部的若干机制,例如对输入和表示的具体复制行为、仅上层即具备线性ICL能力,以及在更困难的混合设置中的ICL后表示选择机制。这些观察到的机制与我们的理论高度吻合,可能有助于揭示Transformer在更现实场景中执行ICL的方式。

英文摘要:

While large language models based on the transformer architecture have demonstrated remarkable in-context learning (ICL) capabilities, understandings of such capabilities are still in an early stage, where existing theory and mechanistic understanding focus mostly on simple scenarios such as learning simple function classes. This paper takes initial steps on understanding ICL in more complex scenarios, by studying learning with representations. Concretely, we construct synthetic in-context learning problems with a compositional structure, where the label depends on the input through a possibly complex but fixed representation function, composed with a linear function that differs in each instance. By construction, the optimal ICL algorithm first transforms the inputs by the representation function, and then performs linear ICL on top of the transformed dataset. We show theoretically the existence of transformers that approximately implement such algorithms with mild depth and size. Empirically, we find trained transformers consistently achieve near-optimal ICL performance in this setting, and exhibit the desired dissection where lower layers transforms the dataset and upper layers perform linear ICL. Through extensive probing and a new pasting experiment, we further reveal several mechanisms within the trained transformers, such as concrete copying behaviors on both the inputs and the representations, linear ICL capability of the upper layers alone, and a post-ICL representation selection mechanism in a harder mixture setting. These observed mechanisms align well with our theory and may shed light on how transformers perform ICL in more realistic scenarios.

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

↑