Mapping of attention mechanisms to a generalized Potts model

Riccardo Rende, Federica Gerace, Alessandro Laio, Sebastian Goldt
4/14/2023
cond-mat.dis-nncond-mat.stat-mechcs.CL
transformer-attention

No confident code implementation found for this paper.

Abstract

Transformers are neural networks that revolutionized natural language processing and machine learning. They process sequences of inputs, like words, using a mechanism called self-attention, which is trained via masked language modeling (MLM).

Show full abstract

In MLM, a word is randomly masked in an input sequence, and the network is trained to predict the missing word. Despite the practical success of transformers, it remains unclear what type of data distribution self-attention can learn efficiently. Here, we show analytically that if one decouples the treatment of word positions and embeddings, a single layer of self-attention learns the conditionals of a generalized Potts model with interactions between sites and Potts colors. Moreover, we show that training this neural network is exactly equivalent to solving the inverse Potts problem by the so-called pseudo-likelihood method, well known in statistical physics. Using this mapping, we compute the generalization error of self-attention in a model scenario analytically using the replica method.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{rende2023mapping,
  title  = {Mapping of attention mechanisms to a generalized Potts model},
  author = {Riccardo Rende and Federica Gerace and Alessandro Laio and Sebastian Goldt},
  year   = {2023},
  eprint = {2304.07235},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2304.07235v4}
}

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

Discussion