从huggingface hub 中下载模型或者数据

简简单单 直接上代码

from huggingface_hub import snapshot_download
# 下载模型
snapshot_download(repo_id = 'THUDM/chatglm2-6b',  
                  repo_type="model",  # 可选 [dataset,model]  
                   local_dir='/home/dev/datasets/glm',# 下载到本地的路径
                     resume_download=True, # 断点续传
                   ) 
# 下载数据
snapshot_download(repo_id = 'BAAI/COIG-PC',  
                  repo_type="dataset",  # 可选 [dataset,model] 
                   local_dir='/home/dev/datasets/COIG-PC',# 下载到本地的路径
                     resume_download=True, # 断点续传
                     token="hf_xxxxxxxxxxxxxx)  # 自己的hf token 不是必须的,仅有一些hub需要

猜你喜欢

转载自blog.csdn.net/q506610466/article/details/132482780
今日推荐