Concepts / Computing Validation Set Losses

Computing Validation Set Losses

Computing training and validation set losses is a way to assess the quality of LLM-generated text during training.

  • Programming

Why One Loss Number Is Not Enough

Training a large language model produces a steady stream of numbers, and one of the most important is the loss. On its own, though, a single loss value does not tell you very much. The useful question is whether the model is learning something general about language, or whether it is only getting better at the particular text it has already seen. This article covers one practical way to answer that question: computing the loss on two different sets of data, the training set and the validation set, and reading the two results together.

The purpose is stated directly in the source: computing the training and validation set losses is a way to assess the quality of LLM-generated text during training. Keep one question in mind as you read. What does each of the two losses tell you that the other one cannot?

What do you think happens?

If you only ever measure loss on the text the model is training on, what can you conclude about how well it writes new text?

  • That it writes new text well, because the loss is low

  • Very little, because the measurement only covers text the model has already seen

  • That it writes new text poorly, because training loss is always high

Reveal answer
Answer:

Very little, because the measurement only covers text the model has already seen

A loss computed only on training text measures how well the model handles that text. It does not, by itself, show how the model handles text it has not seen, which is the question the validation set is for.

Tracing Two Datasets Through One Model

The workflow has a simple shape. Two datasets enter at the top of the process. Each one is used to compute a loss on the same model, and the two resulting losses are then examined side by side. The assessment does not come from either loss alone. It comes from the pair.

Training settext the model learns fromSame LLMone model, measured on bothsetsTraining lossloss on training textJoint assessmentread the pair togetherValidation settext kept for assessmentValidation lossloss on validation textcomputes loss oncomputes loss ontraining set resultvalidation set resultcompared withcompared with
Trace what happens to the training set and the validation set on the way to the two losses that are read together.

Notice that the model is the same in both branches. Only the data changes. The two branches meet at the assessment step, where the developer reads the two numbers together rather than treating either one as the verdict.

What Differs Between the Two Losses

The training set loss is computed on the training set, and the validation set loss is computed on the validation set. The two losses are separate measurements. They are meant to be read together, not treated as interchangeable numbers. The table below sets out what stays the same and what changes between them.

AspectTraining set lossValidation set loss
Data it is computed onThe training setThe validation set
Model usedThe same LLMThe same LLM
What it tells youHow the model handles text it is learning fromHow the model handles text kept aside for assessment
Role in the assessmentShows the learning on seen textChecks whether that learning carries over to other text

Same model, two datasets, two separate measurements

Training textdata the model learns fromTraining lossmeasured on seen textValidation textdata kept for assessmentValidation lossmeasured on other textloss computedloss computed
What is the same and what is different when the loss is computed on training text versus validation text.

Following One Assessment Step by Step

Worked example

Assessing text quality during training

A developer is training an LLM and wants to judge the quality of the generated text at a checkpoint. Trace how the training loss and the validation loss are obtained and used together.

  1. 1
    Prepare the two datasets

    Separate the text into a training set, which the model learns from, and a validation set, which is kept for assessment.

  2. 2
    Compute the training loss

    Run the model on the training set and compute the loss on that text. This is the first of the two separate measurements.

  3. 3
    Compute the validation loss

    Run the same model on the validation set and compute the loss on that text. This is the second measurement, taken on different data.

  4. 4
    Read the two results together

    Look at the training loss and the validation loss side by side. The judgment about text quality comes from the pair, not from either number alone.

  5. 5
    Decide what to do next

    Use the joint reading to inform the next choice, such as continuing training, stopping, or adjusting training, while remembering that the source frames this as an assessment of text quality.

Result

The developer reaches a judgment about the model's text quality by combining two separate loss measurements, one on seen text and one on held-out text.

This example describes the sequence of steps rather than any particular values. The source gives the purpose of computing both losses but does not provide specific numbers, so no measurement is claimed here. The point of the example is the order of operations and the fact that the two results are combined.

Reading the Two Losses Over Training

Computing the two losses at several points during training lets you watch how they change over time. The training loss and the validation loss can be plotted against training progress. Their relationship over time is what the assessment is built on. When the two curves move together, the model's behavior on the held-out text is tracking its behavior on the training text. When they separate, with the validation loss no longer following the training loss, the gap is the signal to look at more closely.

Early trainingboth losses measuredMiddle traininglosses read togetherWidening gapvalidation no longerfollows trainingAdjust or stopdecision informed by bothlossesnext checkpointgap appearsinforms decision
How the training loss and validation loss relate over successive stages, and the point where a widening gap appears.

The diagram is qualitative and shows the reasoning pattern rather than real values. A widening gap between the two losses is one of the readings a developer would weigh when deciding whether to continue, stop, or adjust training. The decision still rests on reading both numbers together, not on one trend in isolation.

Predicting What a Diverging Pair Means

MEDIUM

Suppose that over several checkpoints the training loss keeps falling, but the validation loss stops falling and starts to rise. Using only what this article has described, explain what the two losses together suggest about the model's text quality, and why the training loss alone would not reveal this.

Hints
  • Ask which dataset each loss was computed on and whether the model has seen that text.
  • Think about what the validation loss measures that the training loss does not.
  • Consider why reading the pair is more informative than reading either number alone.

Common Misreadings of the Two Losses

  • Common mistake

    Treating a low training loss as proof of good generated text

    Why it fails

    The training loss is computed on the training set. A low value shows the model handles that text well, but the source describes the assessment as needing more than one loss value.

    Do this instead

    Read the training loss together with the validation loss before drawing any conclusion about text quality.

  • Common mistake

    Judging text quality from a single loss value

    Why it fails

    The source states that judging text quality from a single loss leaves out part of the evidence.

    Do this instead

    Use the pair of separate measurements, and keep track of which dataset each one came from.

  • Common mistake

    Treating the training loss and validation loss as interchangeable numbers

    Why it fails

    The two losses are separate measurements on different data, so they do not carry the same information.

    Do this instead

    Label each loss with its dataset and interpret them as complementary readings.

  • Common mistake

    Concluding that the model is working well because the validation loss looks reasonable at one checkpoint

    Why it fails

    A single checkpoint shows one moment. The useful signal in this workflow comes from comparing the two losses across training.

    Do this instead

    Observe how both losses change over training and how their relationship evolves.

Key Points to Carry Forward

  1. 1
    Computing the training set loss and the validation set loss is a way to assess the quality of LLM-generated text during training.
  2. 2
    The two losses are computed on different datasets with the same model and are separate measurements read together.
  3. 3
    A single loss value leaves out part of the evidence, so judgments about text quality should draw on both losses.
  4. 4
    Reading the two losses over training, including any widening gap between them, helps inform whether to continue, stop, or adjust training.

Key Takeaways

  • Computing the training set loss and the validation set loss is a way to assess LLM-generated text quality during training.
  • The two losses come from different datasets measured on the same model, and they are read together rather than interchangeably.
  • A single loss value cannot reveal whether learning carries over beyond the text the model has already seen.
  • Watching both losses across training helps inform decisions about continuing, stopping, or adjusting training.

Related concepts

More concepts starting with C