Concepts / Computing Training Set Losses

Computing Training Set Losses

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

  • Programming

One Number Is Not Enough

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

What do you think happens?

If a developer had only one loss value from a training run, could she confidently judge the quality of the generated text?

  • Yes, a low loss always means good text

  • No, one loss leaves out part of the evidence needed to judge quality

Reveal answer
Answer:

No, one loss leaves out part of the evidence needed to judge quality.

The source states that judging text quality from a single loss leaves out part of the evidence. The training loss and the validation loss are separate measurements, and they are meant to be read together rather than treated as interchangeable numbers.

The source for this topic states the purpose directly: 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?

Tracing the Two Measurements

Start with the flow of data. Two datasets enter the process at the top: the training set and the validation set. Each one is used to compute a loss on the same model. The two resulting losses are then examined side by side. The point of this picture is that the assessment does not come from one loss alone. It comes from the pair.

Training setLLMsame modelTraining lossRead side by sideValidation setValidation lossfeedsfeedsyieldsyields
What data passes through the model in each case, and how do the two resulting losses relate to each other?

Notice that both paths pass through the same model. What differs is the data entering it. The training loss is computed on the training set, and the validation loss is computed on the validation set. Those are the two separate measurements the developer keeps.

What Changes Between the Two Losses

Definition

Training set loss: the loss computed on the training set. Validation set loss: the loss computed on the validation set. The two are separate measurements.

The only thing that changes is the text the loss is computed on. The model, the idea of measuring a loss, and the purpose of assessing text quality stay the same. Because the two sets are kept separate, the validation loss is measured on text that is not the same as the text the training loss is measured on. That separation is what lets the pair of numbers say something a single number cannot.

The source frames the central question as whether the model is learning something useful or only getting better at the particular text it has already seen. A training set loss alone cannot separate those two possibilities, because it is measured on the very text the model is being judged against. The validation set loss gives a second view on the same model, measured on a different body of text, and the comparison between the two is where the evidence sits.

How the Text Is Divided

The two losses depend on two datasets, and these datasets are kept apart. The training set and the validation set do not overlap. A piece of text that serves as training material is not also used as validation material in the same comparison. If the two sets shared text, the validation loss would no longer offer a second view, because it would be measured on material the model had already been judged against during training.

Reading the Two Losses Together

The developer's task is to read the two numbers as a pair. The training loss describes how the model performs on the text it has seen. The validation loss describes how it performs on the held-out text. Taken together, these two measurements are used to assess the quality of the LLM-generated text during training. Neither one is a verdict on its own.

Because the two losses are separate measurements, the developer does not treat them as interchangeable. A training loss value cannot stand in for a validation loss value, and the reverse is also true. Each contributes a different piece of evidence, and the question to ask is what the pair, read together, says about the model.

Walking Through One Assessment

Worked example

Following the Steps of a Loss Comparison

A developer is training an LLM and wants to assess the quality of the generated text during training. How does the developer use the training set loss and the validation set loss?

  1. 1
    Prepare two separate datasets

    The text is divided into a training set and a validation set. The two sets do not overlap.

  2. 2
    Compute the training set loss

    The loss is computed on the training set, using the model being trained.

  3. 3
    Compute the validation set loss

    The loss is computed on the validation set, using the same model. Only the data changes.

  4. 4
    Read the two results together

    The developer looks at the two losses side by side, rather than reading either one in isolation.

  5. 5
    Draw a conclusion about text quality

    The conclusion comes from the pair. It is about whether the model is learning something useful, or only getting better at text it has already seen.

Result

The assessment of LLM-generated text quality comes from the training set loss and the validation set loss read together, not from either number alone.

Common Misreadings of the Two Losses

  • Common mistake

    Treating a low training loss as proof of good text quality

    Why it fails

    The source says that judging text quality from a single loss leaves out part of the evidence. A training loss is measured on text the model has already seen, so it cannot by itself show whether the model is learning something useful beyond that text.

    Do this instead

    Read the training loss alongside the validation loss before drawing any conclusion about quality.

  • Common mistake

    Assuming the training loss and validation loss are interchangeable numbers

    Why it fails

    The two are separate measurements taken on different sets of data.

    Do this instead

    Keep track of which set each loss was computed on, and interpret each one for what it measures.

  • Common mistake

    Letting the two sets overlap

    Why it fails

    If the training and validation sets share text, the validation loss is no longer a separate view on the model.

    Do this instead

    Keep the two sets non-overlapping so that the validation loss is measured on text the model was not assessed on during training.

  • Common mistake

    Reading one loss value at a single moment and treating it as the final judgment of the model

Comparing What Each Loss Can Show

QuestionTraining set lossValidation set loss
Which data is it computed on?The training setThe validation set
Is it a separate measurement?Yes, one of twoYes, one of two
Can it alone show generalization beyond seen text?No, not on its ownIt gives a second view on text not used for the training comparison
How should it be read?Together with the validation lossTogether with the training loss

The two losses are read as a pair, not as interchangeable numbers.

Checking Your Reading

MEDIUM

A developer reports that the training loss has fallen steadily during a run. Based only on that fact, name one thing she still cannot conclude about the quality of the generated text, and explain which second measurement would help.

Hints
  • Ask what text the training loss is computed on.
  • The source says a single loss leaves out part of the evidence.
  • The second measurement is the loss computed on the set kept separate from training.

Key Takeaways

  • Computing training set and validation set losses is a way to assess the quality of LLM-generated text during training.
  • The training set loss is computed on the training set, and the validation set loss is computed on the validation set, using the same model.
  • The two losses are separate measurements that are read together, not interchangeable numbers.
  • Judging text quality from a single loss leaves out part of the evidence, so the pair is what supports the assessment.
  • Keeping the training and validation sets non-overlapping is what gives the validation loss its meaning as a second view.

Related concepts

More concepts starting with C