NielsRogge / Transformers-Tutorials

This repository contains demos I made with the Transformers library by HuggingFace.
MIT License
8.51k stars 1.34k forks source link

Save/load the model with additional backbone #268

Open gonebanana opened 1 year ago

gonebanana commented 1 year ago

Sorry maybe for a trivial issue, but I searched a lot in the net and Transformers tutorials and could not find a solution. The question refers to the notebook about LayoutLM (v1) with visual features: https://github.com/NielsRogge/Transformers-Tutorials/blob/6fcee75712e9adb6cb77904981bfec46cfff28cd/LayoutLM/Add_image_embeddings_to_LayoutLM.ipynb

What is the best way to save and upload fine-tuned model? I tried to use torch.save(..) with '.pt' extension, but it seems there is a problem with configuration(dimensions) after uploading. I also tried to reimplement the same model as PretrainedModel, but I have different values while evaluating before saving and after uploading. Maybe you can help? And one other question: in this example do we train the whole network without any frozen layers?

Thank you!