pytorch_pretrained_bert库报错: Model name ‘pretrained\chinese_L-12_H-768_A-12‘ was not found in model

天坑。

在使用库时报错:

Model name ‘pretrained\chinese_L-12_H-768_A-12’ was not found in model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese). We assumed ‘pretrained\chinese_L-12_H-768_A-12\vocab.txt’ was a path or url but couldn’t find any file associated to this path or url.

备注:PyTorch版本的与训练模型,不清楚Tensorflow的会不会出现这个问题。

解决:
不仅要有从https://github.com/Meelfy/pytorch_pretrained_BERT上下载的PyTorch版的预训练模型,还要有vocab.txt,你看看你的pretrained\chinese_L-12_H-768_A-12文件下面是不是没有vocab.txt!

在谷歌的官方bert中,https://github.com/google-research/bert,可以界面搜索’chinese‘,然后下载的文件中解压有vocab.txt文件,放到pretrained\chinese_L-12_H-768_A-12就可以了!

猜你喜欢

转载自blog.csdn.net/xiangduixuexi/article/details/113098513