ContentsThe library

The Mathematics of Attention

The Half of the Transformer That Does Not Move Information

Last timeNormalizing Over Features

Attention moves information between positions but computes almost nothing nonlinear. The feed-forward block does the opposite, and holds most of the parameters.

Seven lessons have been spent on attention, which is reasonable given the name

of the architecture. But attention is roughly a third of the parameters of a

transformer, and the block sitting next to it does something attention

structurally cannot.

What attention does not do

Consider what happens once the attention weights are fixed. The output is

outi=∑jaijvj\mathrm{out}_i = \sum_j a_{ij} v_j

which is a weighted sum of value vectors. Linear. The nonlinearity in attention

lives entirely in how aija_{ij} was computed, not in what is done with the values

once it has been.

So attention routes. It decides which vectors to mix and in what proportion.

Given that decision, no vector is transformed in any way a matrix could not do.

A stack of attention layers with nothing between them would therefore be close

to a linear map with input-dependent coefficients, which is a real but narrow

class of functions. Something has to supply the per-token computation.

The lesson stops here

8 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01Why Attention Needs Three Matrices, Not One
  2. 02Where the Square Root of dkd_k Comes Fromopening only
  3. 03Why Softmax and Not Some Other Normalisationopening only
  4. 04One Weighted Average Is Not Enoughopening only
  5. 05Attention Cannot See Order, So Order Has to Be Addedopening only
  6. 06The Skip Connection Is the Main Roadopening only
  7. 07Why Transformers Normalise Across Features and Not Across the Batchopening only
  8. 08The Half of the Transformer That Does Not Move Informationyou are here

Read alongside