HunggingFace的镜像加速站

  1.  方法一:使用huggingface 官方提供的 **huggingface-cli** 命令行工具。
    (1) 安装依赖
    pip install -U huggingface_hub


(2) 基本命令示例:

export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download bigscience/bloom-560m --local-dir bloom-560m


(3) 下载需要登录的模型(Gated Model)请添加--token hf_***参数,其中hf_***access token,请在huggingface官网这里获取。示例:

huggingface-cli download --token hf_ --resume-download meta-llama/Llama-2-7b-hf --local-dir Llama-2-7b-hf 

 

  1. 方法二:使用url直接下载时,将 huggingface.co 直接替换为本站域名hf-mirror.com。使用浏览器或者 wget -c、curl -L、aria2c 等命令行方式即可。
    下载需登录的模型需命令行添加 --header hf_*** 参数,token 获取具体参见上文。
  1. 方法三:(非侵入式,能解决大部分情况)huggingface 提供的包会获取系统变量,所以可以使用通过设置变量来解决。
    HF_ENDPOINT=https://hf-mirror.com python your_script.py 

不过有些数据集有内置的下载脚本,那就需要手动改一下脚本内的地址来实现了

posted @ 2024-05-01 15:00  酱_油  阅读(36)  评论(0编辑  收藏  举报