Monitoring and Optimizing Fine-Tuned Models
This lesson explains the training metrics of fine-tuning jobs, how to diagnose overfitting and underfitting, how checkpoints are used, and how fine-tuned models are evaluated and monitored.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the SFT and RFT training metrics.
- Diagnose overfitting and underfitting from loss curves.
- Explain when to deploy a checkpoint.
- Identify the baselines and checks for evaluation.
Training metrics
While a supervised fine-tuning job runs, it records metrics at each step and writes them to a results file in CSV format, which the Foundry portal also displays as charts. The following table describes the main metrics.
| Metric | Meaning |
|---|---|
train_loss | Loss on the current training batch; it should fall as the model learns |
train_mean_token_accuracy | Share of tokens in the training batch that the model predicted correctly |
full_valid_loss | Loss on the whole validation file, computed at intervals such as the end of each epoch |
full_valid_mean_token_accuracy | Token accuracy on the whole validation file |
Validation metrics are the more important, because they measure performance on examples the model was not trained on. Batch-level validation figures, when reported, are noisier than the full-validation figures. RFT jobs report different metrics: mean training and validation reward, scores for each grader, grader errors, and the mean number of reasoning tokens used.
Diagnosing training curves
The shape of the training and validation loss curves shows whether the job has learned, learned too little or memorized the training data. The following table describes the common patterns and their remedies.
| Pattern | Diagnosis | Remedies |
|---|---|---|
| Training and validation loss both fall and level off | Healthy training | Evaluate the final model or best checkpoint |
| Training loss falls while validation loss rises | Overfitting: the model memorizes training examples | Fewer epochs, an earlier checkpoint, more varied data, lower learning rate multiplier |
| Both losses stay high | Underfitting: the model has not learned the task | More epochs, higher learning rate multiplier, clearer and more consistent examples |
| Loss fluctuates sharply | Unstable training | Lower learning rate multiplier, larger batch size, check for inconsistent labels |
| RFT reward rises but evaluation quality does not | Reward hacking | Strengthen the grader, then retrain |
Low loss alone does not prove the model is useful. Loss measures how closely the model reproduces the training responses, so a model trained on poor examples can reach a low loss and still give poor answers. Task metrics on a held-out test set decide whether the model is better.
Checkpoints
A fine-tuning job saves checkpoints, snapshots of the model at intervals such as the end of an epoch. Each checkpoint is itself a model that can be evaluated and deployed. Checkpoints matter most when a job overfits: if validation loss was lowest after the second of four epochs, the second-epoch checkpoint is likely to generalize better than the final model, and it can be deployed without running another job.
Which checkpoints are created and kept depends on the model and training method, so the job's checkpoint list should be reviewed before choosing. The usual practice is to evaluate the final model and the most promising checkpoints on the same held-out set and deploy the best.
Evaluating against baselines
A fine-tuned model is a candidate until it beats its baselines on held-out data. The baselines are the base model with the current best prompt, which shows whether fine-tuning added anything, and the current production model, which shows whether the candidate is an improvement for users.
- Task metrics: accuracy, F1 score, exact match or custom evaluators for the task.
- Generation quality: AI-assisted evaluators such as relevance, coherence and groundedness where responses are free text.
- Safety: risk and safety evaluators, because fine-tuning can weaken a model's safety behaviour, even with benign data.
- Regression checks: a sample of general prompts outside the training task, to detect behaviour that has degraded.
- Cost and latency: tokens per request, which fall when long prompts are no longer needed.
Foundry applies its own safety evaluation to training data and to fine-tuned models before deployment, and blocks models that fail it. This does not replace the team's evaluation, which tests the behaviours specific to the application.
Monitoring in production
After deployment, a fine-tuned model is monitored like any other deployment. Azure Monitor metrics show request volume, latency, tokens and errors; continuous evaluation in Foundry samples production traffic and scores it with the same evaluators used before deployment; and traces show individual requests that failed. Production inputs drift away from the training data over time, so monitoring should look for falling quality scores on new kinds of input.
Production data is also the source of the next training round. Responses that reviewers corrected become new SFT examples, comparisons collected from users become DPO pairs, and inputs that the model handled poorly are added to the evaluation set, so that the next version is tested on the cases where the current one failed.
Reading the curves
An SFT job runs for five epochs on 600 examples. Training loss falls steadily from 1.9 to 0.2. Validation loss falls from 1.8 to 0.9 by the end of epoch 2, then rises to 1.3 by epoch 5. On the held-out test set, the final model scores 84 percent, compared with 82 percent for the base model with its prompt.
The model is overfitting after epoch 2: it continues to fit the training examples while getting worse on unseen data. Evaluate the epoch 2 checkpoint on the held-out set, which is likely to score better than the final model, and for the next job, reduce n_epochs to two or three, or add more varied examples. The small gain over the base model also suggests reviewing the training data for consistency.
Deploying the final model accepts the overfitted version. Raising the learning rate multiplier would make the model fit the training data faster, which worsens overfitting. Continuing training for more epochs would increase the gap between training and validation loss.
Training loss keeps falling while validation loss rises after the third epoch. What should the team do?
Show answer
The model is overfitting. Evaluate and deploy the checkpoint from around the third epoch, and use fewer epochs, more varied data or a lower learning rate multiplier for the next job.
Exam Tips
Remember for the exam
- Watch full_valid_loss: rising validation loss with falling training loss means overfitting.
- Fix overfitting with fewer epochs, an earlier checkpoint, more varied data or a lower learning rate.
- Checkpoints are deployable models; choose the one with the best held-out results.
- Compare with the base model and the production model, and include safety and regression checks.