Paper commentary
A Primer in BERTology: What we know about how BERT works
Researchers survey BERT's knowledge, how it is stored, and how to compress it
- Problem Transformers like BERT perform well, but researchers can't yet say clearly why. That gap limits hypothesis-driven changes to their architecture.
- Method The authors review BERT studies on what it learns, how it represents that knowledge, and how it is compressed.
- Results The survey covers over 150 studies of BERT and outlines directions for future research.
Why BERT's behaviour is hard to explain
Transformers, introduced in 2017, reshaped NLP by allowing more parallel computation and better handling of long-range dependencies. BERT is the best-known model of this family and remains a standard baseline across many benchmarks. It works well, but researchers can't say clearly why, and that limits hypothesis-driven changes to its architecture.
Transformers also have little cognitive motivation, and their size makes pre-training experiments and ablation studies hard to run.
What the pre-trained stack consists of
BERT is a stack of Transformer encoder layers, and each layer holds several self-attention heads that build weighted representations from key, value and query vectors. Training has two stages: pre-training with masked language modeling and next sentence prediction, then fine-tuning with one or more fully-connected layers added on top of the final encoder layer.
Its input words are split into wordpieces, and token, position and segment embeddings are summed into a fixed-length vector. So the open question is where this knowledge is stored inside the stack, and that is what the probes below try to locate.
Impact maps from perturbed masking
The key idea is to measure how much masking one word changes the prediction of another word, and to store all those effects in one matrix per sentence. That matrix is called an impact matrix, and a heatmap of it is called an impact map. The method needs no extra trained parameters, so it can probe a model as it stands.
For each sentence, token-level perturbed masking produces the impact matrix F. Graph-based algorithms then induce a dependency tree from F, and that tree is compared against ground-truth annotations. The authors fed BERT 1,000 sentences from the English PUD treebank of the CoNLL 2017 Shared Task, using the pre-processing steps of BERT pre-training.
The authors noticed that the impact pattern often looks like syntactic structure, which led them to try extracting dependency trees from the matrices. The dependency probe's question is whether BERT can outperform linguistically uninformed baselines in unsupervised dependency parsing.
What one example impact map shows
That stripe means the word different strongly affects the earlier words of its phrase. This agrees with a ground-truth dependency tree that makes different the head of the remaining words in its phrase, and similar patterns appear for transitions and Hill.
A constituency tree places media closer to transitions than on is. A syntactically uninformed model would give media and on comparable impacts on transitions, but the map shows a much darker cell for media. So in this sentence the impact pattern tracks syntactic distance, although the authors test the observation quantitatively only in later sections.
Along the diagonal, the words form four contiguous chunks, and the two middle chunks interact strongly enough to form a larger verb phrase. The authors suggest that BERT may capture compositionality, though this rests on one example sentence.
Syntax in token embeddings, not in attention weights
Lin et al. (2019) showed that BERT representations are hierarchical rather than linear, so something like a syntactic tree sits alongside word order. Tenney et al. (2019b) and Liu et al. (2019a) found that the embeddings also encode parts of speech, syntactic chunks and roles. Hewitt and Manning (2019) learned transformation matrices that recovered syntactic dependencies in PennTreebank data from BERT token embeddings.
Jawahar et al. (2019) show a dependency tree read from self-attention, but give no quantitative evaluation of it. Jawahar et al. (2019) found dependency trees the best fit among 5 decomposition schemes applied to the [CLS] token, though the MSE differences were very small.
Which layers hold syntax
Hewitt and Manning (2019) reconstructed syntactic tree depth best from the middle layers, layers 6-9 for base BERT and 14-19 for BERT-large. Goldberg (2019) found the best subject-verb agreement around layers 8-9, and syntactic probing used by Jawahar et al. (2019) also peaked near the middle. This middle-layer pattern fits the finding of Liu et al.
(2019a) that middle layers are the most transferable across tasks.
The evidence on chunks conflicts, though, because Tenney et al. (2019a) place basic syntax earlier in the network while Liu et al. (2019a) find chunking best at middle layers. The studies use different suites of probing tasks, so the conflict isn't resolved yet. The final layers are the most specific to the masked language modeling task, which is one reason middle layers transfer better.
During fine-tuning the final layers change the most, and restoring the lower layers of a fine-tuned BERT to their original values barely hurts performance.
Layerwise trade-off in ELMo
The authors retrained softmax classifiers for bidirectional language modeling on each layer's representations, since the ELMo models were trained on the Billion Word Benchmark. The held-out portion was split into 80% for training, about 6.2M tokens, and 20% for evaluation, about 1.6M tokens, to limit domain shift.
Higher layers of the recurrent models consistently reached lower perplexity. The ELMo transformer model did not show this monotonic increase, although its top layer was the best of its layers. Across models, the layers better suited to language modeling also showed worse probing performance, so layers trade general features for task-specific ones.
For LSTMs, moving up the layers yields more task-specific representations, but the same doesn't hold for transformers. This motivates gradual unfreezing from the final layer during fine-tuning (Howard and Ruder, 2018).
Semantic and world knowledge gaps
Ettinger (2019) found that BERT's predictions were not altered by shuffled word order, truncated sentences or removed subjects and objects. This could mean the syntactic knowledge is incomplete, or that BERT doesn't need it for its tasks, and the authors judge the second more likely.
Replacing names in the coreference task changed 85% of predictions, which suggests the model has no generic idea of named entities. This holds even though its F1 scores on NER probing tasks are high (Tenney et al., 2019a). Addition and number decoding also showed that BERT forms poor representations for floating point numbers, partly because wordpiece splits break similar numbers apart.
The masked language modeling objective can fill cloze blanks to recall facts, and for some relation types vanilla BERT competes with knowledge-base methods (Petroni et al., 2019). Performance also drops as the number of necessary inference steps grows (Zhou et al., 2020; Richardson and Sabharwal, 2019).
Self-attention heads and special tokens
Kovaleva et al. (2019) describe five attention patterns, one of them heterogeneous, which is the pattern that could carry linguistic information. When BERT is fine-tuned on GLUE, fewer than 50% of heads show the heterogeneous pattern. Much of the model instead shows the vertical pattern, with attention on [CLS], [SEP] and punctuation. The authors of this survey link this redundancy to overparameterization.
Clark et al. (2019) found that early-layer heads attend more to [CLS], middle-layer heads to [SEP], and final-layer heads to periods and commas. They read this as a no-op signal that tells the model to ignore a head when its pattern doesn't apply. After fine-tuning, both [SEP] and [CLS] receive much attention, depending on the task. Punctuation also draws attention, because periods and commas are nearly as frequent as special tokens.
Compressing BERT and what it costs
Knowledge distillation trains a smaller student network to mimic a larger teacher, and quantization lowers the precision of the weights to save memory. Pruning zeroes out parts of the model, either in structured form, which drops whole blocks as in LayerDrop, or in unstructured form, which removes weights wherever they are.
In the comparison table, DistilBERT reaches ×1.5 compression with 90% performance retention relative to BERT-base. Some rows reach far larger compression, such as TinyBERT at ×7.5 with 96% retention, but those rows use different evaluation tasks.
Prasanna et al. (2020) and Chen et al. (2020) look for winning subnetworks in pre-trained BERT under the lottery ticket hypothesis, and they find such subnetworks exist. Transferability between subnetworks for different tasks varies. Adapter modules approximate fine-tuning and reach competitive performance on 26 classification tasks at a fraction of the computational cost.
Overparameterization and training changes
Base BERT's 110M parameters are now dwarfed by the 17B of Turing-NLG (Microsoft, 2020). Human language may need many parameters, but current models don't make good use of the ones they already have.
Depending on the task, some heads or layers are harmful as well as redundant, and disabling heads helped in some tasks. Larger isn't always better: BERT-base outperformed BERT-large on subject-verb agreement (Goldberg, 2019).
Clark et al. (2019) suggest that attention dropout, which zeroes some attention weights during training, may be one reason heads become redundant. Large-batch training with 8k examples improved both language model perplexity and downstream performance (Liu et al., 2019b). Warm-start training, which copies a shallower model's parameters into deeper layers, reached 25% faster training without sacrificing performance.
Limits of probing evidence
A probe that fails to find a pattern doesn't show the pattern is absent, and finding it doesn't show how the model uses it (Tenney et al., 2019a). If a more complex probe recovers more information, it's unclear how much of that still comes from the original model (Liu et al., 2019a). Different probing methods can give complementary or contradictory conclusions, so a single test is insufficient.
Many attention studies are qualitative and often use cherry-picked examples (Belinkov and Glass, 2019). Most studies also drop special tokens from inter-word attention, which may miss information that matters at inference time. Amnesic probing removes specific information from the model and measures the change in performance (Elazar et al., 2020).
Paper info
- Authors
- Anna Rogers, Olga Kovaleva, Anna Rumshisky
- Venue
- arXiv · Preprint
- First published
- 2020-2-27
- Added
- 2026-11-13
- Updated
- 2020-11-9
- Version
- v3
- arXiv
- 2002.12327
- Category
- cs.CL
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Anna Rogers, Olga Kovaleva, Anna Rumshisky (2020). A Primer in BERTology: What we know about how BERT works. arXiv:2002.12327v3. https://arxiv.org/abs/2002.12327v3
BibTeX
@misc{rogers2020primer,
title = {{A Primer in BERTology: What we know about how BERT works}},
author = {Anna Rogers and Olga Kovaleva and Anna Rumshisky},
year = {2020},
eprint = {2002.12327},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2002.12327v3}
}