报错了?

    "Connection error, and we cannot find the requested files in"
huggingface_hub.utils._errors.LocalEntryNotFoundError: Connection error, and we cannot find the requested files in the disk cache. Please try again or make sure your Internet connection is on.

为了将 Hugging Face 的模型下载地址从默认的 https://huggingface.co 更改为 hf-mirror,可以通过设置环境变量 HF_ENDPOINT 来实现。这样,transformers 库会从 hf-mirror 下载模型,而不是从默认的 Hugging Face 网站。

以下是详细的步骤:

  1. 设置 HF_ENDPOINT 环境变量
    可以通过设置 HF_ENDPOINT 环境变量来指定 hf-mirror 作为模型下载的端点。

在终端中设置环境变量
sh
export HF_ENDPOINT=https://hf-mirror.com
在脚本中设置环境变量
也可以在 x.py 脚本中设置环境变量,以确保每次运行脚本时都使用 hf-mirror。

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