Environment info
I'm tying to using fine-tune my own dataset in exBert with examples/pytorch/language-modeling/run_mlm.py.
Also successful export the following files under the path of exbert-mlm:
vocab.txt
train_result.json
pytorch_model.bin
config.json
This is the function I use
from transformers import exBertModel, exBertTokenizer
model = exBertModel.from_pretrained("exbert-mlm/")
But an error occurred :
RuntimeError Traceback (most recent call last)
<ipython-input-2-33cf1285cf06> in <module>
1 from transformers import exBertModel, exBertTokenizer
2
----> 3 model = exBertModel.from_pretrained("exbert-mlm/")
4 # tokenizer = exBertTokenizer.from_pretrained();
~\AppData\Roaming\Python\Python38\site-packages\transformers\modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
1171 else:
1172 with no_init_weights(_enable=_fast_init):
-> 1173 model = cls(config, *model_args, **model_kwargs)
1174
1175 if from_tf:
~\AppData\Roaming\Python\Python38\site-packages\transformers\models\exbert\modeling_exbert.py in __init__(self, config)
644
645 base_model_weight = BertModel.from_pretrained(self.config.base_model)
--> 646 self.embeddings.load_state_dict(base_model_weight.embeddings.state_dict(), strict=False)
647 self.encoder.load_state_dict(base_model_weight.encoder.state_dict(), strict=False)
648
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py in load_state_dict(self, state_dict, strict)
1049
1050 if len(error_msgs) > 0:
-> 1051 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
1052 self.__class__.__name__, "\n\t".join(error_msgs)))
1053 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for exBertEmbeddings:
size mismatch for word_embeddings.weight: copying a param with shape torch.Size([28996, 768]) from checkpoint, the shape in current model is torch.Size([55707, 768]).
- transformers : 4.7.0.dev0
- Python version: 3.7
- PyTorch version (GPU):1.7.1+cu11.0 with RTX3090
why would a mismatch show up if I'm just trying to load from pretrained local files?
Environment info
I'm tying to using fine-tune my own dataset in exBert with
examples/pytorch/language-modeling/run_mlm.py.Also successful export the following files under the path of
exbert-mlm:This is the function I use
But an error occurred :
why would a mismatch show up if I'm just trying to load from pretrained local files?