Which loss function does supervised fine-tuning actually minimize?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Supervised fine-tuning minimizes token-level cross-entropy on the response tokens, the same objective the base model was pretrained with, just on a smaller curated set.
Imagine teaching someone to copy a famous handwriting sample one letter at a time. At each letter you cover the answer, ask them to guess the next stroke, then reveal the correct one. The lesson scores how surprised they were by the actual letter: very surprised is a big penalty, perfectly expected is a small one. They keep practicing until their guesses match the handwriting closely. SFT works the same way with words. The model reads a prompt, then one word at a time tries to predict the next word in the ideal response. The loss is the surprise score, summed over every word in the response. The system and user prompts are not scored, only the answer is, because the answer is what you are teaching the model to write.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: name token level cross-entropy with masking, write the formula, explain teacher forcing, contrast with DPO and PPO losses, and call out the chat-template masking bug as the common production failure mode.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Conflating the SFT loss with the DPO pairwise loss or the PPO KL term. SFT is plain next-token cross-entropy on a single ideal response, with no pair, no reference, and no reward model.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.