Concepts / Training a Model Over Multiple Epochs

Training a Model Over Multiple Epochs

Overfitting can begin after a few epochs when the dataset is very small and is iterated over many times.

  • Programming

Why a Falling Loss Looks Like Success

Imagine you have finished setting up a training run. You pass a small collection of text through the model again and again, and after each pass the number that measures how wrong the model is on that same text goes down. It is tempting to read that as success. The training function is doing its job, and the loss it reports is shrinking. This article asks a more careful question: what does a falling training loss actually tell you, and when can it mislead you?

What One Epoch Means

Definition

An epoch is one complete pass through the training data. Training over multiple epochs means the same examples are presented to the model more than once, in sequence, so that the model is adjusted again and again using the same material.

Repetition is normal and useful in training. The concern this article addresses is what happens when the pool of examples is small. Each pass then shows the model nearly the same material as the one before it, which gives the model many chances to learn the particular examples it has been given rather than the broader pattern behind them.

Watching the Same Small Dataset Repeat

The source explains that the model begins to overfit after a few epochs. The reason it gives is the combination of two things: the dataset is very small, and the training process goes over it multiple times. Trace what the model sees as the epochs accumulate. In the first pass, the examples are new to it. By the next pass, it has already been adjusted on those same examples. By the later passes, the model has met each example many times, and the variety it experiences has not grown.

Epoch 1examples seen for the firsttimeEpoch 2same examples againEpoch 3same examples againLater epochsfew new examples to learnfromOverfittingbegins after a few epochsrepeatrepeatrepeatmay appear
How does the model's behavior change as the same small dataset is passed through again and again, and at which epoch does it start memorizing instead of generalizing?

The diagram shows the progression in words rather than numbers. The source does not give a specific epoch count at which overfitting starts. It says only that it can begin after a few epochs, and that the condition depends on a very small dataset being repeated.

When Two Ingredients Combine

The key idea is the combination. A small dataset alone is not the whole story, and repeated passes alone are not the whole story either. Overfitting appears when both are present: little variety in the data, and many repeated exposures to that same variety. Remove either ingredient and the risk the source describes is reduced.

Why Training Loss Cannot Settle the Question

The source makes a balanced statement about the same run. It notes that the model overfits, and then it adds that the function is working, because it minimizes the training set loss. Both claims are true at once. The training function is correctly driving down the loss it is asked to minimize. The concern is that this particular loss only measures performance on the data the model is already being trained on.

A falling training loss therefore shows that the training function is minimizing the loss it measures. It does not show how the model behaves on text it has not been trained on. A model can keep improving on the examples it has memorized while getting worse on material it has not seen, and the training loss curve would still be heading down.

Training lossmeasured on the trainingdataLoss on training datakeeps falling across epochsUnseen dataperformancenot measured by traininglossResults on unseendatacan get worse while theother fallsreportsreveals
How can training loss keep dropping while performance on unseen data gets worse, and how do the two curves move apart over epochs?

What do you think happens?

If the training loss has fallen steadily for many epochs, does that prove the model will work well on new text?

  • Yes, a falling loss proves it

  • No, the loss only measures the training data

Reveal answer
Answer:

No, the loss only measures the training data

The source says the training function is working because it minimizes the training set loss, but that loss is computed on the data the model is already trained on. It says nothing directly about performance on text outside the training set.

Worked Trace of a Suspicious Run

Worked example

Reading a run with a small dataset

A training run uses a very small set of text examples and is iterated over for many epochs. The training loss keeps falling. Should you conclude that the run succeeded?

  1. 1
    Check the dataset size

    The dataset is very small, so each epoch shows the model almost the same material as the last one.

  2. 2
    Check the number of epochs

    The run goes over the data many times, which gives the model many chances to learn the specific examples.

  3. 3
    Read the falling loss

    The training function is minimizing the loss it measures. That confirms the optimization step is working on the training data.

  4. 4
    Ask what the loss does not measure

    The loss is computed on the training data. It does not, by itself, show how the model behaves on text it has not seen.

  5. 5
    Look for a larger, more varied comparison

    Compare the results with results on a larger text dataset before deciding the model works.

