Level 3 In-Depth AI · ML Engineering and Production
Synthetic Data
Training data made by programs and models instead of collected from the world. How LLMs generate instructions, textbooks and reasoning traces for other models, why filtering and verification matter more than generation, and the risk of model collapse when models learn mostly from their own output.
- Level
- ●●●●● Intermediate
- Reading
- 12 min
- To learn it well
- 45 minutes to read, an afternoon to practise
- Builds on
- 35 concepts →
- Quiz
- 4 questions ↓
This leads to
—The full path from zero — 35 concepts before this one
- What Is AI?
- Vectors
- Derivatives and Slopes
- Probability Basics
- Python for AI
- How Machines Learn
- Partial Derivatives and Gradients
- Matrices and Matrix Multiplication
- The Chain Rule
- Dot Product, Norms and Similarity
- Pandas and Working with Data
- Tokenization
- Supervised, Unsupervised and Reinforcement Learning
- Gradient Descent
- Data Cleaning and Preparation
- Language Modeling and Next-Token Prediction
- Supervised Learning
- Data Pipelines and Datasets
- Linear Regression
- The Perceptron
- Logistic Regression
- Neural Networks
- Recurrent Neural Networks
- Backpropagation
- Activation Functions
- Vanishing and Exploding Gradients
- Normalization Layers: BatchNorm and LayerNorm
- LSTMs and GRUs
- Residual Connections
- Sequence-to-Sequence Models
- Attention
- Self-Attention and Multi-Head Attention
- Positional Encodings
- The Transformer
- GPT and Decoder-Only Models
- Synthetic Data
Read them roughly in this order. See it on the concept map →
Why it matters
Good training data is scarce and expensive. Human labels cost money and time (Data Pipelines and Datasets). Some data is private (medical records), dangerous to collect (car crashes), or simply rare (fraud, unusual diseases, hard maths problems). And the supply of high-quality public text on the web is finite: models are already trained on a large share of it (Pretraining Large Language Models).
Synthetic data is training data produced by a program or a model rather than collected from the real world. It is old in some forms: flight simulators, rendered images for robots, oversampling methods such as SMOTE (Data Cleaning and Preparation). Large language models changed its scale. A strong model can write millions of instructions, answers, explanations, conversations and reasoning traces cheaply, and these can teach other models.
Much of how today's assistants are built depends on it. Most Instruction Tuning and Chat Models datasets are partly or wholly generated. Reasoning skills are often taught through model-written solutions that were checked automatically (Reasoning Models and Test-Time Compute). Small models are improved with data written by larger ones (Knowledge Distillation and Small Models). AI-written feedback replaces some human feedback in RLHF and Preference Optimization. Synthetic data is now one of the main levers in building a model, and its pitfalls are real.
The intuition
Think of a teacher writing practice exercises. A good teacher can produce endless variations of a problem, at exactly the right level, covering the cases students get wrong. That beats waiting for exam questions to appear in the wild. But the exercises are only as good as the teacher. Mistakes in the answer key get learned as facts. A teacher who only writes the kinds of problems they like leaves gaps. And a class taught only from the previous class's notes, generation after generation, slowly forgets everything that wasn't in the notes.
Synthetic data works best as a loop with strong quality control:
Key idea Generating data is easy; generating good data is the whole job. The value of synthetic data comes from the filter: checks that keep correct, diverse, useful examples and throw away the rest. Always keep real data in the mix and evaluate on real data.
How it works
Kinds of synthetic data
- Simulation and rendering. Physics engines and game engines produce labelled images, sensor readings and driving scenarios, including rare events. The labels are perfect because the program knows the scene. The risk is a gap between simulation and reality.
- Augmentation and resampling. Transforming real examples (crops, noise, paraphrases) or interpolating between them (Data Augmentation). This stays close to the real data.
- Model-generated data. A model writes new examples from scratch, guided by prompts. This chapter focuses on this, mostly for language models.
From seed to dataset
The basic recipe has four steps.
- Seed. Start with seed data: a small set of hand-written examples, a list of topics, personas or skills, or real documents to build questions about. Seeds control coverage. Diversity in, diversity out.
- Generate. Prompt a capable model to produce new examples similar to, but different from, the seeds. Vary the prompts (topic, difficulty, style, persona, format) to avoid producing thousands of near-copies.
- Filter. Remove duplicates and near-duplicates. Check correctness wherever a check exists. Score quality with a judge model or a classifier. Remove anything that overlaps the test sets you will evaluate on.
- Train and evaluate on real data. The only honest test of synthetic data is whether the model trained on it does better on real, held-out data.
Self-instruct (Wang et al., 2022) is the classic example. Starting from 175 hand-written seed tasks, the authors had GPT-3 write new instructions, inputs and outputs, filtered out near-duplicates and malformed examples, and fine-tuned GPT-3 on the result. It improved substantially at following instructions. Stanford's Alpaca (2023) applied the recipe with OpenAI's text-davinci-003 to make 52,000 instruction examples for fine-tuning Meta's LLaMA 7B. The authors reported that generating the data cost under 500 US dollars. Evol-Instruct (WizardLM, 2023) asked a model to rewrite instructions into progressively harder and more varied versions.
Data for pretraining
Synthetic data can also teach knowledge and skills from the start. Textbooks Are All You Need (Gunasekar et al., Microsoft, 2023) trained phi-1, a 1.3-billion-parameter coding model, partly on about a billion tokens of synthetic textbooks and exercises written by GPT-3.5, and reported 50.6% on the HumanEval coding benchmark, high for its size at the time. TinyStories (Eldan and Li, 2023) generated short stories using only words a young child knows, and showed that models with only a few million parameters trained on them could write fluent, consistent English. Hugging Face's Cosmopedia (2024) released over 25 billion tokens of synthetic textbooks, blog posts and stories generated by Mixtral-8x7B-Instruct.
Verification beats judgement
The most reliable synthetic data has an automatic check:
- Maths with a known final answer: compare it.
- Code with tests: run them.
- Structured outputs: validate against a schema (Structured Output and JSON).
- Tool use: execute the call and check the result.
This enables rejection sampling: generate many candidate solutions per problem, keep only those that pass the check, and train on the survivors. STaR (2022) used it to teach models to reason, and it is central to building Reasoning Models and Test-Time Compute. DeepSeek reported distilling about 800,000 such curated samples from its R1 reasoning model into smaller open models.
Where no automatic check exists (essays, advice, summaries), teams use LLM-as-judge scoring against a rubric, reward models, or agreement between several generations. These are weaker filters. Judges share the generator's blind spots and prefer outputs that sound like themselves. Spot-check samples by hand.
Feedback as synthetic data
Preference data, the "A is better than B" judgements used in RLHF and Preference Optimization, can also be generated. Anthropic's Constitutional AI (2022) had a model critique and revise its own answers according to a written list of principles, and used AI preference labels to train for harmlessness. Generally this is called reinforcement learning from AI feedback (RLAIF).
Model collapse
What happens if models are trained, generation after generation, mostly on data produced by earlier models? Shumailov and colleagues (Nature, 2024) showed that this leads to model collapse. Each generation slightly under-represents rare events, because a model's samples come mostly from the high-probability middle of what it learned. Errors compound. The tails of the distribution vanish first, then the model's outputs grow narrower and stranger.
The simplest demonstration fits a bell curve to some data, samples new data from the fitted curve, refits, and repeats:
The fix shown in the green line matters in practice. Gerstgrasser and colleagues (2024) found that when synthetic data accumulates alongside the original real data, instead of replacing it, collapse is avoided in their experiments. This strategy of data accumulation is the practical rule: keep real data in every training mix, track the provenance of everything, and don't let synthetic data crowd it out.
The concern extends to the web itself. As more online text is machine-written, future models scraped from it will train partly on their predecessors' output whether their makers intend it or not. This is one reason curated, verified human data has become more valuable.
Other risks
- Inherited errors and bias. The generator's factual mistakes (Hallucinations), stereotypes and blind spots pass straight into the training set (Bias and Fairness).
- Low diversity. Generated data clusters around the model's favourite phrasings and topics. Measure diversity (for example, embedding spread or the share of near-duplicates) and vary prompts deliberately.
- Benchmark contamination. A generator that has seen a benchmark may reproduce its questions. Decontaminate against every evaluation set you use (Evaluating LLMs and Benchmarks).
- Terms and licences. Some model providers' terms of service restrict using their outputs to train competing models. Check before you build a dataset.
- Privacy is not automatic. Data generated by a model trained on private records can leak those records. Formal guarantees need techniques such as differential privacy.
In code
First, model collapse in miniature: fit a Gaussian, sample from it, refit, and repeat, either replacing the data each generation or accumulating it.
import numpy as np
rng = np.random.default_rng(0)
real = rng.normal(0, 1, 100) # generation 0: 100 real data points
def run(mode, generations=200, n=100):
data, spreads = real.copy(), []
for g in range(generations):
mu, sigma = data.mean(), data.std() # "train" a model: fit a Gaussian
spreads.append(sigma)
synthetic = rng.normal(mu, sigma, n) # sample the next generation from the model
data = synthetic if mode == "replace" else np.concatenate([data, synthetic])
return np.array(spreads)
for mode in ("replace", "accumulate"):
runs = np.array([run(mode) for _ in range(20)])
s = runs.mean(axis=0)
print(f"{mode:<10} std at generation 0: {s[0]:.2f} 50: {s[50]:.2f} 100: {s[100]:.2f} 199: {s[199]:.2f}")
# replace std at generation 0: 0.96 50: 0.67 100: 0.49 199: 0.30
# accumulate std at generation 0: 0.96 50: 0.95 100: 0.95 199: 0.95
Each refit loses a little of the spread, on average, and with replacement the losses compound. Second, the generate-filter pattern, with a stand-in "teacher" that makes mistakes 15% of the time and repeats itself, and a programmatic verifier:
import random
random.seed(0)
def teacher(n):
"""Stand-in for an LLM asked to write maths word problems with answers."""
names, items = ["Ana", "Ben", "Chen", "Dara"], ["apples", "books", "coins"]
out = []
for _ in range(n):
a, b = random.randint(2, 20), random.randint(2, 20)
q = f"{random.choice(names)} has {a} {random.choice(items)} and gets {b} more. How many now?"
answer = a + b if random.random() > 0.15 else a + b + random.choice([-1, 1, 10]) # 15% wrong
out.append({"question": q, "answer": answer, "a": a, "b": b})
return out
def verify(ex): # a programmatic check, like running unit tests on code
return ex["answer"] == ex["a"] + ex["b"]
candidates = teacher(2000)
unique = {ex["question"]: ex for ex in candidates}.values() # exact-duplicate filter
kept = [ex for ex in unique if verify(ex)]
print(f"generated {len(candidates)}, unique {len(unique)}, verified {len(kept)}")
print(kept[0]["question"], "->", kept[0]["answer"])
# generated 2000, unique 1628, verified 1382
# Ana has 14 books and gets 15 more. How many now? -> 29
Of 2,000 generated problems, 372 were duplicates and another 246 had wrong answers: almost a third of the raw output would have harmed training. With a real model, teacher becomes an API call. For example, against an OpenAI-compatible server such as the vLLM one in Serving LLMs at Scale:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="not-needed")
seed_topics = ["fractions", "percentages", "unit conversion", "ratios"]
for topic in seed_topics:
reply = client.chat.completions.create(
model="Qwen/Qwen2.5-7B-Instruct",
messages=[{"role": "user", "content":
f"Write one word problem about {topic} for a 12-year-old. "
"Reply as JSON with keys 'question' and 'answer' (a number)."}],
temperature=1.0,
)
print(reply.choices[0].message.content) # then parse, verify and deduplicate
Common pitfalls
- No real-data evaluation. Measuring a model trained on synthetic data with more synthetic data hides every flaw they share. Hold out real, human-checked data.
- Mode collapse in generation. Thousands of prompts with the same template give thousands of near-identical examples. Vary seeds, personas, difficulty and format, and measure near-duplicates.
- Trusting the judge. An LLM judge from the same family as the generator rates its own style highly. Calibrate the judge against human labels on a sample.
- Leaking test sets. Generated data that paraphrases benchmark questions inflates scores without improving the model. Decontaminate.
- Replacing real data entirely. Collapse risk grows when each round trains only on the previous round's output. Accumulate, and keep the real data.
Watch out A model trained on unverified synthetic data learns the generator's mistakes as confidently as its truths. If 15% of generated answers are wrong, as in the example, the student is taught that wrong arithmetic is correct 15% of the time. Wherever an automatic check exists, use it. Where none exists, sample and review by hand before scaling up.
Where it leads
- Instruction Tuning and Chat Models and Fine-Tuning an Open Model in Practice: where most synthetic instruction data ends up.
- Knowledge Distillation and Small Models: training a small model on a large model's outputs, the purest form of model-generated data.
- Reasoning Models and Test-Time Compute: verified reasoning traces and reinforcement learning with checkable rewards.
- RLHF and Preference Optimization: AI feedback as synthetic preference data.
- Evaluating LLMs and Benchmarks: decontamination, LLM judges and why evaluation needs real data.
- Privacy, Data and Copyright: licensing, terms of service and privacy questions around generated data.
A bit of history
Synthetic data has a long history in computer vision and robotics, where rendered scenes and simulators supplied perfectly labelled examples, and in statistics, where synthetic microdata was proposed in the early 1990s as a way to release census-like data without exposing individuals. Augmentation and oversampling methods such as SMOTE (2002) generated new examples for small classes.
The modern wave began with large language models. Self-Instruct (late 2022) and Stanford's Alpaca (March 2023) showed that a few hundred dollars of API calls could produce a usable instruction dataset. Within months came Evol-Instruct, TinyStories and phi-1's "textbook quality" synthetic data, and Anthropic's Constitutional AI had already shown AI-generated feedback could replace some human labels. In 2024 Shumailov and colleagues' Nature paper made "model collapse" widely known, and follow-up work showed that accumulating real and synthetic data avoids it. By 2025, verified synthetic data, especially for maths, code and reasoning, had become a standard ingredient of building frontier models.
Try it
- In the collapse simulation, change
nfrom 100 to 1,000 points per generation. How much more slowly does the spread shrink with replacement? Why?- Modify the accumulate version to keep only the most recent 300 points. Does collapse return?
- In the teacher example, make the verifier forgiving (accept answers within ±1 of the truth). How many wrong examples slip through?
Hint for 1: with more samples, each fitted standard deviation is a more accurate estimate, so less spread is lost per generation.
Learn more
Hand-picked courses, books, videos and tutorials for going deeper. See all resources →
Self-Instruct: Aligning Language Models with Self-Generated Instructions
Uses a language model to write its own instruction-following training data from a small seed set, the trick behind many cheap open chat models.
AI models collapse when trained on recursively generated data
The Nature paper showing that models trained generation after generation on their predecessors' output lose the tails of the distribution and degrade.
Cosmopedia: how to create large-scale synthetic data for pre-training
A detailed, practical account of generating 25 billion tokens of synthetic textbooks and stories: prompts, seed data, diversity, deduplication and decontamination.
Textbooks Are All You Need
phi-1: a 1.3B-parameter coding model trained largely on filtered web data plus synthetic textbooks and exercises written by GPT-3.5.
Alpaca: A Strong, Replicable Instruction-Following Model
How 52,000 instructions generated with OpenAI's text-davinci-003, for under 500 dollars, turned LLaMA 7B into an instruction follower.
Is Model Collapse Inevitable? Breaking the Curse of Recursion by Accumulating Real and Synthetic Data
Shows that collapse is avoided when synthetic data is added to the accumulated real data instead of replacing it.
TinyStories: How Small Can Language Models Be and Still Speak Coherent English?
A synthetic dataset of simple children's stories that lets tiny language models learn fluent, consistent English.
Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/mlops/synthetic-data.md