Masked Language Modeling: How BERT Predicts Missing Words
Interactive 3D masked-language-model simulator: mask a word in a sentence, watch its bidirectional context average into a vector in embedding space, and see live softmax probabilities over candidate words -- the core mechanism behind BERT.
BERT's headline trick is the masked language modeling objective: hide a token, then predict it from everything around it — left and right — rather than only what came before, as an autoregressive model like GPT must. This simulator makes that mechanism tangible with a small, fully computed toy model: a row of 3D token blocks renders a sentence with one word masked, a point cloud below it is a real embedding space where every vocabulary word sits at a fixed 3D unit vector, and pressing Predict averages the embeddings of the words on both sides of the mask into a single context vector, scores every candidate word by cosine similarity to it, and turns those scores into a probability distribution with a temperature-controlled softmax. Live readouts track the top prediction, its probability, the distribution's entropy, and whether the model actually recovered the true masked word, while the temperature slider and a vocabulary re-embedding button let you see how both the sharpness of the guess and the underlying geometry shape the outcome.
Mask a word in a sentence and watch a live 3D embedding space aggregate its bidirectional context into a vector, score every candidate word by cosine similarity, and turn those scores into softmax probabilities -- the core mechanism behind BERT's masked language modeling.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install