Lesson 3 of 3 Fine-Tuning Foundation Models

Synthetic Data for Fine-Tuning

This lesson explains how synthetic training data is generated with a teacher model, how distillation works, and how synthetic datasets are checked and managed.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe techniques for generating synthetic data.
  • Explain distillation from a teacher to a student model.
  • Identify the checks synthetic data needs.
  • Describe the lineage recorded for a synthetic dataset.

What synthetic data is

Synthetic data is training data generated by a model instead of collected from real use. It fills three common gaps: too few examples of a task, sensitive real data that cannot be used for training, and an uneven distribution in which rare but important cases have almost no examples. The generating model is usually a large, capable model called the teacher.

The following table shows common ways to generate synthetic data and what each produces.

TechniqueInputOutput
Question and answer generationDocuments such as manuals or policiesQuestions a user might ask, with answers grounded in the documents
Expansion from seedsA small set of real examplesNew examples in the same style with different content
ParaphrasingExisting user messagesVariations in wording, tone and errors, which make the model robust
Conversation simulationA task description and user personasMulti-turn conversations, including difficult users
Response generationReal prompts without good answersHigh quality responses from the teacher for SFT or preference pairs for DPO

Distillation

Distillation uses the outputs of a large teacher model as training data for a smaller student model. The teacher, given a detailed prompt and possibly retrieved context, answers a set of representative inputs; the best answers become SFT data; and the student is fine-tuned to produce them from a short prompt. The result is a model that performs the specific task close to the teacher's level with lower latency and cost per request.

  1. Collect inputs

    Gather representative prompts from production logs or generate them, covering the task's range.

  2. Generate with the teacher

    Run the teacher with its best prompt and context, and store its responses.

  3. Filter

    Keep only responses that pass evaluators or review; discard wrong or unsafe ones.

  4. Fine-tune the student

    Train the smaller model with SFT on the filtered pairs.

  5. Compare

    Evaluate student and teacher on the same held-out real examples, with quality, latency and cost.

Foundry supports this workflow by storing completions from a deployed model, so that production responses can be reviewed and exported as training data. The terms of use of the teacher model must permit using its outputs to train another model.

Checking synthetic data

Synthetic data inherits the teacher's mistakes and tends to be repetitive, so it must be checked before training. A model fine-tuned on unchecked synthetic data learns those mistakes as confidently as the correct behaviour.

  • Correctness: grade answers with evaluators such as groundedness against the source documents, with a stronger model as judge, or with code for verifiable answers, and route uncertain cases to human review.
  • Diversity and balance: remove exact and near-duplicates, for example by embedding similarity, and check the distribution of topics, lengths and difficulty against real traffic.
  • Safety and privacy: run content safety checks and confirm that no personal data from seed examples has been copied into the generated examples.
  • Realism: compare samples with real user messages; synthetic questions are often cleaner and more complete than real ones.

Test on real data

Always evaluate on a held-out set of real examples. A model can score well on synthetic test data generated in the same way as its training data and still perform poorly on real users' inputs.

Managing synthetic datasets

Synthetic datasets are artifacts of a generation process, so they are managed like any other training asset. Each dataset version is registered, for example as a data asset in Azure Machine Learning or in versioned storage, together with the information needed to reproduce or audit it.

  • The teacher model and version, and the generation prompts and parameters.
  • The seed examples or source documents and their versions.
  • The filters applied, their thresholds and the share of examples removed.
  • The proportion of synthetic and real examples in the final training file.

Recording this lineage means that, when the base model is replaced or a quality problem is traced to the training data, the dataset can be regenerated or corrected rather than rebuilt from scratch.

Worked example

Building a training set

A bank wants to fine-tune a small model to answer questions about its 300 product documents. It has 150 real customer questions with approved answers, but most are about two popular products, and the questions contain customer details. Compliance requires that answers match the documents.

Use a teacher model to generate question and answer pairs from the product documents, so that every product is covered, and to paraphrase questions into realistic customer wording. Filter the generated pairs with a groundedness evaluator against the source passages and a sample of human compliance review, remove near-duplicates, and run safety checks. Remove customer details from the real questions and keep most of them as a held-out real test set.

Training only on the 150 real questions would leave most products uncovered and copy customer data into the model. Generating questions without grounding checks would risk teaching unsupported answers. Testing only on synthetic questions would overstate quality. Product information that changes should still be served through retrieval, with fine-tuning used for the answer style and structure.

Check yourself

Why should a fine-tuned model trained on synthetic data be evaluated on real examples?

Show answer

Synthetic test data generated in the same way as the training data shares its style and gaps, so it can overstate quality. Held-out real examples show performance on actual users' inputs.

Exam Tips

Remember for the exam

  • A teacher model generates synthetic examples; a student model is fine-tuned on them.
  • Distillation transfers a large model's task behaviour to a smaller, cheaper model.
  • Filter synthetic data for correctness, duplicates, safety and personal data before training.
  • Evaluate on held-out real examples and record dataset lineage.