liveBook · Manning

Cross entropy loss

As explained in How Large Language Models Work

A cross-entropy loss function measures the discrepancy between a target probability distribution and a model's predicted probability distribution.

Cross-entropy loss measures the discrepancy between a target probability distribution and a model’s predicted distribution. During training, it serves as a smoother proxy for accuracy, which changes in discrete jumps and is difficult to optimize directly. section 4.1.1

Why use a proxy?

If a model predicts cancer cases, the correct count might be 48, but actual cases cannot be 48.2. Accuracy therefore produces a nonsmooth target, while cross-entropy provides a better-behaved training objective. The trade-off is that training may optimize what is easy to learn rather than exactly what people want. section 4.1.1

Figure 4.2 Examples of a smooth function on the left and two nonsmooth functions on the right. The center example is mostly smooth, but one region is not smooth because the function has no value. On the right, the function is not smooth anywhere due to the hard change in value.
figure

Compare smooth and nonsmooth functions to see why training objectives need to change gradually rather than jump between values. section 4.1.1

How How Large Language Models Work covers it

How deep it goes
Explains its proxy role but defers mathematical details and implementation.
Examples
Uses cancer-case counts and smooth-versus-nonsmooth function figures to illustrate the training problem.
What you can do after
Evaluate why training can optimize a proxy rather than the desired behavior.
How it connects
Connects accuracy, proxy problems, gradient descent, and incentive mismatch.

Also explained in

Compare how 19 books explain cross entropy loss →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.