How transformers learn structured data: insights from hierarchical filtering

Jerome Garnier-Brun, Marc Mézard, Emanuele Moscato, Luca Saglietti
8/27/2024
cs.LGcond-mat.dis-nncond-mat.stat-mech

No official code found. Best implementation: emanuele-moscato/tree-language-paper-submission (1 star, last commit 2024-12-09).

Abstract

Understanding the learning process and the embedded computation in transformers is becoming a central goal for the development of interpretable AI. In the present study, we introduce a hierarchical filtering procedure for data models of sequences on trees, allowing us to hand-tune the range of positional correlations in the data. Leveraging this controlled setting, we provide evidence that vanilla encoder-only transformers can approximate the exact inference algorithm when trained on root classification and masked language modeling tasks, and study how this computation is discovered and implemented. We find that correlations at larger distances, corresponding to increasing layers of the hierarchy, are sequentially included by the network during training. By comparing attention maps from models trained with varying degrees of filtering and by probing the different encoder levels, we find clear evidence of a reconstruction of correlations on successive length scales corresponding to the various levels of the hierarchy, which we relate to a plausible implementation of the exact inference algorithm within the same architecture.

View on arXivView PDF

Code Implementations(1)

10PythonDec 9, 20241 years ago

Similar Papers

Cite this paper

@article{garnierbrun2024transformers,
  title  = {How transformers learn structured data: insights from hierarchical filtering},
  author = {Jerome Garnier-Brun and Marc Mézard and Emanuele Moscato and Luca Saglietti},
  year   = {2024},
  eprint = {2408.15138},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2408.15138v3},
  journal = {ICML 2024 2024}
}

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.15138.svg)](https://codeofpaper.com/paper/2408.15138)

Discussion