4.3.2 · D5Pretraining & Fine-Tuning LLMs

Question bank — BERT and encoder models

1,567 words7 min readBack to topic

Notation and pieces you need first

Before the traps, here is every symbol and special token used below, defined once so nothing surprises you.

Figure — BERT and encoder models
Figure — BERT and encoder models

True or false — justify

Every position in a BERT input contributes to the MLM loss.
False — only the masked positions (the set ) are graded; visible tokens contribute nothing, since scoring a token the model can literally see teaches nothing and leaks the answer.
BERT's attention uses a causal mask like GPT does.
False — BERT is bidirectional with no causal mask; the whole point is that each token sees left AND right context. See GPT and decoder models for the causal variant.
Removing NSP always hurts BERT's performance.
False — RoBERTa showed NSP is often useless or slightly harmful; training MLM alone on more data does better, so NSP is optional and MLM is load-bearing.
The [CLS] vector is a good sentence embedding straight after random initialization.
False — its usefulness comes from NSP and fine-tuning training pressure; a raw untrained pooled vector is not automatically a good sentence summary (this is why sentence-BERT exists).
In MLM, exactly 15% of chosen tokens are replaced with [MASK].
False — 15% of tokens are chosen, but of those only 80% become [MASK]; 10% become a random token and 10% are left unchanged.
BERT masks whole words and predicts them one at a time, left to right.
False — it masks 15% of sub-word tokens (WordPiece pieces) and predicts them all at once from full context — no autoregressive loop.
Softmax over the vocabulary is used because we need a probability distribution over possible tokens.
True — softmax turns raw logits (linear scores ) into non-negative numbers summing to 1, so we can ask "how probable is the true token ?" and then minimize its negative log (Cross-Entropy Loss).
Position embeddings are optional because attention already knows word order.
False — self-attention is permutation-invariant (a bag of tokens), so "dog bites man" and "man bites dog" would be identical without an injected position vector.
Fine-tuning retrains the whole model from scratch on the new task.
False — pretraining is done once; fine-tuning adds a tiny head (often one linear layer) and trains briefly, because already encodes rich meaning (see Fine-Tuning vs Pretraining).

Spot the error

"MLM loss over all tokens."
The average must be over (masked positions) not ; unmasked tokens are excluded entirely from the sum and the denominator.
"We always use [MASK] because it's the cleanest signal for 'predict me'."
[MASK] never appears at inference time; a [MASK]-only scheme creates a train/test mismatch, so 10% random + 10% unchanged force good representations for every token.
"BERT can generate a paragraph by sampling one token at a time."
BERT is encoder-only with no left-to-right generation loop; it fills fixed-length masked slots. Use GPT and decoder models or T5 and encoder-decoder models for generation.
"NSP predicts the next word, so it overlaps with MLM."
NSP predicts a binary IsNext / NotNext relation between two whole sentences from ; it is a sentence-pair classification, unrelated to word-level prediction.
"Each token embedding is just the token vector fed to attention."
Three embeddings are summed per token — token + position + segment (A vs B) — before entering the encoder stack.
"Since attention is bidirectional, we can safely train BERT on next-token prediction."
With bidirectional attention the model can attend to the very token it must predict — it cheats. That's exactly why BERT needs the cheat-proof MLM objective instead.
"The [SEP] token separates the two pretraining objectives."
[SEP] separates sentence A from sentence B inside one input; it has nothing to do with which loss (MLM vs NSP) is computed.

Why questions

Why does the 80/10/10 corruption rule actually help learning?
Because the model can never be sure whether a given token is corrupt, it is forced to build a good contextual representation for every token — that uncertainty is the training signal, not a side effect.
Why is [CLS] (not the average of all tokens) used for sentence classification?
During pretraining [CLS] was fed to NSP, so its vector learned to aggregate whole-sentence information; fine-tuning then reuses that summarizing habit for a single sentence-level decision.
Why can't a single-sentence MLM objective teach sentence-relationship tasks like entailment?
MLM only conditions on within-sentence context; tasks like QA or entailment need to compare two sentences, which is why NSP (or its replacements) was added to expose cross-sentence signal.
Why is minimizing negative log-probability the same as maximizing probability?
is a monotonically decreasing function, so making larger makes smaller; minimizing the loss and maximizing the true-token probability are the identical optimization.
Why does BERT build a "universal" representation that transfers to many tasks?
MLM forces it to model general bidirectional context across a huge corpus; that broad linguistic knowledge lives in , so downstream heads only learn a small task-specific mapping on top.

Edge cases

What happens to the MLM loss if a sentence has zero masked tokens?
The set is empty, so is undefined/zero for that example — nothing is graded; in practice at least one token is always masked so this is avoided.
If a chosen token falls in the "10% unchanged" bucket, is it still graded?
Yes — it is still in , so the model must predict it correctly from context even though the input looks identical; only the input corruption differs, not the loss membership.
For a single-sentence task, is the segment embedding meaningless?
There is only segment A, so every token gets the same segment-A vector — it adds a constant and effectively drops out, which is fine; segment embeddings only matter for two-sentence inputs.
What if sentence B in NSP is a random sentence that happens to be topically plausible?
The label is still NotNext because it wasn't the actual following sentence; NSP grades true adjacency, not topical similarity, which is part of why the signal is weak enough for RoBERTa to drop it.
At inference on a downstream task, how many [MASK] tokens appear in the input?
Zero — masking only happens during MLM pretraining; at fine-tuning/inference the real tokens are all present, which is exactly the mismatch the 80/10/10 rule protects against.
If you feed BERT a sequence longer than its trained position range, what breaks?
There is no learned position embedding for those extra slots, so order information beyond the max length is undefined — the model can't place those tokens correctly.