# Mission 19.3: Are 80 examples enough?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-19-3

Belongs to [Chapter 19: Fine-tuning in brief](https://llm.yoga/en/19-fine-tuning.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Felix**, sales engineer:

> “I wrote 80 examples, each a request from the contact form plus the matching CRM entry, and fine-tuned with them. The training loss drops nicely. But starting at step 120, the validation loss rises again. Do I just need more steps, or are 80 examples not enough?”

If you’re the go-to person for AI on your team, people show you curves like these as soon as someone fine-tunes on their own, usually asking whether more data or more compute would help. The **loss** measures how far off the model is from the desired answers; smaller is better. The training loss applies to the examples it learns from, the validation loss to ten examples it never sees while learning.

**Felix’s curves (example values)**

Step 40: training 1.2, validation 1.3.

Step 80: training 0.8, validation 1.0.

Step 120: training 0.5, validation 0.9.

Step 160: training 0.3, validation 1.0.

Step 200: training 0.2, validation 1.2.

**Question 1 (prediction):** What do Felix’s curves show starting at step 120?

- A) Training is briefly stuck; with more steps, the validation loss will drop again too.
- B) The ten validation examples are faulty; otherwise both curves would run the same.
- C) The model is memorizing the 80 examples instead of learning the task.

## What’s behind it

If you memorize the answers in the workbook for an exam, you’ll soon solve the workbook without mistakes. With new problems, that helps little, and at some point it hurts, because you only recognize patterns.

Fine-tuning works the same way. If the training and validation loss drop together, the model is learning the task. If only the training curve keeps falling while the other one rises, it’s memorizing the examples. That’s called **overfitting**. Then you stop or take an earlier checkpoint; mlx-lm saves them regularly. In the long run, fewer passes and more, more varied data help.

On quantity, OpenAI gives guidance: at least 10 examples, noticeable improvements often already with 50 to 100, start with 50 well-made ones, then evaluate. Quality matters more than quantity, because the model learns exactly what’s in the examples, mistakes included. Good examples look like the real inputs, with typos and special cases. They cover the variety, including hard cases, and they’re consistent: if the same input gets two different answers, the model learns randomness. Personal data doesn’t belong in them, because a model can reproduce training data word for word. And training never sees the test examples for the final evaluation.

For Felix, this means: 80 examples can be enough. He takes the checkpoint at around step 120 or retrains with fewer passes, and checks his examples for variety and contradictions. At the end, he evaluates on the test set: base model and fine-tuned model with the same requests, plus a few general questions that show whether the model has unlearned other things.

### In more detail: what the loss measures and how jumpy it is with few examples

The loss is the cross-entropy from mission 4.3: the negative natural logarithm of the probability the model gives the correct next token, averaged over the answer. With the `--mask-prompt` setting in mlx-lm, only the desired answer counts, not the request before it.

Felix’s values above are an example; the figure in the chapter is schematic. In the short run on the test Mac (Mac exercise for mission 19.2, twelve training and three validation examples, 40 steps), the validation loss was 4.219 before training, then 0.218, 0.344, 0.243 and 0.076 after every ten steps. With so few validation examples, the curve jumps around; you look at the trend over several measurements, not at a single value.

The three parts of an evaluation according to chapter 19: a fixed test set for the base model and the fine-tuned model, metrics that fit the task (for a format, say, the share of valid outputs and of correctly filled fields), and a small set of general questions to catch forgetting.

## Try it

**Sorting: does the example help the training?**

**Task:** Seven examples from Felix’s collection. Sort each one.

Categories: good example · bad example

1. Two almost identical requests for a quote: one is marked “urgent” in the CRM entry, the other “normal”.
2. “hi, need quote for 3 licenses, urgent!!”, with the correct CRM entry.
3. A real request with the customer’s full name, email address and phone number.
4. The 30th request for a contract renewal, almost word for word the same as the 29 before it.
5. A hard request: two wishes in one email, half of it in English.
6. An example from the test set, so the model knows the hard cases too.
7. A request without a quantity; the entry says “Quantity: unknown” instead of an estimated number.

## Check

**Question 2 (check question):** What does Felix do with his run, where the validation loss rises starting at step 120?

- A) He keeps training until the validation loss drops again too.
- B) He adds the ten validation examples to the training so it has more data.
- C) He takes the checkpoint at around step 120 or retrains with fewer passes.

**Question 3 (check question):** Felix’s boss wants to collect 10,000 examples before any training happens at all. What do you advise?

