Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformers
Tiberi, Lorenzo, Mignacco, Francesca, Irie, Kazuki, Sompolinsky, Haim
Despite the remarkable empirical performance of Transformers, their theoretical understanding remains elusive. Here, we consider a deep multi-head self-attention network, that is closely related to Transformers yet analytically tractable. We develop a statistical mechanics theory of Bayesian learning in this model, deriving exact equations for the network's predictor statistics under the finite-width thermodynamic limit, i.e., $N,P\rightarrow\infty$, $P/N=\mathcal{O}(1)$, where $N$ is the network width and $P$ is the number of training examples. Our theory shows that the predictor statistics are expressed as a sum of independent kernels, each one pairing different 'attention paths', defined as information pathways through different attention heads across layers. The kernels are weighted according to a 'task-relevant kernel combination' mechanism that aligns the total kernel with the task labels. As a consequence, this interplay between attention paths enhances generalization performance. Experiments confirm our findings on both synthetic and real-world sequence classification tasks. Finally, our theory explicitly relates the kernel combination mechanism to properties of the learned weights, allowing for a qualitative transfer of its insights to models trained via gradient descent. As an illustration, we demonstrate an efficient size reduction of the network, by pruning those attention heads that are deemed less relevant by our theory.
May-24-2024
- Country:
- North America
- United States
- Maryland > Baltimore (0.14)
- District of Columbia > Washington (0.04)
- New York > New York County
- New York City (0.04)
- Minnesota > Hennepin County
- Minneapolis (0.14)
- Massachusetts > Middlesex County
- Cambridge (0.04)
- Louisiana > Orleans Parish
- New Orleans (0.04)
- Hawaii > Honolulu County
- Honolulu (0.04)
- California
- San Diego County > San Diego (0.04)
- Los Angeles County > Long Beach (0.04)
- Canada > British Columbia
- United States
- Europe
- Austria > Vienna (0.14)
- France (0.04)
- Spain > Catalonia
- Barcelona Province > Barcelona (0.04)
- Russia > Central Federal District
- Moscow Oblast > Moscow (0.04)
- Italy > Tuscany
- Florence (0.04)
- Asia > Middle East
- Israel > Jerusalem District > Jerusalem (0.04)
- Africa > Rwanda
- North America
- Genre:
- Research Report > New Finding (0.34)