JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attention

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Tian, Yuandong, Wang, Yiping, Zhang, Zhenyu, Chen, Beidi, Du, Simon
Format: Preprint
Veröffentlicht: 2023
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866929277004414976
author Tian, Yuandong
Wang, Yiping
Zhang, Zhenyu
Chen, Beidi
Du, Simon
author_facet Tian, Yuandong
Wang, Yiping
Zhang, Zhenyu
Chen, Beidi
Du, Simon
contents We propose Joint MLP/Attention (JoMA) dynamics, a novel mathematical framework to understand the training procedure of multilayer Transformer architectures. This is achieved by integrating out the self-attention layer in Transformers, producing a modified dynamics of MLP layers only. JoMA removes unrealistic assumptions in previous analysis (e.g., lack of residual connection) and predicts that the attention first becomes sparse (to learn salient tokens), then dense (to learn less salient tokens) in the presence of nonlinear activations, while in the linear case, it is consistent with existing works that show attention becomes sparse over time. We leverage JoMA to qualitatively explains how tokens are combined to form hierarchies in multilayer Transformers, when the input tokens are generated by a latent hierarchical generative model. Experiments on models trained from real-world dataset (Wikitext2/Wikitext103) and various pre-trained models (OPT, Pythia) verify our theoretical findings. Code can be found in https://github.com/facebookresearch/luckmatters/tree/yuandong3.
format Preprint
id arxiv_https___arxiv_org_abs_2310_00535
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attention
Tian, Yuandong
Wang, Yiping
Zhang, Zhenyu
Chen, Beidi
Du, Simon
Machine Learning
Artificial Intelligence
Computation and Language
We propose Joint MLP/Attention (JoMA) dynamics, a novel mathematical framework to understand the training procedure of multilayer Transformer architectures. This is achieved by integrating out the self-attention layer in Transformers, producing a modified dynamics of MLP layers only. JoMA removes unrealistic assumptions in previous analysis (e.g., lack of residual connection) and predicts that the attention first becomes sparse (to learn salient tokens), then dense (to learn less salient tokens) in the presence of nonlinear activations, while in the linear case, it is consistent with existing works that show attention becomes sparse over time. We leverage JoMA to qualitatively explains how tokens are combined to form hierarchies in multilayer Transformers, when the input tokens are generated by a latent hierarchical generative model. Experiments on models trained from real-world dataset (Wikitext2/Wikitext103) and various pre-trained models (OPT, Pythia) verify our theoretical findings. Code can be found in https://github.com/facebookresearch/luckmatters/tree/yuandong3.
title JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attention
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2310.00535