RoBERTa: when the advance is training better what already existed
Masked Language Modeling, dynamic masking, and the other branch of the tree.
Landed here from LinkedIn? This is chapter 10 of the course GPT-1 and GPT-2, taken apart. It reads on its own; if you want the beginning, it is chapter 00.
Four months after GPT-1, Google took the same block and made the opposite decision. Without the causal mask, every token sees the whole sentence, past and future. The representation of 'bank' in 'I sat on the bank of the river' is built with 'river' available from the first block. That is BERT. But bidirectionality creates a training problem: if the model sees everything, predicting the next word becomes cheating. The fix was to hide words. And a year later, Facebook showed BERT was undertrained, and that sometimes the advance is training better what already existed.
The three points
- MLM: hide 15% of the tokens and ask the model to guess them using both sides. It is the objective that makes sense without a causal mask.
- RoBERTa did not change the architecture. It changed data, training time, batch size and the masking, which became dynamic.
- The structural differences you will touch: tokenizer, special tokens, and the absence of generation.
From the chapter, the beginning
Masked Language Modeling, dynamic masking, and the lesson that sometimes the advance is training better what already existed.
Without the mask, each token sees the whole sentence — past and future. The representation of "banco" in "sentei no banco da praça" (Portuguese: "I sat on the bench in the square") is now built with "praça" available from the very first block.
The gain in comprehension is enormous and immediate. BERT broke records on eleven tasks at once. But there is a price, and it is fatal for one specific thing.
What the chapter covers · 5 sections · 8 min
- The other branch of the tree
- The problem bidirectionality creates
- What RoBERTa changed (2019)
- The structural differences you will run into
- In the lab
All chapters of the course · GPT-1 and GPT-2, taken apart
- 00 · The seven fossils: why GPT-1, GPT-2 and RoBERTa are a historical cross-section, not a list
- Glossary · Course glossary: what token, layer and model mean in AI, and in the rest of IT
- 01 · Why GPT-2 sees neither letters nor words, and what that costs in Portuguese
- 02 · Embeddings: from a meaningless integer to a vector that knows king and queen are related
- 03 · Attention: the single operation that replaced twenty years of recurrent networks
- 04 · Twelve heads instead of one, and the single line of code that separates GPT from RoBERTa
- 05 · Why GPT-2 needs 48 floors to answer, and what happens inside each one
- 06 · What scale really buys: from 124 million to 1.5 billion, measured
- 07 · Temperature, top-k and top-p: the decision that changes the text more than switching models
- 08 · Perplexity: the one number that says what the model learned, without anecdotes
- 09 · GPT-1 to GPT-2: same size, half the perplexity. Four decisions explain it
- 10 · RoBERTa: when the advance is training better what already existed
- 11 · Encoder vs decoder: one line of code and every consequence that descends from it
- 12 · The detector: how a language model becomes a classifier, and why this one should decide nothing
- 13 · Reading GPT-2's original code: 174 lines against everything you learned
- 14 · Serving models: from function call to HTTP server, and what production does on top
- 15 · The lab guide: every command, every script, and everything that was measured
- 16 · The ceiling of this path: LeCun's argument, read from inside GPT-2

Writes the GPT-2 course and runs the Antivision experiment, measuring every run before publishing the number. The LinkedIn posts start here and end in the chapters.
Follow on LinkedIn →