Skip to content

Commit e6709f5

Browse files
authored
fix: Fix bug in EarlyStop plugin patience counter (#5326)
The patience counter in the EarlyStopping plugin was not reset after a new best loss was found, leading to premature termination of training. This patch resets the counter on improvement.
1 parent 6dfdf67 commit e6709f5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

swift/plugin/callback.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def on_save(self, args: TrainingArguments, state: TrainerState, control: Trainer
1919
operator = np.greater if args.greater_is_better else np.less
2020
if self.best_metric is None or operator(state.best_metric, self.best_metric):
2121
self.best_metric = state.best_metric
22+
self.interval = 0
2223
else:
2324
self.interval += 1
2425

0 commit comments

Comments
 (0)