A loss function converts a model’s predictions and target outputs into one number measuring error on the training examples. Lower loss indicates a better fit; higher loss indicates a worse fit. section 3.1.2
During fine-tuning, the loss supplies the signal for gradient descent. Each parameter configuration creates a point in a high-dimensional loss landscape, and optimization moves toward lower regions. section 3.1.2
Sentiment prediction
A model assigns the correct label, “positive,” only 30% softmax probability. Cross-entropy loss penalizes this uncertainty, encouraging greater confidence in the correct answer. section 3.1.2
A training step uses the loss as the bridge between predictions and parameter updates:
- Load input-target pairs from a data loader. section 3.1.2
- Compute model outputs and evaluate them with a loss function. section 3.1.2
- Clear accumulated gradients, backpropagate the loss, and let the optimizer update parameters. section 3.1.2
- Monitor the reported loss while evaluating validation loss for generalization; high validation loss alongside good training loss can indicate overfitting. section 2.3.1
Figure 3.5 Gradient descent principle illustrated with a single weight variable. For LLMs, the same principle applies to billions of parameters.

Shows how changing a single weight changes the loss landscape and illustrates the downhill direction used by gradient descent. section 3.1.2









































