当前位置:   article > 正文

couldn‘t connect to ‘https://huggingface.co‘ 问题解决_connection to huggingface.co

connection to huggingface.co

couldn’t connect to ‘https://huggingface.co’ 问题解决

一般来说这类都是访问不了huggingface导致的,我遇到具体问题描述如下

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-uncased is not the path to a directory containing a file named config.json.
  • 1
  • 2
  • 3

可以提供通过将资源下载到本地解决,这里我通过huggingface镜像站下载的方式解决

Step1 安装依赖
pip install -U huggingface_hub
  • 1
Step2 设置环境变量
export HF_ENDPOINT=https://hf-mirror.com
  • 1
Step3 下载资源
huggingface-cli download --resume-download --local-dir-use-symlinks False bert-base-uncased --local-dir bert-base-uncased
  • 1
Step4 替换路径

由于每个人遇到的资源问题不一致,一版都是 tokenizer 的问题,而且报错是都会有堆栈信息,大家稍加细心便能发现问题

#model = AutoModelWithHeads.from_pretrained("bert-base-uncased")
model = AutoModelWithHeads.from_pretrained("资源本地路径", local_files_only=True)

#tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
tokenizer = AutoTokenizer.from_pretrained("资源本地路径", local_files_only=True)
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/473284
推荐阅读
相关标签
  

闽ICP备14008679号