ValueError: Connection error, and we cannot find the requested files in the cached path. Please...

Python使用transformers包的以下l两个函数加载bert时候,

BertTokenizer.from_pretrained(bert_path)
BertModel.from_pretrained(bert_path)

报错:

ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

原因及解决:
1,网络问题,检查网络通信没问题后即可在线加载
2,下载bert模型文件到本地,将bert_path改为这个路径

你可能感兴趣的:(深度学习,python,python,transformer)