In one line: Masked-LM pretraining of a deep bidirectional Transformer encoder plus per-task fine-tuning set SOTA on 11 NLP tasks and made pretrain-then-finetune the default recipe; the encoder lineage lives on in embeddings/retrieval via ModernBERT and Ettin.
How far to trust it: Believe the central claim: masked-LM pretraining of a deep bidirectional encoder beats the same model trained left to right, by margins many standard errors wide, and every later encoder confirmed it. Treat next sentence prediction as unproven (one run, one task outside the noise, reversed by RoBERTa) and the dev-set ablations as single, dev-selected runs. The evidence, judged.
Hide 15% of the input words and train a deep Transformer encoder to recover them from both sides, so every layer can look left and right without the answer leaking into its own prediction; then copy that one pretrained encoder per task, add a single output layer and fine-tune everything.
New terms. Masked LM (MLM): predict hidden input words from both sides. NSP: is sentence B the real next sentence? C: the final state of [CLS]; Ti: the final state of token i. Feature-based against fine-tuning transfer: freeze the representations and feed them to a task model, or train everything.
One encoder, pretrained once with two losses, then copied and fine-tuned per task with one small output layer. The figure is the paper's Figure 1 in 3D, run on one pretraining pair of this page's toy language by the toy BERT (Run a toy BERT); drag it to turn it.
[CLS], sentence A (blue), [SEP], sentence B (green), [SEP], packed into one sequence. For the masked LM some word positions are hidden: here dog becomes [MASK].[CLS], Ti for token i. The orange streams are the masked position gathering from both sides, in proportion to its attention weights.After Figure 1, redrawn (the arXiv paper is not CC BY, so no image of the original); the paper's figure uses illustrative tokens, this one the toy's. The output layers in the last step are drawn, not run: the toy's own fine-tuning is measured in Run a toy BERT.
By 2018, pretraining a language representation on unlabelled text and then transferring it was clearly effective: ELMo, ULMFiT and OpenAI GPT had all improved many tasks with it (§1, §2). There were two ways to transfer. The feature-based way (ELMo) feeds pretrained representations as extra features into a task-specific architecture. The fine-tuning way (GPT) adds a few task parameters and fine-tunes all the pretrained ones. Both pretrained with the same kind of objective: a unidirectional language model (§1).
That is the handicap the paper attacks. A standard language model can only be trained left to right (or right to left), because in a deep network that conditions on both sides each word could indirectly "see itself" through the higher layers (§3.1). So GPT's Transformer lets every token attend only to tokens on its left, and ELMo's two directions are separate, shallow LSTMs whose outputs are merely concatenated (§2.1, Figure 3). For sentence-level tasks this is sub-optimal; for token-level tasks such as question answering and named entity recognition, where the context on the right of a word is essential, it "could be very harmful" (§1).
The gap: a way to pretrain a genuinely deep bidirectional model on unlabelled text that transfers to many tasks, sentence-level and token-level, with minimal task-specific architecture.
Why can a bidirectional model not simply be trained to predict each word? Because in a stack of self-attention layers, the state at position i in layer 2 attends to every position of layer 1, and each of those already attended to the word at i. The answer leaks into its own prediction, and the model "could trivially predict the target word" (§3.1). A left-to-right model avoids the leak by never looking right, which is exactly the handicap.
BERT's answer is the masked language model (MLM), the Cloze task of Taylor (1953): replace some input words with a [MASK] token and predict the original only at those positions, from both sides (§3.1). The word to predict is not in the input any more, so no path through the layers can carry it, and every layer may attend in both directions. The figure runs one sentence through two layers three ways; pick one, then follow its steps.
[MASK]. The answer is no longer anywhere in the input.Two attention layers of this page's toy models (Run a toy BERT): line width and dot density are their real attention weights, heads averaged, and the probabilities are their real outputs. Orange states hold information from the word dog itself. The left-to-right model predicts the word at a position from the state one position earlier, as a language model does. "Both ways, no mask" uses the toy BERT's weights on the unmasked sentence; such a model is not trained here, since it would learn to copy.
Live: both toy models after pretraining on the same text. Change the verb and watch only the bidirectional model change its mind; the left-to-right model's guess cannot depend on a word it has not read.
Top five words for the blank, softmax over the 86 ordinary words of the toy vocabulary. Bidirectional: the masked-LM head at the [MASK]. Left to right: the next-word head at "big".
BERT is "a multi-layer bidirectional Transformer encoder" almost identical to the original of Vaswani et al. (2017) (§3). With L layers, hidden size H and A attention heads, and the feed-forward size always 4H (footnote 3):
| Model | L | H | A | Feed-forward | Parameters (paper) | Recounted |
|---|---|---|---|---|---|---|
| BERT-Base | 12 | 768 | 12 | 3,072 | 110M | |
| BERT-Large | 24 | 1024 | 16 | 4,096 | 340M | |
| OpenAI GPT | 12 | 768 | 12 | 3,072 | (same size) |
Base recounts to 110M from the released configuration, independently; Large to 335M, not 340M (details below).
Recounted from the released configurations (bert-base-uncased, bert-large-uncased, vocabulary 30,522, 512 positions): embeddings (V + 512 + 2)H plus their LayerNorm, per layer 4(H² + H) + 2 · 4H² + 5H + 4H, plus the pooler H² + H. Base reproduces 110M independently; Large comes out at 335M, not 340M, and the pretraining heads add only 0.6M to 1.1M. ModernBERT's Table 2 lists BERT-Large as 330M. GPT from its configuration (vocabulary 40,478): BERT-Base "was chosen to have the same model size as OpenAI GPT" (§3), and the two differ by about 6%, all of it in GPT's larger vocabulary (40,478 entries against 30,522). The tables tab recounts every Table 6 size.
The one architectural difference from GPT is the attention mask: BERT's self-attention is bidirectional, GPT's lets each token see only its left, which is why the literature calls them a Transformer "encoder" and "decoder" (footnote 4). The input has to represent a single sentence or a pair (question and passage, say) as one sequence, where a "sentence" is any span of contiguous text (§3):
[CLS]; its final hidden state C ∈ ℝH is the aggregate representation for classification. The final state of token i is Ti.[SEP], and each token also gets a learned segment embedding, A or B.[SEP]. The word austin appears twice.Figure 2 redrawn with the toy BERT's real learned vectors: 24 numbers each, drawn as bars (up positive, down negative, one scale for every row); the tables are the glass plates on the left. Note the segment row: two vectors only, A for the first sentence and B for the second.
The data generator picks 15% of the WordPiece positions of each sequence at random. Their final states Ti go through a softmax over the vocabulary and are trained with cross-entropy to predict the original token; unlike a denoising autoencoder, nothing else is reconstructed (§3.1; how MLM compares with causal LM, span corruption and UL2 as objectives is on Families and objectives). Masking is applied after WordPiece tokenisation, uniformly, with no special treatment of word pieces (A.2).
The authors later released Whole Word Masking models, which mask all the pieces of a word at once, because predicting one piece of a split word was "too 'easy'" (repository README, 31 May 2019).
A [MASK] token never appears at fine-tuning time, which creates a mismatch. So a chosen position is not always masked (§3.1, A.1):
| Of the chosen 15% | Example (the 4th token, hairy, chosen) | Share of all tokens |
|---|---|---|
80%: replaced by [MASK] | my dog is hairy → my dog is [MASK] | 12% |
| 10%: replaced by a random word | my dog is hairy → my dog is apple | 1.5% |
| 10%: left unchanged | my dog is hairy → my dog is hairy | 1.5% |
Because the encoder does not know which words it will be asked to predict, or which were swapped, it is forced to keep "a distributional contextual representation of every input token"; keeping some words unchanged biases the representation towards the observed word, and random replacement touches only 1.5% of tokens (10% of 15%), too few to harm understanding (A.1). The price: only 15% of positions produce a loss in each batch, against every position for a left-to-right model, so MLM should need more steps. It does converge marginally slower, but its downstream accuracy overtakes the left-to-right model's almost immediately (C.1, Figure 5 below).
The masking is the paper's rule exactly as the toy was trained (at least one position, never [CLS] or [SEP]; then 80/10/10). The predictions are the toy BERT's, at every chosen position, including those it was not told were changed. The tally draws the rule 10,000 times over this pair's positions.
Question answering and natural language inference turn on the relation between two sentences, which language modelling does not capture directly. So every pretraining example is a pair: 50% of the time B is the sentence that actually follows A (IsNext), 50% a random sentence from the corpus (NotNext), and C, the final [CLS] state, classifies which (§3.1). The final model gets 97% to 98% on it (footnote 5), and C is "not a meaningful sentence representation without fine-tuning, since it was trained with NSP" (footnote 6). The appendix's examples:
[CLS] reads the whole pair. Its final state C is built by attention over every token of both sentences; the streams are [CLS]'s real layer-2 attention weights in the toy BERT, heads averaged.The paper reports NSP as "very beneficial to both QA and NLI" (§3.1); its own ablation shows a mixed effect (QNLI loses 3.5 points without it, the others 0.6 or less), and later work dropped it (How much to believe).
Earlier sentence objectives (Jernite et al. 2017, Logeswaran and Lee 2018) transferred only sentence embeddings; BERT transfers all its parameters (§3.1).
Derived, with an assumption the paper does not state: if the batch stays 256 sequences at length 128, the run sees 0.9 × 106 × 256 × 128 + 0.1 × 106 × 256 × 512 ≈ 42.6 billion token positions, about 13 passes over 3.3 billion words rather than 40 (and WordPiece tokens outnumber words).
BERT was deliberately built as close to GPT as possible so the two could be compared, but four other things differ (A.4): more data, a bigger batch, special tokens learned in pretraining, and a per-task learning rate (numbers in the closed block). The ablations below isolate the objective from these.
BERT was deliberately built as close to GPT as possible so the two could be compared, but four other things differ (A.4): BERT also trains on Wikipedia (GPT: BooksCorpus only); BERT learns [SEP], [CLS] and the segment embeddings in pretraining (GPT adds them at fine-tuning); BERT's batch is 128,000 words against GPT's 32,000, both for 1M steps; and BERT picks a fine-tuning learning rate per task where GPT used 5e-5 for all.
For each task the task inputs and outputs are plugged in and all parameters are fine-tuned end to end; each task gets its own copy, initialised from the same checkpoint (§3, Figure 1). Sentence A and B become a paraphrase pair, a hypothesis-premise pair, a question-passage pair, or a text paired with nothing (classification, tagging). Encoding the concatenated pair with self-attention already includes bidirectional cross-attention between the two, which replaces the separate encode-then-cross-attend stages of earlier pair models (§3.2). The new parameters are tiny (§4, Figure 4): a K × H classifier on C for GLUE; for SQuAD a start vector S and an end vector E, with Pi = eS·Ti / Σj eS·Tj and the best span S·Ti + E·Tj, j ≥ i; under 0.001% of the encoder.
| Task | Output | New parameters (BERT-Large) | Paper's settings |
|---|---|---|---|
| GLUE classification (§4.1) | W ∈ ℝK×H on C; loss log softmax(CW⊤) | K × 1,024 (3,072 for MNLI's 3 labels) | batch 32, 3 epochs, learning rate the best of 5e-5, 4e-5, 3e-5, 2e-5 on dev; several random restarts for Large on small sets |
| SQuAD v1.1 (§4.2) | start vector S, end vector E; Pi = eS·Ti / Σj eS·Tj; span score S·Ti + E·Tj, best with j ≥ i | 2,048 | 3 epochs, 5e-5, batch 32; question as segment A, passage as B |
| SQuAD v2.0 (§4.3) | as v1.1, with "no answer" as a span at [CLS]: answer only if max S·Ti + E·Tj > S·C + E·C + τ, τ tuned on dev | 2,048 | 2 epochs, 5e-5, batch 48, no TriviaQA |
| SWAG (§4.4) | four sequences (sentence plus each ending); one vector scores each C, softmax over the four | 1,024 | 3 epochs, 2e-5, batch 16 |
| NER (§5.3) | a classifier on each word's first sub-token, no CRF | K × 1,024 | case-preserving WordPiece, maximal document context |
New parameters counted from the output layers the paper describes (weights only), against 335M recounted for the encoder: under 0.001%.
Fine-tuning is cheap: every result in the paper "can be replicated in at most 1 hour on a single Cloud TPU, or a few hours on a GPU" from the same pretrained model; the SQuAD model trains in about 30 minutes on one Cloud TPU to 91.0 dev F1 (§3.2, footnote 7).
Across tasks, batch 16 or 32, learning rate 5e-5, 3e-5 or 2e-5 and 2 to 4 epochs work well; data sets with 100k+ labelled examples are far less sensitive to the choice than small ones, and an exhaustive search over the grid is reasonable (A.3).
Measured on 2,000 test sentences (see Run a toy BERT), fine-tuned on 128 labelled sentences, mean of 3 seeds. The same left-to-right model classifies the whole sentence well from its last token, which has read everything: the damage is specific to token-level outputs, as the paper argues for SQuAD.
BERT set a new state of the art on eleven NLP tasks (abstract, §4). Counting the tasks of section 4, they are the eight GLUE tasks reported in Table 1, SQuAD v1.1, SQuAD v2.0 and SWAG; CoNLL NER (§5.3) is not among them.
The headline claim is less any one number than the pattern: the same pretrained checkpoint with a one-layer head beat specialised architectures on sentence-level and token-level tasks alike (§1). Every table is sortable and rebuilt in The paper's tables, rebuilt.
Grey: the previous best the paper compares against; colour: BERT-Large (blue above, orange below). GLUE from §4.1 (official leaderboard score), SQuAD from Tables 2 and 3 (v1.1: an ensemble of 7 with TriviaQA), SWAG from Table 4, NER from Table 7. The axis starts at 70, so read the gaps, not bar lengths.
Pretraining tasks (§5.1, Table 5). BERT-Base is retrained with the same data, fine-tuning and hyperparameters but no NSP, and then as a left-to-right LM with no NSP: "directly comparable to OpenAI GPT, but using our larger training dataset, our input representation, and our fine-tuning scheme". The left-only constraint is kept at fine-tuning, since removing it introduced a mismatch that hurt.
Each bar is a difference of two rows of Table 5 (dev): NSP = BERT-Base − No NSP; bidirectionality = No NSP − LTR & No NSP; + BiLSTM = (+ BiLSTM) − (LTR & No NSP). Derived here; the paper prints the rows.
The left-to-right model is worse on every task, with large drops on MRPC (86.5 to 77.5) and SQuAD (87.9 to 77.8): its token states have no right-side context. A randomly initialised BiLSTM on top, "a good faith attempt at strengthening the LTR system", recovers 7.1 SQuAD F1 but still falls far short, and hurts GLUE.
Training separate left-to-right and right-to-left models and concatenating them, as ELMo does, would be twice as expensive, non-intuitive for QA (the right-to-left model cannot condition the answer on the question) and strictly less powerful than a model that uses both sides in every layer (§5.1).
Model size (§5.2, Table 6). Six sizes from 3 to 24 layers, each fine-tuned with 5 random restarts: bigger is strictly better on all four measures, even on MRPC with 3,600 labelled examples. The authors' hypothesis: fine-tuned directly with very few new parameters, even tiny tasks benefit from bigger pretrained representations.
Earlier feature-based studies had found mixed returns (Peters et al. 2018b: two to four bi-LM layers; Melamud et al. 2016: 200 to 600 hidden units helped, 1,000 did not). For scale, the largest Transformer in Vaswani et al. was L=6, H=1024, A=16 (100M parameters in the encoder) and the largest in the literature L=64, H=512, A=2 (235M, Al-Rfou et al. 2018).
Feature-based BERT (§5.3, Table 7). Frozen features have advantages: some tasks do not fit an encoder, and an expensive representation can be computed once and reused. On NER, frozen BERT-Base features into a two-layer 768-dimensional BiLSTM do nearly as well as fine-tuning: concatenating the top four layers gives 96.1 dev F1, 0.3 behind fine-tuning's 96.4; the input embeddings alone give 91.0.
Masking procedure (C.2, Table 8). Fine-tuning is "surprisingly robust" to the 80/10/10 split (MNLI 83.6 to 84.4 across six mixes). The feature-based NER case, where the representation cannot adapt, shows the mismatch: [MASK] only drops to 94.0 against 94.9, and random only is much worse too.
Training steps (C.1, Figure 5). BERT-Base gains almost 1.0% MNLI going from 500k to 1M steps, and the masked LM, though it converges slightly slower, "begins to outperform the LTR model almost immediately".
The points of Figure 5, decoded from the figure's own vector coordinates in the arXiv HTML (exact to the plot, not read by eye; see tables.json). Read this way the left-to-right model is ahead at 30k and 50k steps (79.4 and 79.8 against 78.6 and 79.6) and the masked LM leads from 100k on; the 500k to 1M gain is 0.8 by linear interpolation between the 400k and 600k points ("almost 1.0%" in the text). The toy's own version is in Run a toy BERT.
What holds up, and why. The headline results are on hidden test sets, scored by the GLUE and SQuAD servers, and BERT-Large's gains over GPT on the accuracy-scored GLUE tasks are between 4.9 and 11.9 standard errors of a difference. The core ablation changes one thing, the objective and its attention mask, with the same data and fine-tuning: going left to right costs 10.1 SQuAD F1 (Table 5). The toy on this page reproduces that direction independently (Run a toy BERT), RoBERTa's reimplementation replicated BERT-Base, and every encoder since keeps the masked LM. Beyond the paper.
The headline results are on hidden test sets, scored by the GLUE and SQuAD servers, and the gains are far larger than the noise of those sets. On the GLUE tasks scored by accuracy, BERT-Large beats GPT by 4.6 points on MNLI-m (9,796 test examples), 5.3 on QNLI, 3.6 on SST-2 and 14.1 on RTE (3,000): between 4.9 and 11.9 standard errors of a difference (Table 1; binomial standard errors from the split sizes of the GLUE release, computed in recompute.py, treating the two systems' errors as independent, which overstates the noise of a paired comparison). The core ablation changes one thing, the objective and its attention mask, with the same data and fine-tuning: going left to right costs 10.1 SQuAD F1, 9.0 on MRPC (3.8 standard errors on its 408 dev examples) and 1.8 on MNLI (3.5) (Table 5). The toy on this page reproduces that direction independently (Run a toy BERT). And it replicated: RoBERTa's reimplementation of BERT-Base, with NSP, reached 90.4 SQuAD v1.1 F1 against the published 88.5, 92.9 on SST-2 against 92.8 and 84.0 on MNLI-m against 84.3 (Liu et al. 2019, Table 2), and every encoder since keeps the masked LM. Beyond the paper.
Where the evidence is weaker.
BERT ended the era of task-specific NLP architectures: after it the default recipe became "pretrain a big Transformer, fine-tune per task", and masked prediction became the canonical self-supervised objective for encoders. A family of descendants followed: RoBERTa (the same model "significantly undertrained"; trained longer on 160GB, without NSP, with dynamic masking), ALBERT, ELECTRA, DistilBERT, DeBERTa and the multilingual XLM-R. The idea leaked beyond text: masked-prediction pretraining underpins vision methods such as BEiT and MAE, and pooled [CLS]-style representations underpin embedding models (Sentence-BERT). It also cemented the GLUE and SQuAD leaderboard culture, and Table 6 was an early clean demonstration that scaling model size keeps paying even on small downstream sets.
Encoders never went away where one cheap forward pass must produce a representation or a label rather than text: embeddings and retrieval (Embedding models), rerankers and late interaction (Rerankers and late interaction), classification and NER. How the encoder, decoder and encoder-decoder families compare today is on Families and objectives.
Decoders won generation, but encoder-only models never went away where one cheap forward pass must produce a representation rather than text: BERT descendants dominate embedding and retrieval stacks (bi-encoders for vector search such as DPR, cross-encoder rerankers such as monoBERT, late interaction in ColBERT), plus classification, moderation and NER at production scale. The recipe was refreshed by ModernBERT (Answer.AI, LightOn and others, December 2024: RoPE, GeGLU, alternating local and global attention, unpadding, 8,192-token context, 2 trillion training tokens; stepped through in Then and now) and the Ettin suite (Johns Hopkins and LightOn, 2025), which trains paired encoders and decoders from 17M to 1B parameters with one recipe and finds, like earlier work, that encoders excel at classification and retrieval and decoders at generation; a 400M encoder beats a 1B decoder continued with MLM on MNLI (Weller et al. 2025). For an AI engineer today, BERT-family models are what you reach for when the task is "represent or label text" rather than "write text".
A real BERT, built as §3 says (learned token, position and segment embeddings; post-LN encoder layers with GELU and a 4H feed-forward; the masked-LM head tied to the token embeddings; a tanh pooler and NSP layer on [CLS]), at toy scale: L = 2, H = 24, A = 4, parameters. It was pretrained on a made-up English with the paper's two objectives and masking rule, then fine-tuned with one output layer, and it runs here in plain JavaScript on its exported weights. Beside it, the same model pretrained left to right (the paper's "LTR & No NSP"), so the paper's central ablation can be run on any sentence you build.
Eight names (austin, paris, jordan, sydney, florence, chelsea, victoria, georgia) are each a person or a place equally often, so the name alone says nothing. Context decides: a cue before the name ("we flew to austin", "i met austin") or a cue after it ("austin is a city", "austin has a cold"). Animal sentences fix the animal by a verb after it (dog barked, cat purred, duck quacked, cow mooed). Pretraining text comes in documents about one entity, so next sentence prediction has something to learn. The fine-tuning task tags each name PER or LOC, like CoNLL NER; half of every cue list is kept out of the labelled data (never out of pretraining), to test what pretraining transfers. Rules: grammar.py, copied in 21_js_lang.js.
Cues marked "held out" never occurred in the labelled fine-tuning data; the models met them only in unlabelled pretraining text. Click a word below to hide it.
Bidirectional: the pretrained BERT's masked-LM head at [MASK] (input "[CLS] sentence [SEP]"). Left to right: the pretrained LTR model's next-word head one position earlier, so it has read only the words to the left. Green is the word you hid.
Both taggers were fine-tuned from their pretrained model with one new 3-way layer on every token, on the same 128 labelled sentences (seen cues only), learning rate chosen on dev as the paper does (§4.1). The left-to-right tagger keeps its causal mask, as in Table 5.
Attention weights from the query word to every position, for each of the 2 layers and 4 heads; the darker the cell, the more weight. In the left-to-right model everything to the right of the query is zero by construction.
Each point is the mean of 3 fine-tuning seeds, each with the learning rate picked on a dev set from 3e-4, 1e-3 and 3e-3 (§4.1's protocol at toy scale), tested on 2,000 sentences drawn from the whole grammar (every cue item, held out of the labels or not). Choose what to measure:
The paper fine-tunes MNLI from checkpoints taken along pretraining (Figure 5). Here the same is done for the tagging task (128 labelled sentences, 3 seeds, all names), from checkpoints of the toy BERT and the toy left-to-right model.
Batch losses every 250 steps, unsmoothed, from model/*.pt. The masked-LM loss counts only the chosen 15% of positions; the left-to-right loss counts every position, so the two are not comparable in level.
Draws fresh sentences from the grammar in this page (a different random stream from the Python test set) and tags them with both shipped taggers.
Every table that carries the argument, transcribed from the arXiv HTML with the printed precision kept (tables.json), and every derived number recomputed by recompute.py.
One point per task; x is the number of training examples printed under each task (log scale). Derived from Table 1. MNLI shows its matched set.
The decomposition into an NSP effect and a bidirectionality effect is in the Ablations question of The paper tab; at toy scale it is run in Run a toy BERT.
Formula in The paper tab (Model and input). Base reproduces the printed 110M independently. Large does not: 335M (336M with the heads) against the paper's 340M, under either vocabulary; ModernBERT's Table 2 prints 330M. The other Table 6 sizes are not printed by the paper; the counts above are this page's.
Dev F1 (the feature-based rows print no test score), averaged over 5 restarts. Fine-tuning BERT-Base reaches 96.4; the best frozen features, the top four layers concatenated, 96.1.
Decoded from the figure's vector coordinates (tables.json, recompute.py): accuracy = 75 + 10 × y / 378.68, steps = 1,000k × x / 536.16. The final masked-LM point, 84.4, equals BERT-Base's MNLI dev score in Tables 5 and 6, a check on the decoding.
The encoder recipe survived, the details did not. Each step makes one change that later work introduced, names the paper, and recounts the model from its configuration. The final step lands on ModernBERT-base's released configuration, which reproduces the paper's stated 149M parameters (Warner et al. 2024, §2.1.3).
Parameters: token embeddings VH, plus 512H learned positions and 2H segments while they exist, plus an embedding norm; per layer, attention 4H² and a feed-forward 2HI (GeGLU: 3HI with I = 1,152), plus biases and norm biases while they exist. "Keys per query" is the average over layers, at the longest context, of how many positions one query attends to.
| Part | BERT (2018) | Now | Introduced or adopted by |
|---|---|---|---|
| Objective | masked LM 15% + NSP; masks fixed in 10 copies of the data | masked LM only, masks drawn fresh, 30% masked | RoBERTa §4.1, §4.2 (drop NSP, dynamic masking); Wettig et al. 2023 (15% is sub-optimal), adopted by ModernBERT |
| Data and length of training | 3.3B words, about 40 nominal epochs | 2 trillion tokens including code (ModernBERT); up to 2T for Ettin | RoBERTa ("significantly undertrained": 160GB, batches of 8K sequences); ModernBERT |
| Positions | learned absolute, 512 | rotary (RoPE), 8,192 context | RoFormer; ModernBERT |
| Norm placement | post-LN, LayerNorm(x + Sublayer(x)) | pre-LN, plus a norm after the embeddings; norms without bias | Xiong et al. 2020; ModernBERT §2.1.1 |
| Feed-forward | GELU, 4H | GeGLU | Shazeer 2020; ModernBERT |
| Attention span | every layer global | global every third layer, a 128-token sliding window otherwise | ModernBERT ("identical downstream performance" to all-global in its ablation) |
| Padding | sequences padded to a fixed length | unpadded: sequences concatenated, variable-length attention | MosaicBERT, GTE, ModernBERT (with FlashAttention, KB page) |
| Survived | the encoder-only Transformer with bidirectional self-attention; masked-token prediction as the pretraining objective; [CLS] and [SEP] special tokens (ModernBERT keeps BERT's templating "facilitating backwards compatibility"); pretrain once, then fine-tune with a small head per task. | ||
Sources quoted in src/inputs/later_extracts.txt; configurations in src/inputs/hf_configs.json. RoBERTa-base's byte-level BPE vocabulary (50,265) "adds approximately 15M" parameters to BERT-Base (RoBERTa §4.4); the recount gives 15.2M.
Every link opens in a new tab. Reading time of the resources below: 3h 20m.
NAACL 2019 (best long paper), the paper itself; the HTML version has the anchors this page links to. abstract page, PDF.
(45 min)
the authors' TensorFlow code and the released checkpoints (repo, about 20 minutes for the README and entry path: modeling.py, create_pretraining_data.py, run_classifier.py).
(20 min)
Jay Alammar: the classic visual walkthrough of how BERT relates to ELMo and GPT and how fine-tuning works.
(30 min)
Answer.AI, December 2024: where the encoder lineage stands today and why it still matters; the paper is arXiv 2412.13663.
(30 min)
Google AI blog, the authors: concise author framing of the contribution, written for the code release.
(10 min)
Liu et al., Facebook AI, 2019: the replication that found BERT undertrained, dropped NSP and made masking dynamic; read sections 4 and 5.
(40 min)
2017: BERT is this paper's encoder stack, transplanted to transfer learning; its page runs a toy of the full encoder-decoder.
2025: paired encoders and decoders trained with one recipe (the ModernBERT one); a controlled comparison of the BERT and GPT lineages.
2020: the rival left-to-right lineage scaled; in-context learning replaced per-task heads for generation.
2020: its dense retriever (DPR) is a pair of BERT encoders; retrieval is the encoder's main living habitat.
2021: rotary positions replaced BERT's learned absolute positions in modern encoders (ModernBERT) as well as decoders.
2019: masked-span denoising carried into an encoder-decoder, every task as text to text.
2024: gives a decoder-only LLM bidirectional attention over the prompt, BERT's argument applied inside a decoder.
2020: the same encoder and a [CLS]-style class token, applied to image patches.
pretraining objectives, transfer learning.
embeddings, bi-encoders, rerankers.
sequence-model history.
This page is one row of the Papers database; its properties (Paper, Takeaway, Topics, Year) live there.