Fill in the SFT JSONL: the three required fields of a typical chat example.
Top-level key is `messages` (an array). Each message has `role` (system/user/assistant) and `content` (the text). One JSON object per JSONL line.
Imagine a script for a short scene. Each line of the script names the speaker and then their dialogue. That is exactly what an SFT chat example looks like on disk, a list of small speaker and line entries. The whole list is wrapped under one heading called messages because a conversation is a sequence of messages. Each message inside carries two fields, who is talking (role) and what they are saying (content). The trainer reads through the script and uses the speaker labels to figure out which lines it should grade the model on, the assistant lines, and which lines are just context.
Detailed answer & concept explanation~6 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.
5 min: the three fields (messages, role, content) + JSONL one line per example + why no prompt/completion split + role tags drive masking + how loaders consume the shape + Anthropic vs OpenAI variants.
| Field | Position | Purpose |
|---|---|---|
| messages | Top-level key | Wraps the array of conversation turns |
| role | Inside each message | Identifies the speaker (system/user/assistant/tool) |
| content | Inside each message | The actual text of that turn |
Real products, models, and research that use this idea.
- OpenAI fine-tuning endpoint accepts exactly the `{messages: [{role, content}, ...]}` shape, one example per line in a JSONL file.
- Hugging Face TRL SFTTrainer auto-detects this shape and applies the model's chat template for prompt masking.
- Axolotl's chat_template config option triggers the same JSONL parsing across Llama, Mistral, Qwen, and DeepSeek base models.
- Mistral's fine-tuning API uses this format directly; their docs show the same three-field structure.
- ShareGPT and Alpaca datasets are routinely converted to this format before training; community tooling does the conversion in a few lines.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does the trainer not need a separate prompt and completion split when consuming this format?
QHow does Anthropic's chat format differ from this OpenAI-compatible shape?
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.
Trying to add a separate `prompt` and `completion` split next to the messages array. The trainer derives which spans to grade from the role tags; no extra split is needed.
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.