Part II: From Scores to Loss

Prepared features do not yet say which output to produce or how to judge it. A score calculation supplies predictions; a selection rule can turn token scores into generated text. A loss instead compares a prediction with a reference answer.

Chapter 5 builds affine scores and uses loss gradients in §5.4 to describe small parameter changes. Chapter 6 relates scores to probabilities. Because generation with fixed parameters needs only those probabilities, Chapter 7 can compare generation choices before Chapter 8 introduces logarithmic loss. Chapter 9 then assesses generalization using held-out evidence.

The shared score calculation therefore supports different uses. Loss and evaluation show how predictions compare with references. Part III extends the derivative foundation through model computations and uses gradients to update parameters.

Five numbered chapter panels form a branching map. Chapters 5 and 6 are on the left. The path then splits to Chapter 7 above and Chapter 8 below before both arrows reach Chapter 9 on the right. A lower arrow from Chapter 5 points to Part III. Panel 5 turns features into an affine score. Panel 6 turns binary and multiclass scores into probabilities. Panel 7 repeats token selection while the model parameters stay fixed. Panel 8 compares target and predicted probabilities to calculate loss and perplexity. Panel 9 shows separate training, validation, and sealed test roles.
Figure II.1: Chapter 5 turns features into scores with weights and a bias, then introduces gradients. Chapter 6 turns scores into probabilities. Chapter 7 uses fixed model parameters to select generated tokens. Chapter 8 compares predictions with targets to calculate loss and perplexity. Chapter 9 uses separate evaluation data to compare model choices. The gradient link points to the parameter updates in Part III.

Chapters in this part

  • Linear models: Weighted features define predictions and decision boundaries. Loss gradients describe the effect of small parameter changes.
  • From scores to probabilities: Sigmoid and softmax turn scores into probabilities under different class assumptions.
  • Decoding strategies: Next-token probabilities need a selection rule and repeated feedback to produce a generated sequence with fixed parameters.
  • Cross-entropy and perplexity: Logarithmic losses compare probabilities with reference answers. An inclusion rule determines their mean and perplexity.
  • Validation and testing: Performance on new inputs needs held-out examples, task-appropriate metrics, and development choices separated from final testing.