Multi-head attention

Transformer components · component · 2017 · text · images

What it is

Several attention heads run in parallel on projected subspaces, then concatenate — different heads learn different relations.

When to use it

The core mixing operation in every transformer; head specialization explains much of interpretability work.

Caveats

Many heads turn out to be redundant and can be pruned with little loss. For a fixed model width, more heads means fewer dimensions per head, and the cost is still quadratic in sequence length.

Key ideas

  • Runs several attention operations in parallel, each in its own subspace
  • Different heads can attend to different relations or positions
  • The outputs are concatenated and projected back to the model width

Related architectures

Original paper

Attention Is All You Need (2017, arXiv)

Lessons that cover it

Browse all 198 architectures

The architecture landscape, in one place.

Two things get called “ML architecture”: the classical statistical model families, and the neural network wirings. Both are here, tagged by what they are and what data they eat.

Start from your problem

Architectures

0 shortlisted