Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizers
Damai Dai, Yutao Sun, Li Dong, Yaru Hao, Shuming Ma, Zhifang Sui, Furu, Wei

TL;DR
This paper explains the in-context learning ability of large language models like GPT as an implicit form of gradient descent, providing theoretical insights and empirical evidence, and proposes a momentum-based attention mechanism to improve performance.
Contribution
It introduces a novel theoretical framework viewing Transformer attention as dual to gradient descent, and demonstrates how in-context learning functions as implicit finetuning, with a new momentum-based attention design.
Findings
In-context learning behaves similarly to explicit finetuning.
Momentum-based attention improves model performance.
Transformer attention has a dual form of gradient descent.
Abstract
Large pretrained language models have shown surprising in-context learning (ICL) ability. With a few demonstration input-label pairs, they can predict the label for an unseen input without parameter updates. Despite the great success in performance, its working mechanism still remains an open question. In this paper, we explain language models as meta-optimizers and understand in-context learning as implicit finetuning. Theoretically, we figure out that Transformer attention has a dual form of gradient descent. On top of it, we understand ICL as follows: GPT first produces meta-gradients according to the demonstration examples, and then these meta-gradients are applied to the original GPT to build an ICL model. We comprehensively compare the behaviors of in-context learning and explicit finetuning on real tasks to provide empirical evidence that supports our understanding. Experimental…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsTopic Modeling · Machine Learning and Data Classification · Advanced Neural Network Applications
MethodsMulti-Head Attention · Attention Is All You Need · Cosine Annealing · Linear Layer · Linear Warmup With Cosine Annealing · Byte Pair Encoding · Dense Connections · Attention Dropout · Residual Connection · Label Smoothing
