← Back to the track

Learn machine learning · part 8 · session 3

Self-attention and heads

Real heads from the small character model that ships with this track, measured with two statistics that are stated before they are used, and one head that neither statistic describes.

After this session you will be able to read an attention heatmap, measure a head with a stated statistic, and say when a head has no description worth giving.

attn.headsSession 8.3About 35 minutesYour check: predict results on new examples

The gate is three calls on three heatmaps, and two of the three have to hold.

01 · The question

A is one copy of the operation you did by hand in 8.2, with its own keys, queries and values. This model runs four of them side by side in each of its two layers, and they end up doing different jobs. A layer, with its heads and the small network after them, is one , which 8.5 assembles.

These are real heads from the small character model that ships with this track. Each cell is one weight from the operation you computed by hand last session: row 12 attends to column 5 means the weighted average at position 12 drew that fraction of its value from position 5.

Some of the heads on this page have a short description that survives being checked with a statistic. At least one does not, and I have left it in rather than inventing a name for it, because inventing names for heads is the usual way this topic goes wrong. Thirty five minutes.

Trained offline by scripts/ml/train-char-models.mjs, 111808 parameters, run here for inference only. Corpus: loading the credit

02 · Predict

Before anything runs

Four heads per block, one small model. How many of them do you expect to have a description that holds up when you measure it?

Four heads per block, one small model. How many of them do you expect to have a description that holds up when you measure it?

Choose something first.

03 · Try it

Loading the bundled character model.

Ask for a hint

Rungs open as you run the session, not as time passes. You have run it 0 times.

1. A question: available after 3 evaluated runs.

2. A narrowing: available after 5 evaluated runs.

3. A worked fragment, on a 4 by 4 toy: available after 7 evaluated runs.

4. The answer: available after 9 evaluated runs.

04 · Compare

05 · Check your understanding

Your check: predict results on new examples

not yet

Three heatmaps from the bundled model on the sample above, unlabelled. Call which has the largest weight on the previous position, which on the most recent space, and which neither statistic describes. Two of the three passes.

Called 0 of 0 variants so far.

Save your takeaway

Your takeaway

Edit it into your own words, or keep the line as it is.