# Learning Rate and Epochs for Fine-Tuning

> How to set the learning rate and the number of epochs when you fine-tune a model, and how to tell when training has gone too far, for your AI interview.

**In short:** Fine-tuning usually uses small learning-rate steps, so the model adjusts gently and keeps what it knew. Epochs are full passes over your examples: more passes can help, but too many make the model memorise them, so you watch validation loss to choose.

AI and LLM interview question Q298, Fine-tuning and adaptation. Advanced, occasional (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/learning-rate-and-epochs-for-fine-tuning

## Say it in 30 seconds

A learning rate is how big a step the model takes each time it corrects itself. For fine-tuning I keep those steps small, because the model already knows a lot and I only want to teach it my job. An epoch is one full pass over my training examples. I don't guess the number. I score the model after each epoch on examples it never trained on, and I keep the copy from before the score starts to rise.

## Say it in 2 minutes

Fine-tuning starts from a model that already works and teaches it one job, such as sorting insurance claims by urgency. Two settings shape that training. The learning rate sets how far the weights move on each correction. The epoch count sets how many full passes the model makes over our examples.

I keep the learning rate small. Big corrections can overwrite what the base model already knows, and tiny ones make the run crawl. Google's crash course warns that a rate that is too high bounces around the answer and never settles. OpenAI, Azure and AWS each expose it as a setting.

For epochs, more is not automatically better. Each pass can help, but past a point the model memorises the notes it has seen. Bigger datasets usually need fewer passes than small ones. Epochs also cost money, because training tokens grow with them. On 4,000 notes of about 900 tokens each, three epochs is 10.8 million training tokens, and six is 21.6 million.

So I score the model after every epoch on examples it never trained on, save a checkpoint each time, and keep the one from just before validation loss keeps rising. If no setting gives a good score, I look at the data before I touch the settings again.

## What are the learning rate and epochs, in plain words?

A model learns by making small corrections. After each batch of examples it checks how wrong it was, then nudges its weights, the numbers inside it, to be a little less wrong. The learning rate is the size of each nudge.

An epoch is one full pass through the training set. Google's machine learning course says that "the entire training dataset is used during training" once per epoch, and that the count affects both quality and training time.

Think of a claims handler who moves to a new insurer. She already knows how claims work, so the new firm doesn't teach her from zero. Some feedback on its own files is enough to start. Fine-tuning works the same way: it starts from a model that already reads English well and corrects it on your own examples.

Our running example is a claims triage model. An insurer wants it to tag each new claim note as urgent, routine or possible fraud. Its staff have already labelled 4,000 notes, each about 900 tokens long. A token is a small chunk of text, a word or part of one.

- **Learning rate:** The size of each correction the model makes to its weights during training.
- **Epoch:** One full pass through every training example.
- **Validation set:** Examples held back from training, used to score the model as it learns.
- **Checkpoint:** A saved copy of the model at one point in training, so you can go back to it.

Validation loss is a score for how wrong the model is on those held-back examples. Lower is better. We watch it after each epoch.

## Why keep the learning rate small when you fine-tune?

A fine-tune starts from a model that already knows a lot. Big corrections can overwrite that knowledge, so the model gets good at your labels and can lose skills it had before. Small steps let it learn the new job while keeping what it had.

*Diagram, Three learning rates, three outcomes: Three step sizes lead to three outcomes. Big steps bounce around and never settle. Tiny steps barely learn. Steady steps keep the old skills and learn the job, which is the good end.*
1. Big steps make the loss jump about and never settle.
2. Tiny steps barely move the model, so the run drags on.
3. Steady steps keep the base model's skills and learn your labels.

The step size has two sides. Google's crash course says that if the learning rate is too low, the model can take a long time to converge, meaning settle on a good answer. If it is too high, the model never converges and bounces around the best answer instead.

OpenAI, Azure and AWS each expose this as a dial. OpenAI's API calls it a learning rate multiplier, a scaling factor for the learning rate. Azure's guide says a smaller multiplier can help reduce overfitting, the point where the model memorises its examples.

There is no universal number. Hugging Face's Trainer, in its Transformers library, starts at 5e-5 by default. Treat it as a starting point to test on your own data.

> **Tip:** Don't give a magic number in the interview. Say you start from the provider's default or a value you have seen work. If the loss bounces during training, lower the step. If validation loss rises after a few epochs, stop earlier or check the data first.

## How many epochs should you run?

OpenAI's API reference defines an epoch as one full cycle through the training dataset. More epochs give the model more chances to learn, and more chances to memorise.

The starting point differs by provider. For Amazon Nova Lite, Micro and Pro, AWS's Bedrock guide gives a default of 2 epochs, which it says works for most cases. It also says larger datasets need fewer epochs to converge, and smaller datasets need more.

OpenAI saves a full checkpoint at the end of each epoch, so you can compare them after the run. You don't have to stop at the last one.

*Diagram, Stop at the best validation score: After each epoch the run is scored on examples it never trained on. While that score still falls, training carries on. Once the score has risen for two epochs in a row, the model has started memorising, so keep the checkpoint from just before the rise.*
1. Each epoch, the run is scored on held-back examples.
2. A falling score means training carries on.
3. A rise means the score moved up this epoch.
4. Stop here and keep the copy from before the rise.

## How do you pick the epoch count in practice?

Here is a made-up claims triage run. The numbers are invented, but the arithmetic and the stopping rule are the kind a team checks before it spends money.

```python
# Made-up claims triage fine-tune: 4,000 past claim notes, about 900 tokens each.
EXAMPLES = 4000
TOKENS_PER_EXAMPLE = 900
PATIENCE = 2  # stop after this many epochs in a row with no new best

for epochs in (3, 6):
    tokens = EXAMPLES * TOKENS_PER_EXAMPLE * epochs
    print(f"{epochs} epochs = {tokens:,} training tokens")

# Made-up validation loss after each epoch (lower is better).
val_loss = [1.84, 1.52, 1.31, 1.22, 1.20, 1.23, 1.29]
best, best_epoch, waited = float("inf"), 0, 0
for epoch, loss in enumerate(val_loss, start=1):
    print(f"epoch {epoch}: val loss {loss:.2f}")
    if loss < best:
        best, best_epoch, waited = loss, epoch, 0
    else:
        waited += 1
    if waited == PATIENCE:
        print(f"stop after epoch {epoch}")
        break
print(f"keep the checkpoint from epoch {best_epoch} (val loss {best:.2f})")
```

Output:

```text
3 epochs = 10,800,000 training tokens
6 epochs = 21,600,000 training tokens
epoch 1: val loss 1.84
epoch 2: val loss 1.52
epoch 3: val loss 1.31
epoch 4: val loss 1.22
epoch 5: val loss 1.20
epoch 6: val loss 1.23
epoch 7: val loss 1.29
stop after epoch 7
keep the checkpoint from epoch 5 (val loss 1.20)
```

Read the output. Six epochs cost twice as many training tokens as three, because Google's Gemini tuning docs count training tokens as the dataset size times the epochs. The validation loss bottoms out at epoch 5, rises for two epochs, and the run stops at epoch 7 with the copy from epoch 5.

1. **Start from a known setting:** Use the provider's default or a value you have seen work on similar data. Don't guess a big number.
2. **Score after every epoch:** Measure validation loss on examples held back from training. Training loss keeps falling even while the model memorises, so it can't warn you.
3. **Stop when the score turns:** The code waits two epochs in a row with no new best, then stops. Two is a setting you can change to suit the data.
4. **Keep the best copy:** Return to the checkpoint from the best epoch. The last copy may have started to memorise.

## What do the two settings trade off?

- **Learning rate up: Faster, but less stable.** The score can improve sooner, but training may become unstable near the end.
- **Epochs up: More learning, then memorising.** Each pass can help, until validation loss turns up. Each pass also adds cost.
- **The safe pattern: Small steps, a few passes, watched.** Keep the steps modest, watch validation loss, and let it choose when to stop.

> "A smaller learning rate may be useful to avoid overfitting." (OpenAI API reference)
>
> "More passes can improve learning, but can increase overfitting." (Microsoft Foundry docs)
>
> "A faster convergence might also be achieved by increasing the learning rate, but this is less desirable because it might lead to training instability at convergence." (AWS Bedrock docs)

### How would you set them for only 300 examples?

Three hundred labelled examples is small. The model can memorise them quickly, and a validation set of 15% (45 notes) gives a noisy score, so one run's curve can mislead. AWS notes that smaller datasets usually need more passes to converge, which makes the stop point matter even more.

So I would keep the step size small, repeat the same settings with three different random starts, and compare their best validation scores. If the scores disagree a lot, I'd trust none of them. I would also ask whether more labels are possible before adding more passes over these 300.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Learning rate: the size of each correction, and why fine-tuning keeps it small.
- [ ] Epoch: one full pass, which costs tokens and can lead to memorising.
- [ ] Validation loss after each epoch decides when to stop.
- [ ] Keep the best checkpoint, not necessarily the last one.
- [ ] The right values depend on the data and the provider, so you test them.

**Common traps**

- Trap: "A big learning rate helps it learn faster." Better: Big steps can overwrite what the model already knows. Start small and watch the curve.
- Trap: "Train for 50 epochs to be safe." Better: More passes can memorise the notes. Stop when validation loss turns up.
- Trap: "The last checkpoint is always the best one." Better: Keep the checkpoint with the best validation score, which is often an earlier one.

## Can you spot the problem?

**Spot the problem:** A contract-review team's fine-tune log shows training loss falling for 9 epochs, while validation loss has risen since epoch 4. What should they do?

A. Train for 9 more epochs, since training loss is still falling.
B. Keep the checkpoint from epoch 4 and stop, because validation loss rose after it.
C. Raise the learning rate so the validation loss falls faster.
D. Ship the epoch 9 model, since it has the lowest training loss.

**Answer:** B. Training loss measures examples the model has already seen, so it keeps falling as the model memorises them. Validation loss rose after epoch 4, so that checkpoint is the one to keep.

**Quick check:** Your insurer's fine-tune is good enough, but the bill is too high. Which change cuts the training cost most, with the same data?

A. Lower the learning rate multiplier
B. Cut the epochs from 6 to 3
C. Add a longer system prompt to the training data
D. Use a larger validation set

**Answer:** B. Cost follows the tokens processed, and training tokens are the dataset size times the epochs. Halving the epochs halves the training tokens. The learning rate doesn't change how much text is read.

## Can you answer these from memory?

**Flash cards**

- **What is the learning rate?** The size of each correction the model makes to its weights.
- **What is an epoch?** One full pass through every example in the training set.
- **Why keep the learning rate small?** Big steps can overwrite the knowledge the base model already has.
- **What stops extra epochs from helping?** Memorising. Validation loss rises, so keep the best checkpoint and stop.
- **How do you choose the epoch count?** Watch validation loss after each epoch. There is no universal number.
- **What does an extra epoch cost?** More training tokens: dataset tokens times epochs, so more money.

## Likely follow-up questions

- Q297 How do you spot overfitting during fine-tuning? https://designervenkat.online/interview/ai/how-do-you-spot-overfitting-during-fine-tuning
- Q296 What is catastrophic forgetting? https://designervenkat.online/interview/ai/what-is-catastrophic-forgetting
- Q300 How do you evaluate a fine-tuned model? https://designervenkat.online/interview/ai/how-do-you-evaluate-a-fine-tuned-model
- Q294 How do you prepare a fine-tuning dataset? https://designervenkat.online/interview/ai/how-to-prepare-a-fine-tuning-dataset
- Q417 What does the learning rate do? https://designervenkat.online/interview/ai/what-does-the-learning-rate-do
- Q286 What does LoRA rank mean? https://designervenkat.online/interview/ai/what-does-lora-rank-mean

## Learn it in depth

- [Fine-tuning](https://designervenkat.online/learn/ai-engineering/fine-tuning)
- [Tuning a model's settings](https://designervenkat.online/learn/machine-learning/hyperparameter-tuning)
