Supervised fine-tuning, or SFT, trains a pretrained model on labeled input-output pairs so it learns to follow instructions or reproduce a target behavior through ordinary next-token prediction loss on the desired responses. The data format is typically a set of conversation-style records, each containing a system message that sets context or role, one or more user turns, and the assistant turn the model should learn to produce, structured in a chat template such as ChatML or the ShareGPT conversations array so the tokenizer applies the same special tokens used at inference time. For single-turn tasks a simpler instruction, input and output structure like the Alpaca format is common and easier to generate at scale. Consistency matters more than format choice, since mixing templates or forgetting to mask the loss on prompt tokens during training are common sources of degraded quality. Most frameworks compute loss only on the assistant response tokens, not on the system or user turns, to avoid teaching the model to predict its own instructions. Nanobase AI prepares and validates SFT datasets in the exact template the target model and serving stack expect.

Why the same format choice matters more than which format

Every SFT data format, whether ChatML, ShareGPT, or Alpaca, ultimately serves the same purpose: presenting the model with a clear boundary between what it should treat as context and what it should learn to generate. What breaks training is not the specific format chosen but inconsistency within a dataset, such as mixing templates across examples or drifting from the exact template the target base model was originally instruction-tuned with. A model trained on a mismatched template can still learn something, but it will apply that learning less reliably at inference time, when the serving stack applies the template the model actually expects.

Consistency with the target model's native chat template matters more than which named format a dataset technically follows.

The loss-masking mistake that quietly degrades quality

The most common and least visible SFT bug is computing loss across the entire sequence, including the system and user turns, rather than masking those tokens out and training only on the assistant's response. Without masking, the model spends part of its training budget learning to predict its own instructions and the user's questions, which is not the intended objective and dilutes the signal that should be teaching the target behavior. Most modern training frameworks handle this masking automatically when given properly labeled conversation data, but a manually built data pipeline can silently skip this step.

Masking approachWhat the model learns fromEffect on training
No masking (loss on full sequence)System prompt, user turn, and response, all weighted equallyDiluted signal, wasted training budget
Correct masking (loss on assistant tokens only)Only the target responseFull training signal on the actual objective

Verifying that loss masking is applied correctly before a training run starts is a five-minute check that prevents a quality problem that is otherwise hard to diagnose after the fact.

Choosing a structure for single-turn versus multi-turn tasks

Single-turn tasks such as classification, extraction, or short-answer generation are well served by a simple instruction, optional input, and output structure, since there is no conversation history to represent and a simpler structure is easier to generate and validate at scale. Multi-turn tasks, such as a support assistant that must track context across several exchanges, need a structure that represents a full conversation as an ordered list of turns, since training only on isolated single exchanges will not teach the model to use prior context correctly. Getting this structural choice wrong for the task, such as training a multi-turn assistant on single-turn pairs, produces a model that answers each message in isolation and ignores conversation history it was never shown during training.

Match the data structure to whether the production task is genuinely single-turn or multi-turn, since this shapes what the model learns to attend to.

A pre-training data validation checklist

  1. Confirm every example follows the same chat template the target base model expects at inference.
  2. Confirm loss masking excludes system and user tokens and applies only to assistant response tokens.
  3. Check for truncated examples where the response was cut off by a fixed sequence length limit.
  4. Deduplicate near-identical examples that would otherwise be weighted more heavily than intended.
  5. Spot-check a random sample of tokenized examples to confirm the tokenizer applied special tokens as expected.

Running this checklist before launching a full training job catches the majority of SFT quality problems before they consume GPU-hours on a flawed dataset.

A five-minute pre-training check catches formatting and masking bugs that would otherwise be diagnosed only after a confusing evaluation result.

Frequently asked questions

Does the choice between ChatML, ShareGPT, and Alpaca affect final quality?

Less than consistency does. Any of these formats works well when applied consistently and matched to the target model's expected template; mixing formats within one dataset or ignoring the model's native template is the bigger risk.

Can SFT data include multi-turn examples with tool calls?

Yes, most current frameworks support representing tool or function calls as part of the conversation structure, provided the format matches what the target model and serving stack expect for tool use.

What happens if system prompts vary across training examples?

This is fine and often desirable, since it teaches the model to condition its behavior on different system instructions. What must stay consistent is the template structure itself, not the specific content of each system message.

How long should SFT training sequences be?

Long enough to include the full instruction and response without truncation, but not so long that most examples are heavily padded, which wastes compute. Setting sequence length based on the actual distribution of example lengths avoids both problems.

How Nanobase AI helps

Nanobase AI prepares and validates SFT datasets in the exact template the target model and serving stack expect, including the loss-masking and structural checks described here, before any training run begins. This catches the quiet formatting mistakes that otherwise show up only as unexplained quality gaps after training. See our solutions or the RAG versus fine-tuning decision guide for related architecture context.

Ready to discuss your project? Contact Nanobase AI or email hello@bumu.tech.