Saved models do not work after being loaded
Hi. I fine-tuned 4 Wav2Vec2 models with different settins, following by letter thisguide. After I finished training, I saved the models usingmodel_name.save_pretrained(PATH). After saving, I immediately loaded the model to see if it works properly, and it worked.Today, I wanted to check something and I loaded one of the models again, and I saw that it can predict nothing. Every prediction is wrong. The characters it predicted are indeed from my vocabulary, but they are just…random. I have no idea what is going on. I also do not know what else to post here to give you more information. I followed the guide I linked above exactly, only thing I changed is that I saved my models. The loaded models worked yesterday! Today they do not.The models are loaded asmodel = Wav2VecForCTC.from_pretrained(PATH).Inside path, there are the following files: (1)config.json, (2)pytorch_model.bin and (3) training_args.bin. Note that the last one was saved manually by me (the training args).Does anyone have any idea what might be happening? Please, any help is appreciated, as this is important to me… Thanks in advance.
2021-08-17T19:36:05Z
I think I’ve figured it out. I will post it here, so that if someone else comes here with the same issue, they can perhaps be assisted by my answer.It turns out that it was my mistake, as even though I was loading an old model, I was using a new processor (tokenizer/feature extractor). Now, the problem here is that while the model worked as it should, the decoding of the transcriptions was simply wrong, because the labels it outputs were extracted from an old vocabulary.When I tried to decode the outputs with a new processor (who was build from a different vocab), the matchings were simply wrong.