4.3.5 · D3Pretraining & Fine-Tuning LLMs

Worked examples — Self-supervised pretraining objectives

2,272 words10 min readBack to topic

This page is a drill sheet. The parent note built the machinery; here we run that machinery through every kind of input it will ever meet — clean cases, edge cases, degenerate cases, a word problem, and an exam trap. Nothing new is assumed: every symbol we use is re-explained the first time it appears.

Before starting, three symbols you MUST have in hand (all from the parent):


The scenario matrix

Every worked example below is tagged with the cell of this matrix it covers. The goal: leave no cell empty.

# Case class What makes it tricky Example
A Clean CLM, multi-token ordinary averaging Ex 1
B Perfect prediction () limiting value, Ex 2
C Worst prediction () degenerate, loss Ex 2
D Uniform / no-knowledge model , sanity floor Ex 3
E MLM, count only masked which positions enter the sum Ex 4
F MLM 80/10/10 corruption random & unchanged sub-cases Ex 5
G Span corruption (T5) multi-token target, one output seq Ex 6
H Word problem (real training run) tokens ≠ words; Tokenization (BPE) Ex 7
I Exam twist: change log base / compare CLM vs MLM PPL base conversion, fair comparison Ex 8

Example 1 — Clean CLM, multi-token (cell A)


Example 2 — The two limits: perfect and worst prediction (cells B, C)

Figure — Self-supervised pretraining objectives

The red curve above is the per-token loss . Read off the two dots: at it touches zero; as slides left toward it shoots up without bound. That single picture explains cells B and C at once.


Example 3 — The no-knowledge baseline (cell D)


Example 4 — MLM: only masked positions count (cell E)


Example 5 — MLM 80/10/10 corruption (cell F)


Example 6 — Span corruption, one output sequence (cell G)


Example 7 — Word problem: tokens ≠ words (cell H)


Example 8 — Exam twist: log base & fair CLM-vs-MLM comparison (cell I)


Recall

Recall Did every cell get covered?

Which example handled the case where the model assigns probability to the true token? ::: Example 2 (cell C) — loss . Which positions enter the MLM loss sum? ::: Only masked positions (Example 4, cell E); but chosen-unchanged tokens are still scored (Example 5, cell F). Why can't you directly compare a CLM perplexity of 30 to an MLM perplexity of 8? ::: Different tasks — MLM sees future context, so its (pseudo)perplexity is easier and not comparable (Example 8, cell I). Perplexity of a model that knows nothing over vocab ? ::: Exactly (Example 3, cell D).


Flashcards

Per-token loss 1.609 on two tokens with probs 0.4 and 0.1 — perplexity?
, the geometric mean of and .
Loss and PPL of a uniform model over vocab ?
, .
If loss is reported in bits, how do you get perplexity?
, not .
Does the 10% "unchanged" token in BERT contribute to the loss?
Yes — its label is the original token, forcing real representations even without a [MASK].
Per-token loss 3.2 nats, 1.3 tokens/word — per-word PPL?
.