How do Transformers Perform In-Context Autoregressive Learning?

Michaël E. Sander*, Raja Giryes, Taiji Suzuki, Mathieu Blondel, Gabriel Peyré

*Corresponding author for this work

Research output: Contribution to journalConference articlepeer-review

Abstract

Transformers have achieved state-of-the-art performance in language modeling tasks. However, the reasons behind their tremendous success are still unclear. In this paper, towards a better understanding, we train a Transformer model on a simple next token prediction task, where sequences are generated as a first-order autoregressive process st+1 = Wst. We show how a trained Transformer predicts the next token by first learning W in-context, and then applying a prediction mapping. We call the resulting procedure in-context autoregressive learning. More precisely, focusing on commuting orthogonal matrices W, we first show that a trained one-layer linear Transformer implements one step of gradient descent for the minimization of an inner objective function when considering augmented tokens. When the tokens are not augmented, we characterize the global minima of a one-layer diagonal linear multi-head Transformer. Importantly, we exhibit orthogonality between heads and show that positional encoding captures trigonometric relations in the data. On the experimental side, we consider the general case of non-commuting orthogonal matrices and generalize our theoretical findings.

Original languageEnglish
Pages (from-to)43235-43254
Number of pages20
JournalProceedings of Machine Learning Research
Volume235
StatePublished - 2024
Event41st International Conference on Machine Learning, ICML 2024 - Vienna, Austria
Duration: 21 Jul 202427 Jul 2024

Funding

FundersFunder number
ANR-19-P3IA-0001
Agence Nationale de la Recherche
Japan Society for the Promotion of Science24K02905
Core Research for Evolutional Science and TechnologyJPMJCR2015, JPMJCR2115

    Fingerprint

    Dive into the research topics of 'How do Transformers Perform In-Context Autoregressive Learning?'. Together they form a unique fingerprint.

    Cite this