HomeSIFT AI · Research Breakdown
Research Breakdown

BERT:

Pre-training of Deep Bidirectional Transformers for Language Understanding

The 2018 model that learned to read every sentence in both directions at once — and reset the bar on eleven language tasks in a single paper.

Devlin et al.Google AI LanguageNAACL 2019 · arXiv:1810.04805
Intermediate10 min read
GPT: left context only →mydogis[MASK]predict the hidden word →

Masked LM — a hidden token is read from left and right context at once.

80.5%GLUE score, +7.7 pts absolute over prior SOTA11NLP tasks pushed to new state of the art93.2SQuAD v1.1 Test F1 (+1.5 pt)340Mparameters in BERT-LARGE (110M in BASE)
How to read itDotted passages open the paper to that line.Solid terms link to the glossary.
The whole paper in 20 seconds

TL;DR

The idea
Pre-train deep bidirectional representations by conditioning on both left and right context in every layer.
The trick
Mask random tokens and predict them from context — so a deep bidirectional model never trivially sees the word it’s predicting.
The result
Eleven new state-of-the-art results, with GLUE pushed to 80.5% — a 7.7-point absolute jump.
The legacy
Rich unsupervised pre-training became a core component of language understanding — now deep and bidirectional.
Why it exists

Language models only read one way

Standard LM pre-training predicts the next word left-to-right — so it can never look ahead.

A language model is trained to predict the next token from the ones before it. That is fine for generation, but it hobbles transfer learning to tasks that need the whole sentence at once — question answering, entity tagging. The major limitation is that standard language models are unidirectional, and this limits the choice of architectures that can be used during pre-training.

The masked language model randomly masks some of the tokens from the input, and the objective is to predict the original vocabulary id of the masked word based only on its context.
The thesis

Read both directions at once

BERT conditions on left and right context in every layer — the property it is built around.

BERT is designed to pre-train deep bidirectional representations from unlabeled text by jointly conditioning on both left and right context in all layers. That single design choice — bidirectional self-attentioninstead of a left-only mask — is what separates it from the prior generation of pre-trained Transformer models. The mechanism on the right of the hero shows it live: a hidden word is recovered from context on both sides.

The trick

Masking is what makes bidirectionality trainable

You can't train a deep two-sided model normally — a word would see itself. Masking removes it from the input.

The masked language model (a Cloze task) hides a fraction of tokens and asks the model to recover them. In all of our experiments, we mask 15% of all WordPiece tokens in each sequence at random. A twist keeps pre-training aligned with fine-tuning, where [MASK] never appears — click through the 80/10/10 rule below.

Click any word to hide it, then reveal what the model recovers. Because attention runs in both directions, the slot is filled from the words on its left and right.

When a token is chosen (15% of them)

The token is replaced with [MASK] — the usual case.

§3.1 · 15% masking rate§3.1 · 80/10/10 corruption

The second task

Next Sentence Prediction

A trivially generated binary label teaches the model how two sentences relate — which QA and inference need.

Alongside the masked LM, BERT is pre-trained to tell whether one sentence really follows another. 50% of the time B is the actual next sentence that follows A (labeled as IsNext), and 50% of the time it is a random sentence from the corpus. No annotation is required — the labels fall out of any monolingual corpus for free.

One difference that matters

BERT vs GPT vs ELMo

BERT-BASE is sized to match GPT exactly — so the gains come from attention direction, not parameter count.

All three pre-train on text, but their connectivity differs. Critically, however, the BERT Transformer uses bidirectional self-attention, while the GPT Transformer uses constrained self-attention where every token can only attend to context to its left. The reported sizes are BERT-BASE (110M parameters) and BERT-LARGE (340M parameters), the two configurations behind every headline number.

Figure 3
Three side-by-side architecture diagrams: BERT (a bidirectional Transformer whose Trm units attend both ways), OpenAI GPT (a left-to-right Transformer), and ELMo (concatenated independently trained left-to-right and right-to-left LSTMs).
Figure 3: Differences in pre-training model architectures. BERT uses a bidirectional Transformer. OpenAI GPT uses a left-to-right Transformer. ELMo uses the concatenation of independently trained left-to-right and right-to-left LSTMs to generate features for downstream tasks.
Critically, however, the BERT Transformer uses bidirectional self-attention, while the GPT Transformer uses constrained self-attention where every token can only attend to context to its left.
One model, many tasks

