Preparing Fine-Tuning Datasets

Collect, clean, format and split training examples; data quality matters far more than quantity.

Intermediate · about 5 hours · difficulty 3/5

Learn first: Prompting vs RAG vs Fine-Tuning, Building Golden Datasets

A fine-tuned model learns exactly what your data shows it, including mistakes. Most of the work in fine-tuning is data work.

Formats

  • Supervised fine-tuning (SFT) uses input and ideal output pairs, usually as chat-format JSONL: a list of messages with system, user and assistant roles.
  • Preference data uses a prompt plus a preferred and a rejected response, for methods like DPO.
  • Match the format your training tool or provider expects exactly, including any chat template.

Sources

  • Logged production outputs that humans reviewed or corrected.
  • Expert-written examples for the hardest cases.
  • Outputs from a larger model that you filter for quality (this is distillation, covered next).

Quality checklist

  • Consistency: examples should agree with each other on format and style. Contradictions teach confusion.
  • Coverage of the real input distribution, including edge cases and refusals.
  • Deduplication and removal of near-duplicates.
  • PII scrubbing and licence checks on anything you did not write.
  • Held-out eval split never seen during training, and ideally your existing golden set.

How much data?

A few hundred high-quality examples can shift format and style; complex tasks may need thousands. Start small, train, evaluate, then add data targeted at the failure categories you see.

Good enough to move on

You can produce a clean, deduplicated chat-format JSONL dataset with train and eval splits and a short data card describing its sources and known gaps.

Key concepts

  • Chat-format JSONL
  • SFT vs preference data
  • Sourcing examples
  • Consistency and deduplication
  • Chat templates
  • Train and eval splits
  • Data cards

Mini project

Turn 500 logged support replies into a fine-tuning dataset: filter to human-approved answers, deduplicate, scrub PII, convert to chat JSONL, and hold out 50 for evaluation.

Check yourself

Half your examples end with a sign-off and half do not. What will the fine-tuned model likely do?

Free resources