This page assumes you know nothing. Before you can read the parent note, every squiggle it uses must first be a picture in your head. We build them one at a time, each from the one before.
Before any math, the atom of everything here is the token.
Picture a sentence as a row of boxes, one word per box:
Look at the figure. "The cat sat" becomes three boxes: [the] [cat] [sat]. Each box is a token. The model never sees letters — it sees this row of boxes.
Why the topic needs it: MLM works by hiding a box and asking the model to refill it. If we couldn't cut text into boxes, there would be nothing to hide.
We hide some boxes, not all. We need a way to say "the collection of box-numbers we hid."
In the figure, out of 7 boxes we hide boxes 3 and 5, so M={3,5}. The hidden boxes turn coral; the visible ones stay lavender.
Why the topic needs it: BERT hides ~15% of tokens. M is exactly which ones. Every prediction and every piece of loss happens only at positions inside M.
A computer can't multiply words. Every box must become a list of numbers.
The figure shows the pipeline: word → its own number-vector → plus context from neighbours → the final vector hi. Two identical words in different sentences get differenthi — that's the whole point of "contextual."
Why the topic needs it: Loss and softmax operate on numbers, not letters. hi is the bridge from language to arithmetic.
Scores can be any number (even negative). Probabilities must be between 0 and 1 and add up to 1. We need a converter.
Putting it together, the softmax for word xi at box i:
P(xi∣x\M)=v∈V∑exp(wv⊤hi)exp(wxi⊤hi)
Read it as a fraction: top = "how much score this one word got (made positive)"; bottom = "the total score of all words." Dividing forces the numbers to add to 1 across the vocabulary — a valid probability.
The figure shows raw scores (some negative) becoming positive bars via exp, then squeezed down so they sum to exactly 1.
Why the topic needs it: This is how the raw dot-product scores become the confidence P(⋅) that the loss reads.
The last piece: turning "confidence in the right word" into a number to shrink.
Now the parent's loss reads plainly:
LMLM=−∑i∈MlogP(xi∣x\M)
"For every hidden box i, take the model's confidence in the true word, log it, flip the sign, and add them up. Shrinking this number = making the model more confident in the right words."
Read top to bottom: boxes give us a numbered sequence; hiding some gives M; each box becomes a vector hi; dot products score candidate words; exp + softmax turn scores into probabilities; log + minus assemble the loss — and that is MLM.