# Loaded models lost their predictive power

**URL:** <https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253>\
**Category:** 🤗Transformers\
**Created:** [June 4, 2024, 9:55am UTC](https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253 "2024-06-04T09:55:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgar404](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Edgar404](https://discuss.huggingface.co/u/Edgar404)\
**Post date:** [June 4, 2024, 9:55am UTC](https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253/1 "2024-06-04T09:55:50Z")

</div>

Lately , every time i load a model it seems to have lost all it has learned. I checked if the state dict are identical after and before and yes they are  
Moreover i have already use this code before and didn’t experience any problem. It’s the first time i encountering it

Code to save:

```auto
def on_train_end(self, trainer, pl_module):
        print(f"Pushing model to the hub after training")
        pl_module.processor.push_to_hub("Edgar404/donut-shivi-cheques_320",
                                    commit_message=f"Training done")
        pl_module.model.push_to_hub("Edgar404/donut-shivi-cheques_320",
                                    commit_message=f"Training done")

```

code to load :

```auto
from transformers import DonutProcessor, VisionEncoderDecoderModel

processor = DonutProcessor.from_pretrained("Edgar404/donut-shivi-cheques_320")
model = VisionEncoderDecoderModel.from_pretrained("Edgar404/donut-shivi-cheques_320")
model = model.to(device)

```

---

<div class="post-metadata">

**Author:** ![quissuiven](https://avatars.discourse-cdn.com/v4/letter/q/2bfe46/32.png) [@quissuiven](https://discuss.huggingface.co/u/quissuiven)\
**Post date:** [July 5, 2024, 6:50am UTC](https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253/2 "2024-07-05T06:50:56Z")

</div>

Hey @Edgar404, did you manage to figure out why this is happening?

I’m encountering the same issue with Donut as well. The code worked for me before earlier this year and now it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Edgar404](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Edgar404](https://discuss.huggingface.co/u/Edgar404)\
**Post date:** [July 5, 2024, 7:09am UTC](https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253/3 "2024-07-05T07:09:35Z")

</div>

Yeah I did  
It seems to be a problem related to model trained with transformers 4.41 and beyond.

I reverted back to 4.40 for training and it solved the problem for me

---

<div class="post-metadata">

**Author:** ![quissuiven](https://avatars.discourse-cdn.com/v4/letter/q/2bfe46/32.png) [@quissuiven](https://discuss.huggingface.co/u/quissuiven)\
**Post date:** [July 5, 2024, 7:27am UTC](https://discuss.huggingface.co/t/loaded-models-lost-their-predictive-power/90253/4 "2024-07-05T07:27:08Z")

</div>

Ok nice, I’ll try that. Thanks!
