Dataset Formats
The three canonical dataset formats, the one right way to apply a chat template, and the five-second inspection loop that catches every silent formatting bug before it costs you a training run.
There are exactly three canonical dataset formats — raw messages, instruction/response, and ShareGPT — and all three normalize to a single `messages` column. One internal representation, one conversion, one bug surface.
Always apply the model's chat template with `apply_chat_template`. Never hand-concatenate strings. Hand-concat is the #1 silent bug in fine-tuning: token-boundary errors, special-token merging, wrong role tokens. Loss still drops; the model is subtly worse.
Decode the tokenized `input_ids` and read the result before training. The decoded text is the ground truth of what the model sees. Every format bug — missing EOS, trailing spaces, specials-as-text — is visible here; none is visible in loss curves.
SFT data (one response) and preference data (chosen/rejected) are structurally distinct. The shape signals the objective; mismatching them silently trains the wrong objective.