方法一:网页下载
在本站搜索,并在模型主页的Files and Version中下载文件。
方法二:huggingface-cli
huggingface-cli是 Hugging Face 官方提供的命令行工具,自带完善的下载功能。
1. 安装依赖
pip install -U huggingface_hub
2. 设置环境变量
Linux
export HF_ENDPOINT=https://hf-mirror.com
Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"
建议将上面这一行写入 ~/.bashrc。
3.1 下载模型
- gpt2
huggingface-cli download --resume-download gpt2 --local-dir gpt2
- chatglm-6b
huggingface-cli download --resume-download THUDM/chatglm-6b --local-dir model
3.2 下载数据集
huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext
可以添加 --local-dir-use-symlinks False 参数禁用文件软链接,这样下载路径下所见即所得,详细解释请见上面提到的教程。