Loaded models lost their predictive power

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:

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 :

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)

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.

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

Ok nice, I’ll try that. Thanks!