# Loss Masking: The Real Implementation of 'Loss Only on Response'

> Source: https://sukruyusufkaya.com/en/learn/fine-tuning-cookbook/ftc-loss-masking-implementation-real
> Updated: 2026-05-14T14:42:50.539Z
> Category: Fine-Tuning Cookbook (Model-by-Model)
> Module: Part II — Tokenizer & Data Engineering
**TLDR:** Loss masking is the cornerstone of SFT. How IGNORE_INDEX=-100 interacts with PyTorch CrossEntropyLoss, how instruction tokens are masked while response is kept, source-code reading of Unsloth's train_on_responses_only, turn-by-turn masking in multi-turn conversations, edge cases.

