Loading lesson…
Level 1 · Apprentice0 XP
Queries, keys and values, the causal mask, and why we scale by √d.
Step 1 / 6
ProblemTo predict the word after "The cat sat on the", the last position needs information from "cat" and "sat". Something must move information from earlier tokens to later ones.
← → step
Before this: The simplest language model
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Implement the attention head by hand and compare its output with F.scaled_dot_product_attention on the same q, k and v (they should match to about 1e-5). Then remove the mask and see how fast the training loss collapses: that is the model cheating.