Simple definition#
Dataset engineering is the work of producing the data a model is trained or evaluated on: deciding what data you need, getting it, generating it when you cannot get it, and cleaning it into a usable format.
As models become commodities, data becomes the differentiator. Two teams using the same base model are separated mostly by the quality of their instructions, examples, preferences and evaluation sets.
What data are we talking about?#
| Purpose | Shape of the data |
|---|---|
| Supervised fine-tuning | (instruction, response) pairs; multi-turn conversations |
| Preference fine-tuning | (prompt, preferred response, rejected response) |
| Reasoning | Problems with step-by-step solutions (chain-of-thought) |
| Tool use | Conversations including tool calls, arguments and results — often hard to collect from humans, because people use tools differently from agents |
| Evaluation | Inputs with expected outputs, rubrics or reference answers — see evaluating AI systems |
| Retrieval | Queries with relevant documents, for embedding and reranker tuning |
Single-turn data teaches answering; multi-turn data teaches clarification, follow-up and correction. Most real applications need both.
Data curation: quality, coverage, quantity#
Quality#
High-quality examples are:
| Property | Meaning |
|---|---|
| Relevant | Match the task and domain you will serve |
| Aligned with task requirements | Follow the format, policy and style the product needs — a correct but off-format answer is a bad example |
| Consistent | Annotators agree; the same input gets the same label |
| Correctly formatted | No stray HTML, broken encodings, truncated responses |
| Sufficiently unique | Few duplicates, which distort training and contaminate evaluation |
| Compliant | Licensed for use, free of personal data you cannot keep |
Coverage#
Data must span the range of inputs the product will see: topics, lengths, languages, user expertise, phrasing styles, edge cases and adversarial inputs. Missing a slice in training shows up as a failure for that slice in production.
Mix matters too. If 80% of your traffic is billing questions, training on 80% technical questions skews behaviour. Experiment with mixes and measure per-slice quality.
Quantity#
How much you need depends on:
- Technique — full fine-tuning needs more data than LoRA; a strong base model needs less.
- Task complexity — classification needs less than open-ended generation or reasoning.
- Base-model fit — the closer the base model already is, the less you need.
Run a data scaling experiment: train on 25%, 50% and 100% of your data and plot quality. If the curve is still rising, more data will help; if it has flattened, invest elsewhere.
Acquisition and annotation#
The best source is usually your own application — real user queries, corrections and feedback (see user feedback). Other sources: public datasets (check licences), purchased data, and annotation by experts or vendors.
Annotation is mostly a guidelines problem. Write clear rubrics with examples of good and bad responses; the same guidelines later become your evaluation rubric. Measure inter-annotator agreement and resolve disagreements before scaling up.
Data augmentation and synthesis#
Synthetic data is used to increase quantity, increase coverage (rare cases, adversarial inputs), improve quality (better than average human writing for some tasks), protect privacy (realistic data without real customers) and distil models.
Traditional techniques#
| Technique | Example |
|---|---|
| Rule-based / templates | Generate transactions, forms or invoices from templates and value lists |
| Perturbation | Paraphrase, swap entities, add typos and noise to make models robust |
| Simulation | Simulate environments — robotics, game play, tool use — and record trajectories |
AI-powered synthesis#
Models can generate inputs, outputs, or both:
- Instruction synthesis — generate diverse instructions from seed topics, then responses to them.
- Reverse instruction — start with high-quality human content (an article, code) and ask a model to write the instruction it answers; the response stays human-quality.
- Self-play and role-play — models simulate users, customers or opponents to create multi-turn data.
- Long-context data — split long documents and generate questions that require the whole document.
flowchart LR
S["Seed topics,<br/>real examples,<br/>documents"] --> G["Generate<br/>instructions + responses<br/>with a strong model"]
G --> V{"Verify"}
V -->|"functional checks<br/>(code runs, math checks)"| K["Keep"]
V -->|"AI judge scores<br/>above threshold"| K
V -->|"fails / duplicate /<br/>off-policy"| X["Discard"]
K --> D["Deduplicate<br/>and balance"]
D --> H["Human spot-check<br/>sample"]
H --> T["Training set"]
Verifying synthetic data#
Generated data is only as useful as its verification:
- Functional correctness — run code, check math, validate JSON against a schema.
- AI judges — score quality, faithfulness and policy compliance; keep the top slice.
- Heuristics — remove repetitive examples, instructions that are too long or short, identical instructions with conflicting responses, outputs that just repeat the input.
- Human review of a sample — always.
Limits of synthetic data#
Model distillation#
Distillation trains a smaller student model to imitate a larger teacher. In practice for LLMs this usually means: use the teacher to generate (or label) training data, then fine-tune the student on it.
It is the standard route to a cheap, fast model for a narrow task: the teacher sets the quality bar, the student meets it at a fraction of the serving cost. Evaluate the student against the teacher on your evaluation set, especially on hard cases, where students tend to fall short.
Data processing#
Processing is unglamorous and decisive. Do it in this order:
| Step | What to do |
|---|---|
| 1. Inspect | Read samples. Plot distributions of lengths, topics, languages, sources and annotators. Look for outliers and surprises — most data problems are visible within an hour of reading |
| 2. Deduplicate | Remove exact and near duplicates within the training set and between training and evaluation sets (contamination). Methods: pairwise similarity for small sets, hashing (MinHash, locality-sensitive hashing), embedding similarity |
| 3. Clean and filter | Strip formatting artefacts; remove personal data, toxic content, low-quality and non-compliant examples; filter by quality scores or heuristics |
| 4. Format | Convert to the exact chat template and tokenizer format the base model expects; a wrong template silently degrades fine-tuning |
Keep each step scripted and versioned, so a dataset can be rebuilt and audited — part of AI governance.
Common mistakes#
Review questions#
What makes training data high quality? It is relevant to the task, aligned with the required format and policy, consistent across annotators, correctly formatted, sufficiently unique and legally usable.
How do you decide how much data you need? Run a data scaling experiment — train on increasing subsets and watch the quality curve. Needs fall with stronger base models, simpler tasks and parameter-efficient methods.
Why use synthetic data, and what are its risks? It adds quantity and coverage, can improve quality, protects privacy and enables distillation. Risks are uncaught errors, superficial imitation, model collapse from recursive training and unclear lineage.
What is model distillation? Training a smaller student model on outputs from a larger teacher, so the student approaches the teacher’s quality on a task at much lower serving cost.
Why deduplicate between training and evaluation sets? Duplicates contaminate the evaluation: the model is tested on what it was trained on, so scores overstate real-world quality.
Summary#
- Data is the differentiator when models are commodities; quality and coverage beat volume.
- Know the data shape you need: instructions, preferences, reasoning, tool use, evaluation.
- Synthesise to fill gaps — but verify functionally, with judges and with humans.
- Distil large models into small ones for narrow tasks.
- Inspect, deduplicate, clean, filter and format — scripted and versioned.
References#
- Chip Huyen, AI Engineering, O’Reilly, 2025 — chapter 8.
- Zhou et al., LIMA: Less Is More for Alignment, 2023.
- Shumailov et al., The Curse of Recursion: Training on Generated Data Makes Models Forget, 2023.
- Gudibande et al., The False Promise of Imitating Proprietary LLMs, 2023.
- Li et al., Self-Alignment with Instruction Backtranslation, 2023.