Out-of-distribution generalization via composition: a lens through induction heads in Transformers

Jiajun Song, Zhuoyan Xu, Yiqiao Zhong
8/18/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: JiajunSong629/ood-generalization-via-composition (6 stars, MIT, last commit 2025-03-04).

Abstract

Large language models (LLMs) such as GPT-4 sometimes appear to be creative, solving novel tasks often with a few demonstrations in the prompt. These tasks require the models to generalize on distributions different from those from training data -- which is known as out-of-distribution (OOD) generalization. Despite the tremendous success of LLMs, how they approach OOD generalization remains an open and underexplored question. We examine OOD generalization in settings where instances are generated according to hidden rules, including in-context learning with symbolic reasoning. Models are required to infer the hidden rules behind input prompts without any fine-tuning. We empirically examined the training dynamics of Transformers on a synthetic example and conducted extensive experiments on a variety of pretrained LLMs, focusing on a type of components known as induction heads. We found that OOD generalization and composition are tied together -- models can learn rules by composing two self-attention layers, thereby achieving OOD generalization. Furthermore, a shared latent subspace in the embedding (or feature) space acts as a bridge for composition by aligning early layers and later layers, which we refer to as the common bridge representation hypothesis.

View on arXivView PDF

Code Implementations(1)

MIT
60Shell, PythonAug 13, 20241 years agoMIT

Similar Papers

Cite this paper

@article{song2024outofdistribution,
  title  = {Out-of-distribution generalization via composition: a lens through induction heads in Transformers},
  author = {Jiajun Song and Zhuoyan Xu and Yiqiao Zhong},
  year   = {2024},
  eprint = {2408.09503},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2408.09503v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2408.09503.svg)](https://codeofpaper.com/paper/2408.09503)

Discussion