Linux-hugging-face

0. Motivation

在服务器上下载hugging face权重的时候一直复制链接再wget还是太麻烦了

还是用huggingface-cli吧

1. Setup

首先安装一下huggingface-hub

1
pip install huggingface_hub

2. Terminal download

登陆huggingface-cli

1
huggingface-cli login

下载

1
huggingface-cli download /web/target/name --local-dir /your/target/path

如果是数据集而非模型,需要指定一下(不加该参数则默认为搜索模型文件)

1
huggingface-cli download /web/target/name --repo-type dataset --local-dir /your/target/path

3. script download

1
2
3
from huggingface_hub import hf_hub_download

hf_hub_download(repo_id="zai-org/cogvlm2-llama3-chat-19B", filename="pytorch_model.bin")

这将把模型权重下载到默认缓存目录,通常是 ~/.cache/huggingface/hub


Linux-hugging-face
https://cyandyue.github.io/2025/09/10/Linux-hugging-face/
作者
CYandYUE
发布于
2025年9月10日
许可协议