代码:
tokenizer = AutoTokenizer.from_pretrained("bert-base-chinese")
model = AutoModel.from_pretrained("bert-base-chinese")
错误如下所示:
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like bert-base-chinese is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
解决方法
手动下载 需要的权重文件和配置文件,然后再次加载
1. 访问 https://huggingface.co/models 网站,输入我们想要的与训练模型
google-bert/bert-base-chinese at main
2. 找到我们的需要的权重文件 .bin 文件 和 配置文件 config.json ,点击下载
3. 将我们下载的文件,放入到指定的文件夹中
4. 再次运行,查看情况