paper-with-me

Papers

Transformers learn in-context by gradient descent

2022-12-15 · Johannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento, Alexander Mordvintsev, Andrey Zhmoginov, Max Vladymyrov

At present, the mechanisms of in-context learning in Transformers are not well understood and remain mostly an intuition. In this paper, we suggest that training Transformers on auto-regressive objectives is closely related to gradient-based meta-learning formulations. We start by providing a simple weight construction that shows the equivalence of data transformations induced by 1) a single linear self-attention layer and by 2) gradient-descent (GD) on a regression loss. Motivated by that construction, we show empirically that when training self-attention-only Transformers on simple regression tasks either the models learned by GD and Transformers show great similarity or, remarkably, the weights found by optimization match the construction. Thus we show how trained Transformers become mesa-optimizers i.e. learn models by gradient descent in their forward pass. This allows us, at least in the domain of regression problems, to mechanistically understand the inner workings of in-context learning in optimized Transformers. Building on this insight, we furthermore identify how Transformers surpass the performance of plain gradient descent by learning an iterative curvature correction and learn linear models on deep data representations to solve non-linear regression tasks. Finally, we discuss intriguing parallels to a mechanism identified to be crucial for in-context learning termed induction-head (Olsson et al., 2022) and show how it could be understood as a specific case of in-context learning by gradient descent learning within Transformers. Code to reproduce the experiments can be found at https://github.com/google-research/self-organising-systems/tree/master/transformers_learn_icl_by_gd .

📄 PDF Abstract BibTeX arXiv:2212.07677

Code (2)

google-research/self-organising-systems 공식 구현 tf
RobvanGastel/meta-in-context-learning jax

Tasks

In-Context LearningMeta-Learningregression

Similar Papers 제목 키워드 기반

Transformers learn to implement preconditioned gradient descent for in-context learning

2023-09-21 · NeurIPS 2023 11

Motivated by the striking ability of transformers for in-context learning, several works demonstrate that transformers can implement algorithms like gradient descent. By a careful construction of weights, these works sho…

Transformers Efficiently Perform In-Context Logistic Regression via Normalized Gradient Descent

2026-05-07 · Chenyang Zhang, Yuan Cao arxiv

Transformers have demonstrated remarkable in-context learning (ICL) capabilities. The strong ICL performance of transformers is commonly believed to arise from their ability to implicitly execute certain algorithms on th…

Bypassing the Exponential Dependency: Looped Transformers Efficiently Learn In-context by Multi-step Gradient Descent

2024-10-15 · Bo Chen, Xiaoyu Li, YIngyu Liang, Zhenmei Shi 외

In-context learning has been recognized as a key factor in the success of Large Language Models (LLMs). It refers to the model's ability to learn patterns on the fly from provided in-context examples in the prompt during…

In-Context Learning

Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regression

2023-10-26 · Deqing Fu, Tian-Qi Chen, Robin Jia, Vatsal Sharan

Transformers excel at in-context learning (ICL) -- learning from demonstrations without parameter updates -- but how they do so remains a mystery. Recent work suggests that Transformers may internally run Gradient Descen…

In-Context Learning

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

2025-10-12 · Sara Dragutinović, Andrew M. Saxe, Aaditya K. Singh arxiv

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 understand…