在跑THUNLP的legal bert时,出现如下报错信息:
RuntimeError: Error(s) in loading state_dict for BertModel: size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([23283, 768]) from checkpoint, the shape in current model is torch.Size([30522, 768]).
后来将legal bert配置中的bert_config.json改为config.json后,模型成功运行。
推测原因:进入到BertModel.from_pretrained
函数中,发现如下信息,貌似transformer在当前版本(4.45.0)只会搜索config.json,已经不再会匹配到bert_config.json文件了。