Back to library

AI / Technology

BERTPre-training of Deep Bidirectional Transformers for Language Understanding

Comparison of left-to-right context and BERT's jointly bidirectional context

Figure 1. A teaching diagram, not a reproduction of the paper’s figure. In a left-to-right model, the highlighted token can use only earlier context. In BERT, every layer can combine context from both sides. Source: paper pp. 1–3 and Appendix A.4, pp. 12–13.

The strongest result is not just a leaderboard score. In a controlled ablation, the left-to-right version performed worse than the bidirectional masked-language version on every reported task. The largest unresolved practical risk is cost: BERT-Large had 340 million parameters and its pretraining used 64 TPU chips for four days. Source: paper pp. 3, 7, 12

Masked language modeling uses context from both sides to recover a hidden token

Figure 2. The hidden position receives evidence from both sides. The paper notes a tradeoff: MLM predicts only 15% of tokens in each batch, so it can require more pretraining steps than a standard left-to-right model. Source: paper p. 3 and Appendix A.1, pp. 11–12.

BERT’s answer is the masked language model (MLM). It selects 15% of WordPiece token positions for prediction. Of those selected positions, 80% become [MASK], 10% become a random token, and 10% remain unchanged. The model predicts the original token using the surrounding sequence. Because the target is obscured, every Transformer layer can safely combine left and right context. Only selected positions contribute to this prediction task, rather than reconstructing the entire input. Source: paper §3.1, pp. 3–4

One pretrained BERT model branches into several fine-tuned task models

Figure 3. Pretraining supplies a shared starting point; each task gets its own fine-tuned copy and output layer. “One model” here means one shared pretrained initialization, not one deployed copy serving all tasks simultaneously. Source: paper Figure 1 and §3.2, pp. 3–4.

Inputs combine token, segment, and position embeddings. Pretraining used BooksCorpus (800 million words) plus English Wikipedia (2.5 billion words). For each downstream task, the same pretrained parameters initialize a new model; a small task-specific output layer is added and all parameters are fine-tuned. BERT-Base has 12 layers and 110 million parameters; BERT-Large has 24 layers and 340 million. Source: paper §§3–3.2, pp. 3–4

Research appendix

Authors: Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova
Source: arXiv:1810.04805, version 2 · submitted 11 October 2018, revised 24 May 2019
Reading note: This explanation separates the authors’ reported findings from practical interpretation.

Takeaway

Three things to remember

  1. BERT learns a word’s representation from the words on both sides at once, rather than processing only left-to-right or joining two separately trained directions.
  2. It makes that training possible by hiding some input tokens and asking the model to recover them; the hidden token cannot simply reveal its own answer.
  3. One pretrained model can then be adapted end-to-end with a small output layer for classification, question answering, and other language tasks.

The strongest result is not just a leaderboard score. In a controlled ablation, the left-to-right version performed worse than the bidirectional masked-language version on every reported task. The largest unresolved practical risk is cost: BERT-Large had 340 million parameters and its pretraining used 64 TPU chips for four days. Source: paper pp. 3, 7, 12

Problem

Why one-way reading was limiting

Before BERT, a fine-tuned Transformer language model such as OpenAI GPT was pretrained left-to-right: each token could attend only to earlier tokens. That is a poor fit for tasks where the answer depends on words on both sides, especially token-level tasks such as question answering. ELMo did use both directions, but trained its left-to-right and right-to-left models independently and joined their outputs later; the two directions did not interact through every layer. Source: paper pp. 1–2 and Appendix A.4, p. 12

The training paradox

Simply allowing an ordinary language model to see both sides would leak the answer: the target word could indirectly see itself. The paper’s core problem is therefore not merely “use more context.” It is: how can a deep model learn from both directions without letting the word being predicted give itself away? Source: paper §3.1, p. 3

Method

Hide a token, then recover it

BERT’s answer is the masked language model (MLM). It selects 15% of WordPiece token positions for prediction. Of those selected positions, 80% become [MASK], 10% become a random token, and 10% remain unchanged. The model predicts the original token using the surrounding sequence. Because the target is obscured, every Transformer layer can safely combine left and right context. Only selected positions contribute to this prediction task, rather than reconstructing the entire input. Source: paper §3.1, pp. 3–4

Learn relationships between text spans

BERT also uses next sentence prediction (NSP). Half of its training pairs contain a span followed by the span that actually came next; the other half pair the first span with a random span. The model predicts IsNext or NotNext from the special [CLS] representation. In this paper’s ablation, removing NSP reduced results on MNLI, QNLI, and SQuAD 1.1. Source: paper §3.1, pp. 3–4; §5.1, p. 7

Pretrain once, adapt the whole model

