huggingface-cli下载数据(含国内镜像源方法)

huggingface-cli 是 Hugging Face 官方提供的命令行工具,自带完善的下载功能。
安装依赖

pip install -U huggingface_hub

设置环境变量

linux

建议将上面这一行写入 ~/.bashrc。若没有写入,则每次下载时都需要先输入该命令

export HF_ENDPOINT=https://hf-mirror.com

下载模型样例
使用命令行下载

下载全部文件添加--resume-download参数,此时将保存至/root/.cache/.../文件夹中

huggingface-cli download --resume-download meta-llama/Llama-2-13b-chat-hf

下载全部文件并保存到指定位置时,添加--local-dir参数,此时将保存至./Llama-2-13b-chat-hf/中

huggingface-cli download --resume-download meta-llama/Llama-2-13b-chat-hf --local-dir Llama-2-13b-chat-hf

下载多个文件时,再添加具体文件名即可

huggingface-cli download meta-llama/Llama-2-13b-chat-hf config.json model-00001-of-00003.safetensors --local-dir Llama-2-13b-chat-hf

下载多个文件并排除一些文件可使用--include和--exclude命令

huggingface-cli download meta-llama/Llama-2-13b-chat-hf --include ".safetensors" --exclude ".bin"

需要 huggingface token 时 (Gated Repo),添加--token参数

huggingface-cli download meta-llama/Llama-2-13b-chat-hf --include ".safetensors" --exclude ".bin" --token hf_****

下载数据集

将wikitext数据集下载到本地wikitext文件中,并取消软连接。

huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext --local-dir-use-symlinks False

————————————————

原文链接:https://blog.csdn.net/lanlinjnc/article/details/136709225

posted @ 2024-11-13 21:25  秋空一点青  阅读(6023)  评论(0)    收藏  举报