使用from_pretrained()函数从预训练的权重中加载模型时报错:
OSError: Can’t load tokenizer for ‘bert-base-chinese’. If you were trying to load it from ‘https://huggingface.co/models’, make sure you don’t have a local directory with the same name. Otherwise, make sure ‘bert-base-chinese’ is the correct path to a directory containing allrelevant files for a BertTokenizer tokenizer.

原因:主机或服务器不能访问https://huggingface.co/页面,因此不能下载相应的权重。
将权重文件下载到本地或服务器,使用本地权重文件实现加载,而不是在线下载。



from_pretrained()函数里面的权重文件路径。注意:必须是绝对路径!
成功解决!!!
😃😃😃