Inputs combine token, segment, and position embeddings. Pretraining used BooksCorpus (800 million words) plus English Wikipedia (2.5 billion words). For each downstream task, the same pretrained parameters initialize a new model; a small task-specific output layer is added and all parameters are fine-tuned. BERT-Base has 12 layers and 110 million parameters; BERT-Large has 24 layers and 340 million. Source: paper §§3–3.2, pp. 3–4

Evidence and limits

What the experiments show

The paper reports results on 11 NLP tasks. On the GLUE test suite, BERT-Large averaged 82.1 in the paper’s table, compared with 75.1 for OpenAI GPT; that average excludes WNLI. On SQuAD 1.1, the best BERT-Large ensemble with TriviaQA augmentation reached test F1 93.2, while its single model with the same augmentation reached 91.8. On SQuAD 2.0, the paper reports test F1 83.1, a 5.1-point improvement over the previous best system. Source: abstract; Tables 1–3, pp. 5–6

Controlled BERT-Base ablation (development set)MNLI-m accuracyQNLI accuracyMRPC accuracySST-2 accuracySQuAD F1
Full BERT-Base84.488.486.792.788.5
Without NSP83.984.986.592.687.9
Left-to-right, without NSP82.184.377.592.177.8

This table is the cleanest support for the central mechanism: with the same BERT-Base architecture, training data, fine-tuning scheme, and hyperparameters, the left-to-right objective was worse across all five reported measures. It does not isolate bidirectionality from NSP in one step; the most direct bidirectionality comparison is “without NSP” versus “left-to-right, without NSP.” Source: paper Table 5 and §5.1, p. 7

What remains uncertain

  • Compute and scale are entangled with the story. BERT used more pretraining text and a larger batch than the GPT setup it compared against. The paper’s controlled ablation helps, but leaderboard gains should not all be attributed to bidirectionality alone. Source: Appendix A.4, p. 13
  • Pretraining was expensive. Each model took four days; BERT-Large used 16 Cloud TPUs, or 64 TPU chips. Attention also grows quadratically with sequence length, so 90% of training steps used length 128 and only 10% used length 512. Source: Appendix A.2, p. 12
  • The evidence is benchmark-bound. The experiments establish strong results on the paper’s English NLP benchmarks, not factual reliability, fairness, robustness in deployment, multilingual quality, or causal “understanding” in a human sense. This is a limit of what was tested, not a claim that BERT necessarily fails those properties.
  • Some headline results use extra ingredients. The 93.2 SQuAD 1.1 test F1 comes from an ensemble with TriviaQA augmentation; the corresponding single augmented model scored 91.8. Source: Table 2, p. 6

Practical meaning

A reusable language foundation

The practical shift is a change in where engineering effort goes. Instead of building a heavily customized architecture for every language task, a team can start from a general pretrained encoder, attach a small output layer, and fine-tune the whole model on labeled examples. In the paper, the same input format covers single sentences, sentence pairs, question–passage pairs, and token-level outputs. Source: paper §3.2, p. 4

How to read the contribution today

As an interpretation, BERT is best understood as a proof of a reusable recipe: obscure part of the input so a deep encoder can learn genuinely two-sided context, then transfer the learned parameters to many tasks. The durable idea is the pretrain-then-adapt pattern and the masked objective—not that this exact model, NSP task, dataset mix, or hardware budget is automatically the best choice for every product.

Verification notes

  • Primary source: Devlin et al., BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, arXiv:1810.04805v2. Abstract and metadata · full paper
  • Terms: “bidirectional” means each token representation can condition on left and right context throughout the Transformer encoder; “fine-tuning” means updating the pretrained parameters for a labeled downstream task.
  • Questions worth carrying forward: How much of a gain comes from the objective versus data and scale? Does a benchmark match the intended use? What compute, latency, robustness, and fairness checks does deployment require?

Three key questions about this paper

What problem does BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding address?

Authors: Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova Source: arXiv:1810.04805, version 2 · submitted 11 October 2018, revised 24 May 2019 Reading note: This explanation separates the authors’ reported findings from practical interpretation.

What evidence supports the main claim in BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding?

This table is the cleanest support for the central mechanism: with the same BERT-Base architecture, training data, fine-tuning scheme, and hyperparameters, the left-to-right objective was worse across all five reported measures. It does not isolate bidirectionality from NSP in one step; the most direct bidirectionality comparison is “without NSP” versus “left-to-right, without NSP.” Source: paper Table 5 and §5.1, p. 7

What limitation should readers know about BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding?

This table is the cleanest support for the central mechanism: with the same BERT-Base architecture, training data, fine-tuning scheme, and hyperparameters, the left-to-right objective was worse across all five reported measures. It does not isolate bidirectionality from NSP in one step; the most direct bidirectionality comparison is “without NSP” versus “left-to-right, without NSP.” Source: paper Table 5 and §5.1, p. 7

2 new free reports left todaySubscribe to Pro for unlimited reading and 10 new paper explanations each month.Upgrade to Pro