BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
TL;DR. BERT is a Transformer encoder pre-trained on unlabelled text with two tasks: predict masked tokens using context from both sides, and predict whether sentence B follows sentence A. For each downstream task you add one small output layer and fine-tune everything. BERT-LARGE set new results on eleven NLP tasks, including GLUE 80.5 (+7.7 points) and SQuAD 1.1 F1 93.2.
Key idea
Section titled “Key idea”Model. BASE: 12 layers, width 768, 12 heads, 110M parameters (sized to match GPT for comparison). LARGE: 24 layers, width 1024, 16 heads, 340M parameters. A WordPiece vocabulary of 30,000. Every input starts with [CLS], and sentence pairs are separated by [SEP] with segment embeddings.
Masked language modelling (MLM). Choose 15% of positions. Replace 80% of them with [MASK], 10% with a random token and leave 10% unchanged. Predict the original tokens with cross-entropy. Since the model cannot see which tokens are targets, it must represent every token using both left and right context.
Next-sentence prediction (NSP). Half the time B really follows A; otherwise it is a random sentence. The [CLS] vector is used to classify the pair. The pre-trained model reaches 97–98% on this task.
Data. BooksCorpus (800M words) plus English Wikipedia (2,500M words), using document-level text to get long contiguous sequences.
Key results
Section titled “Key results”BERT-LARGE reaches GLUE 80.5, 7.7 points above the previous best, MultiNLI 86.7, SQuAD 1.1 test F1 93.2 and SQuAD 2.0 test F1 83.1. In the Table 5 ablation on BERT-BASE, removing NSP lowers QNLI from 88.4 to 84.9, while left-to-right training without NSP drops MRPC from 86.7 to 77.5 and SQuAD from 88.5 to 77.8. Fine-tuning is robust to the masking mix, but the feature-based setting suffers if only [MASK] is used (Table 8).
Connections
Section titled “Connections”- Encoder of the original Transformer: Attention Is All You Need, explained visually in the Illustrated Transformer.
- The other two families: the decoder-only GPT-3 and the encoder-decoder T5.
- BERT in retrieval: ColBERT uses late interaction over BERT token vectors; SPLADE-v3 reuses the MLM head to produce sparse term weights; cross-encoder rerankers score a query and passage packed as one sentence pair, as in BERTs [SEP] input (see the reranker map).
- Compression: knowledge distillation.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Mechanism
BERT picks 15% of tokens as prediction targets and replaces them with [MASK] 80% of the time, a random token 10% of the time and leaves them unchanged 10% of the time. Explain why, and what the masking ablation in Appendix C.2 shows.
What a strong answer covers
- [MASK] never appears in fine-tuning, so always masking creates a mismatch between pre-training and fine-tuning inputs.
- Random and unchanged tokens force the model to keep a good representation of every input token, since it cannot tell which ones will be predicted.
- Table 8: fine-tuning is robust (MNLI 84.2 with 80/10/10 vs 84.3 with 100% [MASK]), but feature-based NER drops from 94.9 to 94.0 with only [MASK].
- Using only random replacement is clearly worse (MNLI 83.6), so some [MASK] tokens are needed.
- Derive / compute
Work out what fraction of all input tokens end up as [MASK], random and unchanged targets, and how many prediction targets a 512-token sequence gives compared with a left-to-right language model. What does the paper say this costs?
What a strong answer covers
- 0.15 × 0.8 = 12% of tokens become [MASK]; 0.15 × 0.1 = 1.5% become random tokens; 1.5% are unchanged targets.
- A 512-token sequence yields about 77 targets, while a left-to-right model predicts all 512.
- Fewer targets per step means slower learning per token; Appendix C.1 shows MLM converges marginally slower than left-to-right.
- The paper argues the gains from bidirectional context far outweigh this extra training cost.
- What if…
Using Table 5, compare BERT-BASE with versions that drop next-sentence prediction (NSP), that train left-to-right (LTR) without NSP, and that add a BiLSTM on top of the LTR model. What does each comparison show?
What a strong answer covers
- Dropping NSP hurts QNLI most (88.4 to 84.9), with small drops on MNLI and SQuAD.
- Training left-to-right hurts much more, especially MRPC (86.7 to 77.5) and SQuAD (88.5 to 77.8), since tokens cannot see their right context.
- Adding a BiLSTM to the LTR model recovers some SQuAD (84.9) but hurts GLUE, so it does not replace true bidirectional pre-training.
- These are single runs on dev sets, so small differences should not be over-read.