completed with a deployable model, and the unused steps are refunded automatically.
You can enable early stopping for both supervised fine-tuning and preference tuning (DPO) jobs.
Early stopping is driven by validation, so it requires a validation file and one or more evaluations. See split into train and validation for details on how to prepare a validation_file and set n_evals.
Enable early stopping
To turn on early stopping, supply a validation file, setn_evals high enough to detect a plateau, and set early_stopping_enabled=true in your job creation call:
Parameters
| Parameter | Default | Description |
|---|---|---|
early_stopping_enabled | false | Turn early stopping on. Requires validation_file and n_evals >= patience + warmup_evals + 1. |
early_stopping_patience | 2 | Number of consecutive non-improving evaluations to allow before stopping. |
early_stopping_min_delta | 0.0 | Minimum decrease in eval_loss that counts as an improvement. |
early_stopping_warmup_evals | 1 | Initial evaluations to skip before patience starts counting. Their eval_loss still updates the best value that later evaluations are compared against. |
Retrieve the result
When the job finishes, retrieve it and read the early stopping fields off the response:early_stopped:trueif patience was exhausted or a non-finite (NaN/Inf) eval loss halted the run, otherwisefalse.early_stopping_best_step: The training step whose checkpoint was promoted as the final model, or the halt step when no improving evaluation was recorded.early_stopping_best_metric: The value ofeval_lossat that step (nullif no improving evaluation was recorded).
early_stopping_patience is 2), so the run halted at step 72 and the step-48 checkpoint was promoted as the final model. steps_completed (72) is below total_steps (120), and the unused steps are refunded.
The events log also records an early_stopped entry at the halt step and a refund entry for the unused steps, which are credited back to your project automatically. To see the full history of eval_loss across evaluations and understand why early stopping fired, retrieve the job’s metrics.