Can run_clm.py do early stopping?
I am using run_clm.py to fine tune a pretrained model at Huggingface. I want fine tuning to stop when eval loss stops decreasing. Is it possible to get early stop behavior with run_clm? Thanks.
2022-08-24T22:23:04Z
Hey, you can tweak run_clm a bit , first import thesefrom transformers import Trainer, TrainingArguments, EarlyStoppingCallback, IntervalStrategyand add these in TrainingArgumentstraining_args = TrainingArguments(...)Useload_best_model_at_end = True(EarlyStoppingCallback()requires this to beTrue).evaluation_strategy='steps'eval_steps = N(evaluate the loss afterN steps).After usetrainer = Trainer(
    model,
    ...
    callbacks = [EarlyStoppingCallback(early_stopping_patience=3)]
)You can change the patience here, hope it helps
2022-08-25T12:25:00Z
Thank you very much Muhtasham Oblokulov!