Result

The falling loss is not enough to declare success. The run needs a comparison on more varied data before its quality can be judged.

What to Compare Before Trusting a Run

The source does not stop at diagnosing the small-dataset problem. It invites the reader to train the model on a larger text dataset and to compare the results of this more sophisticated training function with the results from the simpler train_model_simple function. The point of the comparison is to see how the training outcome changes when the data is bigger and the training approach is different, rather than to accept one loss curve at face value.

Basis for judgmentWhat it tells youLimitation
Training loss on the small runThe training function is minimizing the loss it measuresMeasured only on the data being trained on; cannot show overfitting by itself
Results on a larger text datasetHow the training outcome changes when data is bigger and more variedRequires running and comparing a second, larger training setup
One small run judged aloneA single data point about one setupEasy to mistake for success when the data is too limited

Evidence to weigh when judging a training run, as framed by the source

When you run that comparison, keep one question in view: is the improvement you see a feature of the training function, or a feature of having more varied data? A larger and more varied dataset gives the model less opportunity to memorize a few passages, which is exactly the condition the small-dataset discussion warned about.

Mistakes When Reading Training Results

  • Common mistake

    Treating a falling training loss as proof that the model works

    What it looks like

    The loss drops for twenty epochs, so the run is declared a success.

    Why it fails

    The loss is computed on the training data, so it measures fit to that data rather than behavior on unseen text.

    Do this instead

    Compare results on a larger and more varied dataset before deciding the model works.

  • Common mistake

    Ignoring dataset size because the training function looks correct

    What it looks like

    The optimization code is sound, so a tiny dataset is assumed to be fine.

    Why it fails

    Overfitting appears when a very small dataset is iterated over many times, even when the training function is doing its job.

    Do this instead

    Check the dataset size and the number of epochs together.

  • Common mistake

    Judging the model from one small run alone

    Why it fails

    A single run on limited data gives one data point, and the source advises judging results by comparison on a larger text dataset rather than trusting one small run.

    Do this instead

    Repeat the comparison on a larger dataset and check whether the improvement holds.

LoRA as a Parameter-Efficient Technique

The appendix that introduces LoRA sits next to the overfitting discussion for a reason. Both concern how a model is adjusted after its initial training, and both require careful reading of what the adjustment achieves. The source frames LoRA as a fine-tuning technique rather than as a new way of measuring results. It is best understood as a method for changing a model efficiently.

The source describes LoRA as a widely used parameter-efficient fine-tuning technique. Its illustration in the source is the spam classification fine-tuning example from chapter 6. The source also states that LoRA fine-tuning is applicable to the supervised instruction fine-tuning covered in chapter 7. So the technique is not limited to one task; it is tied to these two settings in the source material.

LoRAparameter-efficientfine-tuning techniqueSpam classificationfine-tuning example,chapter 6Supervisedinstructionfine-tuningcovered in chapter 7illustrated withapplicable to
How LoRA relates to the two fine-tuning settings the source ties it to: spam classification and supervised instruction fine-tuning.

Judging a Training Run Yourself

MEDIUM

A training run uses a very small text dataset and goes over it for many epochs. The training loss falls steadily. Describe what you would check before deciding whether the model is working, and explain why the falling loss alone is not enough.

Hints
  • Start with what the dataset size and repeated passes together can cause.
  • Ask which data the training loss is computed on.
  • Think about what a larger and more varied comparison would reveal.

Key Takeaways

  • A very small dataset iterated over many epochs makes overfitting likely, because each pass shows the model nearly the same material again.
  • A falling training loss shows the training function is minimizing the loss it measures, but that loss is computed on the training data and does not by itself prove the model works well.
  • Judge training results by comparing them on a larger and more varied text dataset rather than trusting one small run.
  • LoRA is a parameter-efficient fine-tuning technique, illustrated in the source with spam classification and applicable to supervised instruction fine-tuning.

Related concepts

More concepts starting with T