Attention-Only Transformers and Implementing MLPs with Attention Heads

Robert Huben, Valerie Morris
9/15/2023
cs.LG

No confident code implementation found for this paper. 2 possible matches can be shown below.

Abstract

The transformer architecture is widely used in machine learning models and consists of two alternating sublayers: attention heads and MLPs. We prove that an MLP neuron can be implemented by a masked attention head with internal dimension 1 so long as the MLP's activation function comes from a restricted class including SiLU and close approximations of ReLU and GeLU. This allows one to convert an MLP-and-attention transformer into an attention-only transformer at the cost of greatly increasing the number of attention heads. We also prove that attention heads can perform the components of an MLP (linear transformations and activation functions) separately. Finally, we prove that attention heads can encode arbitrary masking patterns in their weight matrices to within arbitrarily small error.

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. 2 weaker matches are hidden by default — 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{huben2023attentiononly,
  title  = {Attention-Only Transformers and Implementing MLPs with Attention Heads},
  author = {Robert Huben and Valerie Morris},
  year   = {2023},
  eprint = {2309.08593},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2309.08593v1}
}

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

Discussion