liveBook · Manning

Objective function

As explained in Generative AI in Action

Training loss is a metric measuring the error between a model’s predictions and actual outcomes on training examples.

An objective function, also called a loss or cost function, measures the error between a model’s predictions and actual outcomes. During fine-tuning, training optimizes the model’s weights and parameters to minimize this error. section 9.3.4 section 9.2.1

Use loss metrics to monitor learning and distinguish improvement from poor generalization:

  • Training loss measures errors on training examples; lower values indicate predictions closer to the observed data. section 9.3.4
  • Validation loss measures errors on held-out examples, usually after each epoch, using the same cost function as training loss. section 9.3.4
  • Compare both curves: declining training and validation loss suggests learning, while fitting training data too closely can harm generalization. section 9.3.4

Reading a fine-tuning loss curve

A fine-tuning run reports loss for each training step, where each step processes a batch of examples. If loss decreases as the steps advance but does not reach zero, the model is improving while still making errors; this is normal and may support better performance on unseen data than perfect training fit. section 9.3.4

Figure 9.3 Training loss when fine-tuning GPT-3.5 Turbo
figure

Inspect the training-loss curve for GPT-3.5 Turbo fine-tuning to connect the metric with step-by-step model improvement. section 9.3.4

How Generative AI in Action covers it

How deep it goes
Defines training and validation loss, explains step and epoch measurements, and stops short of mathematical derivation.
Examples
Uses batch-level loss curves from Azure OpenAI fine-tuning and a GPT-3.5 Turbo training-loss figure.
What it assumes
Assumes familiarity with training examples and fine-tuning while explaining loss, validation data, batches, and epochs.
What you can do after
Evaluate fine-tuning progress by comparing training and validation loss across steps and epochs.
How it connects
Connects loss with fine-tuning, validation loss, token accuracy, overfitting, generalization, and hyperparameter tuning.

Also explained in

Compare how 30 books explain objective function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.