paper-with-me

Papers

Trained Transformers Learn Linear Models In-Context

2023-06-16 · Ruiqi Zhang, Spencer Frei, Peter L. Bartlett

Attention-based neural networks such as transformers have demonstrated a remarkable ability to exhibit in-context learning (ICL): Given a short prompt sequence of tokens from an unseen task, they can formulate relevant per-token and next-token predictions without any parameter updates. By embedding a sequence of labeled training data and unlabeled test data as a prompt, this allows for transformers to behave like supervised learning algorithms. Indeed, recent work has shown that when training transformer architectures over random instances of linear regression problems, these models' predictions mimic those of ordinary least squares. Towards understanding the mechanisms underlying this phenomenon, we investigate the dynamics of ICL in transformers with a single linear self-attention layer trained by gradient flow on linear regression tasks. We show that despite non-convexity, gradient flow with a suitable random initialization finds a global minimum of the objective function. At this global minimum, when given a test prompt of labeled examples from a new prediction task, the transformer achieves prediction error competitive with the best linear predictor over the test prompt distribution. We additionally characterize the robustness of the trained transformer to a variety of distribution shifts and show that although a number of shifts are tolerated, shifts in the covariate distribution of the prompts are not. Motivated by this, we consider a generalized ICL setting where the covariate distributions can vary across prompts. We show that although gradient flow succeeds at finding a global minimum in this setting, the trained transformer is still brittle under mild covariate shifts. We complement this finding with experiments on large, nonlinear transformer architectures which we show are more robust under covariate shifts.

📄 PDF Abstract BibTeX arXiv:2306.09927

Code (0)

등록된 구현이 없습니다.

Tasks

In-Context Learningregression

Methods 이 논문이 사용한 방법론

Linear Regression Linear Regression is a method for modelling a relationship between a dependent variable and independent variables. These models can be fit with numerous approaches. The most…

Similar Papers 제목 키워드 기반

Trained Transformer Classifiers Generalize and Exhibit Benign Overfitting In-Context

2024-10-02 · Spencer Frei, Gal Vardi

Transformers have the capacity to act as supervised learning algorithms: by properly encoding a set of labeled training ("in-context") examples and an unlabeled test example into an input sequence of vectors of the same …

Ghost in the Kernel: In-Context Learning with Efficient Transformers via Domain Generalization

2026-07-01 · Peilin Liu, Ding-Xuan Zhou arxiv

Transformer-based large models have demonstrated remarkable generalization abilities across different tasks by leveraging a context-aware attention module for in-context learning. With richer context, transformers adapt …

Domain Generalization

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

2024-08-19 · Tong Yang, Yu Huang, Yingbin Liang, Yuejie Chi

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

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…

In-Context Learning of Linear Systems: Generalization Theory and Applications to Operator Learning

2024-09-18 · Frank Cole, Yulong Lu, Wuzhe Xu, Tianhao Zhang

We study theoretical guarantees for solving linear systems in-context using a linear transformer architecture. For in-domain generalization, we provide neural scaling laws that bound the generalization error in terms of …

DiversityDomain GeneralizationIn-Context LearningOperator learning