Why does completion-only loss usually outperform full-sequence loss on the same SFT data?
Completion-only loss masks the prompt so gradient flows only into response tokens. Full-sequence loss wastes gradient teaching the model to predict text the user already typed.
Imagine teaching a student to write replies to emails. If you grade them on every word, including the original email they received, half their effort goes into copying back the sender's words instead of writing the reply. So you cover the original email with a sticky note and grade only the reply they actually wrote. Same homework, same time, same effort, but now every red pen mark falls on the part that matters. The student gets better at replies twice as fast. Completion-only loss is exactly that sticky note: it hides the prompt from the grading pen so every correction lands on the response.
Detailed answer & concept explanation~7 min readEverything 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. 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: loss masking mechanism + identical forward and attention + prompt-fraction sizing + gradient reallocation + distractor refutation + multi-turn handling + when full-sequence still helps.
Real products, models, and research that use this idea.
- TRL's `SFTTrainer` defaults to completion-only loss via `DataCollatorForCompletionOnlyLM`, masking prompt token labels to -100 before cross-entropy.
- Axolotl exposes a `train_on_inputs: false` flag (the default) that implements completion-only masking on the chat template's response span.
- LLaMA-Factory's SFT recipes apply completion-only by default; switching to full-sequence requires an explicit config override.
- OpenAI and Anthropic fine-tuning APIs implicitly use completion-only loss; the documentation specifies that loss is computed on assistant turns only.
- Llama 4 and Qwen 3.5 instruction-tuning ablations published in 2026 report 1 to 3 point gains on MT-Bench and IFEval from switching full-sequence to completion-only on the same SFT mix.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does completion-only often help more on long-prompt datasets than on short-prompt datasets?
QWhen might full-sequence loss actually be preferable to completion-only?
QHow does completion-only interact with multi-turn chat templates?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming completion-only changes the forward pass or attention. It does not. The full sequence still runs through the model; only the loss aggregation masks out prompt-token positions before backward.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.