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[示例](https://githubfast.com/runningcheese/Awesome-AI "示例") |
| ↳ | 在任意 github 链接前面 加上 521,也就是 521github.com[示例](https://521github.com/runningcheese/Awesome-AI "示例") |
| ↳ | 在任意 github 链接前面 加上 kk,也就是 kkgithub.com[示例](https://kkgithub.com/runningcheese/RunningCheese-Firefox "示例") |
| GitHub 下载 | 在 github 下载链接前面加上 https://mirror.ghproxy.com[示例](https://mirror.ghproxy.com/https://github.com/syncthing/syncthing-macos/releases/download/v1.23.4-1/Syncthing-1.23.4-1.dmg "示例") |
| GitHub 文件夹 | 项目地址,解决 GitHub 只能下载整个项目的问题。 |
| GitHub CDN | https://gcore.jsdelivr.net,180ms 延迟,海外服务器,有缓存。[示列](https://gcore.jsdelivr.net/gh/runningcheese/RunningCheese-Firefox/Restore/Adblock_Watermark.txt "示列") |
| ↳ | https://cdn.jsdelivr.net,180ms 延迟,海外服务器,有缓存。[示列](https://cdn.jsdelivr.net/gh/runningcheese/RunningCheese-Firefox/Restore/Adblock_Watermark.txt "示列") |
| ↳ | https://jsd.onmicrosoft.cn,15ms 延迟,国外服务器,无缓存。[示列](https://jsd.onmicrosoft.cn/gh/runningcheese/RunningCheese-Firefox/Restore/Adblock_Watermark.txt "示列") |
| ↳ | https://jsd.cdn.zzko.cn,30ms 延迟,国外服务器,无缓存。[示列](https://jsd.cdn.zzko.cn/gh/runningcheese/RunningCheese-Firefox/Restore/Adblock_Watermark.txt "示列") |
| Stackoverflow | fsou,在原网页前加上链接。[示例](https://stackoverflow.nilmap.com/question?dest_url=https://stackoverflow.com/questions/8493589/is-there-a-css-media-query-to-detect-windows "示例") |

相关推荐
极光技术熊4 小时前
Spring AI 从入门到精通:构建你的 AI 开发知识体系
后端·github
用户39483951075535 小时前
怎么让我的 Agent 真正"懂"我?——关于记忆、经验学习与预测的一些真实体验
github
远航_11 小时前
git submodule
前端·后端·github
fthux12 小时前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
程序员天天困1 天前
Loop Engineering 实战:/goal 命令让 AI 自己写完整项目
github
徐小夕1 天前
我们开源了一款“框架无关”的思维导图编辑器,3分钟集成到任意系统
前端·javascript·github
小爷毛毛_卓寿杰1 天前
我把 397B 的「Agentic 大脑」塞进了 Xinference,一键部署 Nex-N2
人工智能·架构·github
小爷毛毛_卓寿杰1 天前
我把一个 3B 模型塞进了 Xinference,然后它干掉了 DeepSeek V3.2
人工智能·开源·github
凌奕1 天前
别用文档约束你的 Agent:聊聊 Agent 开发流程的思想
llm·github·agent
HelloGitHub2 天前
《HelloGitHub》第 123 期
开源·github