Keeping Softmax in Its Range
P10.attention.04 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Multi-Head Attention
Where next?
Go up a level
P10.attention.04 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Multi-Head Attention
Go up a level
A softmax turns scores into a distribution, and what kind of distribution it produces depends almost entirely on how large the scores are. Small scores give a spread of attention a model can learn from; large ones give a single winner and a gradient close to zero. This module reproduces the failure on this platform's own corpora — the same code, seed and sentence, breaking as the corpus grows — then takes it apart into the three guards that keep a softmax in its range, one switch each.
Why it matters — This is the recipe every attention surface here used until the input was normalised: correct for small inputs, and silently wrong as soon as the corpus grew.
Reads /api/attention/scale-guards — loading
Self-check
If the entries of the attention input double in size, what happens to the attention scores?
Self-check
Why does dividing the scores by √d_k not rescue attention on the raw sum of a large corpus?
Self-check
Why is BERT unaffected by the scale of its embeddings?
Practise this lesson's 3 self-checks
One per screen: you reveal each answer and mark it yourself. Nothing is recorded.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Loading your notes...