Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Kwon, Soo Min, Xu, Alec S., Yaras, Can, Balzano, Laura, Qu, Qing
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866910176823476224
author Kwon, Soo Min
Xu, Alec S.
Yaras, Can
Balzano, Laura
Qu, Qing
author_facet Kwon, Soo Min
Xu, Alec S.
Yaras, Can
Balzano, Laura
Qu, Qing
contents The transformer's remarkable ability to perform in-context learning (ICL) has sparked a wide range of studies designed to understand its strengths and limitations. However, a theoretical understanding of when ICL can and cannot generalize beyond its pre-training data still remains unclear. This paper puts forth a minimal mathematical model that provably identifies when ICL can generalize out-of-distribution (OOD). By studying linear regression tasks parameterized with low-rank covariance matrices, we model distribution shifts as varying angles between subspaces and derive conditions under which a single-layer linear attention model interpolates across all angles. We show that if pre-training task vectors are drawn from a union of subspaces, transformers can generalize to all angle shifts--enabling ICL even in regions with zero probability mass in the training distribution. On the other hand, if the pre-training tasks are drawn from a single Gaussian, the test risk shows a non-negligible dependence on the angle, implying that ICL cannot generalize OOD. We empirically show that our results also hold for models such as GPT-2, and present experiments on how our results extend to nonlinear function classes.
format Preprint
id arxiv_https___arxiv_org_abs_2505_14808
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective
Kwon, Soo Min
Xu, Alec S.
Yaras, Can
Balzano, Laura
Qu, Qing
Machine Learning
Statistics Theory
The transformer's remarkable ability to perform in-context learning (ICL) has sparked a wide range of studies designed to understand its strengths and limitations. However, a theoretical understanding of when ICL can and cannot generalize beyond its pre-training data still remains unclear. This paper puts forth a minimal mathematical model that provably identifies when ICL can generalize out-of-distribution (OOD). By studying linear regression tasks parameterized with low-rank covariance matrices, we model distribution shifts as varying angles between subspaces and derive conditions under which a single-layer linear attention model interpolates across all angles. We show that if pre-training task vectors are drawn from a union of subspaces, transformers can generalize to all angle shifts--enabling ICL even in regions with zero probability mass in the training distribution. On the other hand, if the pre-training tasks are drawn from a single Gaussian, the test risk shows a non-negligible dependence on the angle, implying that ICL cannot generalize OOD. We empirically show that our results also hold for models such as GPT-2, and present experiments on how our results extend to nonlinear function classes.
title Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspective
topic Machine Learning
Statistics Theory
url https://arxiv.org/abs/2505.14808