Skip to content

Preparing Data for Fine-Tuning Language Models

How to collect, format, clean and split examples for fine-tuning an LLM on your task.

Editorial team 1 min read

Fine-tuning results depend mostly on data quality. A few hundred excellent examples often beat thousands of mediocre ones.

Collect Representative Examples

Gather real inputs your application will see, covering common cases, edge cases and difficult ones.

Write High-Quality Outputs

Each output should be exactly what you want the model to produce: correct, well formatted and in the right style. Inconsistent outputs teach inconsistent behaviour.

Format

Most providers use conversation-style formats with system, user and assistant messages, typically in JSON Lines files. Follow the exact format your provider or library requires.

Clean

  • Remove duplicates and near-duplicates.
  • Fix errors and inconsistencies.
  • Remove personal data and secrets.
  • Balance categories where relevant.

Split

Keep a held-out test set, never used for training, to measure improvement honestly.

Start Small

Fine-tune on a small set, evaluate, find weaknesses, and add targeted examples.

Synthetic Examples

Language models can help draft examples, but review them carefully — they can introduce subtle errors and repetitive patterns.

More in Data for AI

All Data for AI guides →
Data for AI Guide · 1 min

How to Read a Dataset Card

The questions a dataset card should answer — what one row is, where the data came from, its licence and its quirks — before you use it.

Data for AI 1 min read 5 Apr 2026

Data for AI Guide · 2 min

Data Quality Dimensions

Accuracy, completeness, consistency, timeliness, validity and uniqueness: a framework for checking whether data is fit for purpose.

Data for AI 2 min read 4 Apr 2026

Data for AI Guide · 2 min

Handling Missing Data

Why data goes missing, how to find out, and the options — dropping, imputing, flagging — with their trade-offs.

Data for AI 2 min read 3 Apr 2026

Data for AI Guide · 2 min

Detecting and Handling Outliers

How to spot unusual values, decide whether they are errors or genuine extremes, and treat them appropriately.

Data for AI 2 min read 2 Apr 2026