Log inStart free
LESSON 12.01 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Supervised fine-tuning and loss masking

Watch a pretrained model learn to answer when the loss counts only the response.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 12.01 · FINE-TUNING BAYPRETRAINED · WRITES "WHAT COLOR IS THE"
01
Stage 1 of 6 · Pretrained model
The pretrained model reads the prompt. It writes more question words, not an answer.
Explain it simply

This model learned from plain text, so it knows that the sky is blue. But it never saw a chat. After the word bot, it writes more question words in the dotted chips. The bars below show its chance for each next token: blue gets only 0.0029, and what gets 0.22.

Eight teal prompt tokens go into the model. It writes "what, color, is, the" in dotted chips. Bars show the chance of each next token; blue gets 0.0029.

tokensweightslabels and outputlossmasked
E embeddings60 weightsW1 layer 120 weightsW2 layer 220 weightsU output75 weightsprompt: the user's turnthe pretrained model writesuserwhatcoloristhesky?botwhatcoloristhe0.20theskygrasssnowis0.0029bluegreenwhite0.11.0.22what0.14color0.18?userbot<end>next-token chancespretrained, after bottop: what 0.22target blue: 0.0029the pretrained modelE embeddings60 weightsW1 layer 120 weightsW2 layer 220 weightsU output75 weightsprompt: the user's turnthe pretrained model writesuserwhatcoloristhesky?botwhatcoloristhe0.20theskygrasssnowis0.0029bluegreenwhite0.11.0.22what0.14color0.18?userbot<end>next-token chancespretrained, after bottop: what 0.22target blue: 0.0029the pretrained model
Toy: a 2-layer model, 15 tokens, 175 weights, 3 chat pairs
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x^8=arg⁡max⁡v pθ(v∣x0..7)\sy{y}{out}{\hat{x}_{8}} = \arg\max_{v}\, p_{\sy{w}{param}{\theta}}(v \mid \sy{x}{data}{x_{0..7}})
x^8=what, p=0.22\hat{x}_{8} = \text{what},\ p = 0.22

The model writes its most likely next token.

Common mix-ups

MYTHThe loss mask hides the prompt from the model.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At 0 training steps, does the model answer the question after "bot"?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.