Attention mechanism

Attention & transformers · component · 2014 · text · images · multimodal

What it is

A soft, content-based lookup: query a set of key-value pairs and read out a weighted average.

When to use it

Everywhere. It is the primitive that replaced recurrence, and it also describes retrieval and memory access.

Caveats

Cost and memory grow with the square of the sequence length, and attention has no built-in sense of order, so it depends on separate position information. Attention weights are also not a reliable explanation of why a model made a prediction.

Key ideas

  • Scaling by sqrt(d_k) keeps logits in a sane range
  • Multi-head = several attention subspaces concatenated, not several models

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