◆ AI All-in-One

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
↗ Plan a path here

Read first

Data Pipelines and DatasetsGPT and Decoder-Only Models

This leads to

—
The full path from zero — 35 concepts before this one
  1. What Is AI?
  2. Vectors
  3. Derivatives and Slopes
  4. Probability Basics
  5. Python for AI
  6. How Machines Learn
  7. Partial Derivatives and Gradients
  8. Matrices and Matrix Multiplication
  9. The Chain Rule
  10. Dot Product, Norms and Similarity
  11. Pandas and Working with Data
  12. Tokenization
  13. Supervised, Unsupervised and Reinforcement Learning
  14. Gradient Descent
  15. Data Cleaning and Preparation
  16. Language Modeling and Next-Token Prediction
  17. Supervised Learning
  18. Data Pipelines and Datasets
  19. Linear Regression
  20. The Perceptron
  21. Logistic Regression
  22. Neural Networks
  23. Recurrent Neural Networks
  24. Backpropagation
  25. Activation Functions
  26. Vanishing and Exploding Gradients
  27. Normalization Layers: BatchNorm and LayerNorm
  28. LSTMs and GRUs
  29. Residual Connections
  30. Sequence-to-Sequence Models
  31. Attention
  32. Self-Attention and Multi-Head Attention
  33. Positional Encodings
  34. The Transformer
  35. GPT and Decoder-Only Models
  36. 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:

Seed dataexamples, topics,personas, documents Generatora strong model withvaried prompts Candidatesmany, cheap,some wrong Filters deduplicateverify: tests, mathsLLM judge, rubricdecontaminate Kept datamixed with real data,provenance recorded Train the modelfine-tune or pretrain Evaluate on REAL dataheld-out, human-checked find gaps andfailure cases →new seeds and prompts candidates that fail a filter are thrown away, never trained on
Fig. 1 The synthetic data loop. A small set of seed examples and instructions prompt a generator model. Its candidate examples pass through filters: deduplication, automatic verification, an LLM judge and decontamination against test sets. Only survivors enter the training set. The trained model is evaluated on real data, and the results guide the next round of prompts.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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:

Spread (standard deviation) of each generation’s data 0.0 0.2 0.4 0.6 0.8 1.0 1.2 0 50 100 150 199 generation (each one trained on samples from the previous fit) accumulate0.95 replace0.30 thin lines: individual runs · thick lines: mean of 20 runs · real data started at 0.96
Fig. 2 Model collapse in a toy simulation. A Gaussian is fitted to 100 points, 100 new points are sampled from the fit, and the process repeats. If each generation replaces the data (red), the spread shrinks steadily, to about a third of its original value after 200 generations, averaged over 20 runs. If synthetic data is added to the accumulated real and earlier data (green), the spread stays where it started.

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

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

  1. In the collapse simulation, change n from 100 to 1,000 points per generation. How much more slowly does the spread shrink with replacement? Why?
  2. Modify the accumulate version to keep only the most recent 300 points. Does collapse return?
  3. 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.

Check your understanding

4 quick questions. Pick an answer to see whether you were right and why. Your best score is saved on this device.

  1. You generate 2,000 maths problems with a teacher model. What is the most reliable way to filter them?

  2. Each generation of a model is trained only on samples from the previous one. What happens over many generations?

  3. How do you avoid model collapse in practice?

  4. You trained on synthetic data and evaluate with more synthetic data from the same generator. Scores look great. What is the risk?

Finished this chapter?

Learn more

Hand-picked courses, books, videos and tutorials for going deeper. See all resources →

Paper

Textbooks Are All You Need

Gunasekar et al. (Microsoft Research) · 2023 · Intermediate · Free

phi-1: a 1.3B-parameter coding model trained largely on filtered web data plus synthetic textbooks and exercises written by GPT-3.5.

Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/mlops/synthetic-data.md