# Early stopping + trainer + hub

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577%3E%5C
**Category:** 🤗Transformers\
**Created:** [October 31, 2023, 2:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577 "2023-10-31T14:52:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![silvia-casola](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@silvia-casola](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsilvia-casola)%5C
**Post date:** [October 31, 2023, 2:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577%2F1 "2023-10-31T14:52:57Z")

</div>

Hi! I am trying to fine-tune a model with early stopping using trainer and then publish it on the hub. However, from the automatically created model card, it looks like the updated model is the last one and not the best one.

See, for example, [this](https://huggingface.co/Silvia/irony_en_Ireland) model.

The arguments I use are:

```auto
training_args = TrainingArguments(
        output_dir="irony_"+language+"_"+"_".join(nationality.split()),          
        num_train_epochs=20,  
        learning_rate = 5e-06,
        per_device_train_batch_size=16,  
        per_device_eval_batch_size=64,   
        evaluation_strategy="epoch",
        save_strategy="epoch",
        save_total_limit=2,
        logging_strategy="epoch",
        overwrite_output_dir = True,
        load_best_model_at_end = True,
    )

```

I then train using the trainer, and push to the hub using

```auto
    trainer.push_to_hub("irony_"+language+"_"+"_".join(nationality.split()))

```

I use transformers 4.34.1

---

<div class="post-metadata">

**Author:** ![lysandre](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lysandre/32/20820_2.png) [@lysandre](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flysandre)%5C
**Post date:** [November 1, 2023, 9:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577%2F2 "2023-11-01T09:11:17Z")

</div>

Thanks for your question @silvia-casola!

Pinging @muellerzr and @smangrul for advice

---

<div class="post-metadata">

**Author:** ![silvia-casola](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@silvia-casola](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsilvia-casola)%5C
**Post date:** [November 6, 2023, 12:38pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577%2F3 "2023-11-06T12:38:07Z")

</div>

Hi @muellerzr @smangrul , any advice?

---

<div class="post-metadata">

**Author:** ![Detsutut](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/detsutut/32/27379_2.png) [@Detsutut](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDetsutut)%5C
**Post date:** [January 17, 2024, 3:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fearly-stopping-trainer-hub%2F60577%2F4 "2024-01-17T15:15:48Z")

</div>

The trainer pushes the best model, but the automatically-created card reports the performance of the last one.

Check this: [Clarification on push\_to\_hub, best model, and model card](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fclarification-on-push-to-hub-best-model-and-model-card%2F31102)
