techtree / Transformer / ← prev 23 of 26 next →

The transformer block

Attention then MLP, each wrapped in normalization and a residual.

46 seconds

Transcript

A transformer block puts the pieces together. In come the token vectors, with their positions added.

First, normalize each vector. Then multi-head attention, with the causal mask, lets the tokens share information. Its result is added back to the input.

Normalize again. Then the MLP works on each token's vector by itself, and its result is added back too.

Attention moves information between tokens. The MLP works within each token.

Out come the same number of vectors, each the same size as before, each one edited.

Normalize, attend, add. Normalize, MLP, add. That is one block.