- A) Start with 50 well-made examples, evaluate, and then add to them where needed.
- B) Quite right; with fewer than several thousand examples, a model learns nothing useful.
- C) Have a large model generate the 10,000 and use them as they are; that’s quick.

**Question 4 (check question):** How can Felix tell whether training made his model unlearn something else?

- A) By the validation loss: if it doesn’t rise, the model hasn’t unlearned anything.
- B) By general questions put to the base model and the new model.
- C) By the training loss: if it’s small at the end, the model can still do everything.

## Done

**What you can do now**

- You read training and validation loss together and recognize memorizing when only the training curve keeps falling.
- You sort training examples by whether they look real, cover the variety, don’t contradict each other, contain no personal data and don’t come from the test set.
- When a customer asks how many examples to collect for fine-tuning, you advise 50 well-made ones as a start, a test set fixed in advance, and an evaluation after every expansion.

### Two cards for review

**Card 1:** True or false? “If the validation loss rises during fine-tuning, the training just needs more steps.”

**Card 2:** How many examples does a first fine-tuning attempt need, and what matters more than the number?

- [Back to all missions](https://llm.yoga/en/einsaetze)
- [Read chapter 19](https://llm.yoga/en/19-fine-tuning.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Data: quantity, quality, format](https://llm.yoga/en/19-fine-tuning-2.md)
- [Evaluation](https://llm.yoga/en/19-fine-tuning-2.md)
- [Risks](https://llm.yoga/en/19-fine-tuning-3.md)
- [Review questions, question 4](https://llm.yoga/en/19-fine-tuning-3.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is C.
- A: The training curve keeps falling, so training is running. It’s just learning something that doesn’t help on new examples. More steps make that worse.
- B: Up to step 120, both curves fell together, with the same ten examples. Only after that do they split. That’s down to the training, not the examples.
- C, correct: It keeps getting better on the known examples and worse again on unseen ones. That’s the sign of memorizing.

- Card 1: **bad example:** The two contradict each other. If the same input gets two different answers, the model learns randomness. Felix sets a rule and aligns both entries.
- Card 2: **good example:** That’s how customers really write, in lowercase and with exclamation marks. Later, the inputs will look exactly like this.
- Card 3: **bad example:** A model can reproduce training data word for word, phone number included. Felix replaces personal details with made-up ones or leaves them out.
- Card 4: **bad example:** More than a third of the 80 examples for a single case: the model memorizes this one, and other requests lack examples. Variety counts more than quantity.
- Card 5: **good example:** Good examples also cover the hard cases that will really come up later. Otherwise, that’s exactly where the model guesses.
- Card 6: **bad example:** Training must never see the test examples. Otherwise, the final evaluation measures memorizing instead of skill.
- Card 7: **good example:** A special case that comes up often, and the answer shows what the model should do then: make nothing up.

**Question 2:** The correct answer is C.
- A: After step 120, the model is memorizing. More steps make it worse, and the validation curve keeps rising.
- B: More data helps, but then the yardstick is gone: he’d no longer see how to spot memorizing. New examples go into training; validation stays separate.
- C, correct: At step 120, the model was at its best on unseen examples. After that, he evaluates on the test set, which neither training nor validation has seen.

**Question 3:** The correct answer is A.
- A, correct: That’s what OpenAI gives as a start. If 50 good examples do nothing at all, you rethink the task or the prompt before collecting more.
- B: For a narrow task, 50 to a few hundred are often enough. OpenAI gives 10 as the minimum and often sees noticeable improvements with just 50 to 100.
- C: The model learns exactly what’s in the examples, mistakes included. A person has to check generated examples; quantity doesn’t replace quality.

**Question 4:** The correct answer is B.
- A: The validation examples come from the same task as the training. They don’t show whether the model has gotten worse elsewhere.
- B, correct: Questions that have nothing to do with the task reveal forgetting. If the fine-tuned model answers them worse, it has unlearned something.
- C: A small training loss only means the model hits its own examples well. It says nothing about anything else, and very small can even mean memorizing.

**Card 1:** **False.** If only the training loss keeps falling while the validation loss rises, the model is memorizing the examples. More steps make that worse. The best state comes before the rise; in the long run, fewer passes and more varied examples help.

**Card 2:** OpenAI gives at least 10, noticeable improvements often with 50 to 100, and 50 well-made ones as a start. Quality matters more: inputs that look real, variety including hard cases, no contradictions, no personal data, nothing from the test set. And evaluate again after every expansion, also with general questions to catch forgetting.
