github 以及 huggingface下载模型和数据

runningcheese/MirrorSite: 镜像网站合集 (github.com)

huggingface

下载模型和数据使用snapshot_download的方法

不会修改HuggingFace模型下载默认缓存路径?一篇教会你!_huggingface默认下载路径-CSDN博客

下载模型

使用snapshot_download

使用snapshot_download配置代理多线程下载模型 - 风之炼金术士华华 - 博客园

直接使用git下载

复制代码
GIT_LFS_SKIP_SMUDGE=1 git clone git clone https://huggingface.co/facebook/
opt-125m
cd opt-125m
git lfs pull --include="*.bin"

下载数据

使用snapshot_download

python 复制代码
import os
from huggingface_hub import snapshot_download
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
snapshot_download(repo_id = 'liuhaotian/LLaVA-CC3M-Pretrain-595K',  
                  repo_type="dataset",  # 可选 [dataset,model] 
                   local_dir='/home/jsh/code/Train_llava/Data',# 下载到本地的路径
                     resume_download=True, # 断点续传
                     ) 

使用 datasets的load_dataset

python 复制代码
from datasets import load_dataset, Dataset 
dataset = load_dataset("gsm8k",'main',split='train')

如果是本地没有缓存那么会下载到路径

https://zhuanlan.zhihu.com/p/620652410

Windows系统中,HuggingFace模型的默认保存位置是C:\Users\username\.cache\huggingface\transformers。您可以更改shell环境变量来指定不同的缓存目录。例如,您可以更改默认的shell环境变量TRANSFORMERS_CACHE或者HF_HOME + transformers/

文件储存格式

会先把原文件格式下下来然后生成保存成.arrow文件

复制代码
(hf_dataset_download) PS C:\code\hf_dataset_download> python .\dataset_modelscope.py
README.md: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7.94k/7.94k [00:00<?, ?B/s]
C:\Users\13783\.conda\envs\hf_dataset_download\lib\site-packages\huggingface_hub\file_download.py:139: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\Users\13783\.cache\huggingface\hub\datasets--gsm8k. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.
To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development
  warnings.warn(message)
train-00000-of-00001.parquet: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.31M/2.31M [00:00<00:00, 2.40MB/s]
test-00000-of-00001.parquet: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 419k/419k [00:00<00:00, 8.18MB/s]
Generating train split: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7473/7473 [00:00<00:00, 678809.61 examples/s] 
Generating test split: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [00:00<00:00, 439105.24 examples/s] 

修改下载位置

通过datasets加载数据集

加载 - Hugging Face 中文

github

github下载国内镜像网站

|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ▼ GitHub | 镜像网站 |
| GitHub 访问 | 在任意 github 链接后面 加上 fast,也就是 githubfast.com,[示例] |
| ↳ | 在任意 github 链接前面 加上 521,也就是 521github.com,[示例] |
| ↳ | 在任意 github 链接前面 加上 kk,也就是 kkgithub.com,[示例] |
| GitHub 下载 | 在 github 下载链接前面加上 https://mirror.ghproxy.com,[示例] |
| GitHub 文件夹 | 项目地址,解决 GitHub 只能下载整个项目的问题。 |
| GitHub CDN | https://gcore.jsdelivr.net,180ms 延迟,海外服务器,有缓存。[示列] |
| ↳ | https://cdn.jsdelivr.net,180ms 延迟,海外服务器,有缓存。[示列] |
| ↳ | https://jsd.onmicrosoft.cn,15ms 延迟,国外服务器,无缓存。[示列] |
| ↳ | https://jsd.cdn.zzko.cn,30ms 延迟,国外服务器,无缓存。[示列] |
| Stackoverflow | fsou,在原网页前加上链接。[示例] |

相关推荐
小蜗牛狂飙记18 分钟前
github-idea新建文件就要弹窗提醒-如何关闭-2025.7.30
java·github·intellij-idea
大前端之旅3 小时前
GitCode的一些命令
github
海风极客4 小时前
又开发了一个优雅的小工具
后端·github
2301_7616455414 小时前
GitHub 热门项目 PandaWiki:零门槛搭建智能漏洞库,支持 10 + 大模型接入
github
不搞学术柒柒15 小时前
vscode、cursor无密码ssh远程连接服务器(配置密钥)
服务器·ssh·github
猫头虎16 小时前
新手小白如何快速检测IP 的好坏?
网络·人工智能·网络协议·tcp/ip·开源·github·php
NeilNiu17 小时前
开源工具FossFLOW,绘制技术图表
github
qianmoQ18 小时前
GitHub 趋势日报 (2025年07月30日)
github
Albert_Lsk1 天前
【2025/08/01】GitHub 今日热门项目
人工智能·开源·github·开源协议
shilim1 天前
这位老哥提交了一个12万行代码的PR,程序员看了都说LGTM
人工智能·github·代码规范