Pre-train once, fine-tune anywhere

The same architecture and the same pre-trained parameters initialize every downstream task.

BERT is a two-phase recipe. Pre-training runs the masked LM and next-sentence tasks on unlabeled text; fine-tuning swaps in a small task-specific head and updates all parameters end-to-end. The encoder stack — and its weights — carry straight across.

Figure 1
Two-panel diagram: BERT pre-training on masked-LM and next-sentence prediction from an unlabeled sentence pair (left), and fine-tuning the same architecture on downstream tasks such as MNLI, NER, and SQuAD (right).
Figure 1: Overall pre-training and fine-tuning procedures for BERT. Apart from output layers, the same architectures are used in both pre-training and fine-tuning. The same pre-trained model parameters are used to initialize models for different down-stream tasks.
When choosing the sentences A and B for each pre-training example, 50% of the time B is the actual next sentence that follows A (labeled as IsNext), and 50% of the time it is a random sentence from the corpus (labeled as NotNext).
The decisive test

The ablation that isolates bidirectionality

Hold data and setup fixed, swap only the objective — and watch token-level tasks collapse.

This is the experiment that pins the credit on two-sided attention rather than scale or data. Flip the metric to see which tasks feel the loss most.

Drop the mask, drop the score (Table 5)

BERTBASE
88.5
No NSP
87.9
LTR & No NSP
77.8
+ BiLSTM
84.9

Swapping the masked LM for a left-to-right objective — everything else held fixed — costs 10.7 here. The LTR model performs worse than the MLM model on all tasks, with large drops on MRPC and SQuAD.

Table 5 · Ablation over pre-training tasks

The payoff

Eleven new states of the art — guess it first

Then see the full GLUE scoreboard, where even BERT-BASE beats every prior system on every task.

Before the reveal — what GLUE average did BERT-LARGE hit?

BERTLARGE, GLUE test average

75.0GLUE avg
65prior best 75.185

GLUE test average (Table 1)

Pre-OpenAI SOTA
74.0
BiLSTM+ELMo+Attn
71.0
OpenAI GPT
75.1
BERTBASE
79.6
BERTLARGE
82.1

Table 1 · GLUE results

Both BERTBASE and BERTLARGE outperform all systems on all tasks by a substantial margin, obtaining 4.5% and 7.0% respective average accuracy improvement over the prior state of the art. BERT also works without fine-tuning: concatenating the top four hidden layers as frozen features lands within 0.3 F1 of fine-tuning the whole model.

A surprise

Bigger keeps helping — even on tiny tasks

Drag through the six configurations: perplexity falls and accuracy rises the whole way up.

Larger models lead to a strict accuracy improvement across all four datasets, even for MRPC which only has 3,600 labeled training examples. With enough pre-training, extreme size pays off on small fine-tuning sets too — a result that was far from obvious at the time.

Model size · #L / #H / #A

24L / 1024H / 16A

Masked-LM perplexity

3.23

86.6

MNLI-m

87.8

MRPC

93.7

SST-2

The BERT-LARGE config — lowest perplexity, highest accuracy across the board.

Table 6 · Effect of model size

So what

Five things to remember

1

Read both directions at once.

Standard LM pre-training is unidirectional; BERT conditions on left and right context in every layer, the property that unlocks token-level tasks like QA.

Bidirectional designThe unidirectional constraintBERT vs GPT attention

2

Masking is what makes bidirectionality trainable.

Mask 15% of WordPiece tokens and predict them from context — with an 80/10/10 corruption rule so [MASK] never leaks the pre-train/fine-tune mismatch.

Masked LM objective15% masking rate80/10/10 corruptionNext Sentence Prediction

3

New state of the art on eleven tasks.

GLUE lifted to 80.5% (+7.7 absolute), SQuAD v1.1 to 93.2 F1 — even BERTBASE, matched to GPT's size, beats every prior system on every GLUE task.

Headline resultGLUE average gainModel sizes

4

The ablation isolates deep bidirectionality.

Swap MLM for a left-to-right objective, hold everything else fixed, and token-level tasks collapse (SQuAD 88.5→77.8) — proof the gains come from two-sided attention.

Ablation: bidirectionalityScaling to small tasks

5

Rich pre-training is now core to NLU.

BERT works fine-tuned or feature-based (within 0.3 F1 frozen), and extends unsupervised pre-training from unidirectional to deep bidirectional architectures.

Feature-based BERTConclusion