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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Fu, Deqing, Chen, Tian-Qi, Jia, Robin, Sharan, Vatsal
Format: Preprint
Published: 2023
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916482880897024
author Fu, Deqing
Chen, Tian-Qi
Jia, Robin
Sharan, Vatsal
author_facet Fu, Deqing
Chen, Tian-Qi
Jia, Robin
Sharan, Vatsal
contents 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 Descent (GD), a first-order optimization method, to perform ICL. In this paper, we instead demonstrate that Transformers learn to approximate second-order optimization methods for ICL. For in-context linear regression, Transformers share a similar convergence rate as Iterative Newton's Method, both exponentially faster than GD. Empirically, predictions from successive Transformer layers closely match different iterations of Newton's Method linearly, with each middle layer roughly computing 3 iterations; thus, Transformers and Newton's method converge at roughly the same rate. In contrast, Gradient Descent converges exponentially more slowly. We also show that Transformers can learn in-context on ill-conditioned data, a setting where Gradient Descent struggles but Iterative Newton succeeds. Finally, to corroborate our empirical findings, we prove that Transformers can implement $k$ iterations of Newton's method with $k + \mathcal{O}(1)$ layers.
format Preprint
id arxiv_https___arxiv_org_abs_2310_17086
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regression
Fu, Deqing
Chen, Tian-Qi
Jia, Robin
Sharan, Vatsal
Machine Learning
Artificial Intelligence
Computation and Language
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 Descent (GD), a first-order optimization method, to perform ICL. In this paper, we instead demonstrate that Transformers learn to approximate second-order optimization methods for ICL. For in-context linear regression, Transformers share a similar convergence rate as Iterative Newton's Method, both exponentially faster than GD. Empirically, predictions from successive Transformer layers closely match different iterations of Newton's Method linearly, with each middle layer roughly computing 3 iterations; thus, Transformers and Newton's method converge at roughly the same rate. In contrast, Gradient Descent converges exponentially more slowly. We also show that Transformers can learn in-context on ill-conditioned data, a setting where Gradient Descent struggles but Iterative Newton succeeds. Finally, to corroborate our empirical findings, we prove that Transformers can implement $k$ iterations of Newton's method with $k + \mathcal{O}(1)$ layers.
title Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regression
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2310.17086