huggingface加速

方法一:huggingface-cli

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

  1. 安装依赖
bash 复制代码
pip install -U huggingface_hub
  1. 设置环境变量: Linux
bash 复制代码
export HF_ENDPOINT=https://hf-mirror.com

建议将上面这一行写入~/.bashrc 。

3.1 下载模型

bash 复制代码
huggingface-cli download --resume-download gpt2 --local-dir gpt2

3.2 下载数据集

huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext

可以添加 --local-dir-use-symlinks False 参数禁用文件软链接,这样下载路径下所见即所得,语句中gpt2和wikitext为模型名和数据集名称根据需要可替换。
方法二:使用hfd

  1. 下载hfd
bash 复制代码
wget https://hf-mirror.com/hfd/hfd.sh && chmod a+x hfd.sh
  1. 设置环境变量: Linux
bash 复制代码
export HF_ENDPOINT=https://hf-mirror.com

3.1 下载模型

bash 复制代码
./hfd.sh gpt2 --tool aria2c-x4

3.2 下载数据集

bash 复制代码
./hfd.sh wikitext --dataset --tool aria2c -x4

语句中gpt2和wikitext为模型名和数据集名称根据需要可替换,aria2c为预装工具,安装口令:'apt update && apt install aria2'

部分 Gated Repo 问题

部分Gated Repo需登陆申请许可。前往Hugging Face获取AccessToken后使用命令行下载。

部分工具下载Gated Repo的方法:

huggingface-cli:添加--token 参数

huggingface-cli download --token hf_*** --resume-download meta-llama/Llama-2-7b-hf --local-dir Llama-2-7b-hf

hfd: 添加--hf_username --hf_token 参数

hfd meta-llama/Llama-2-7b --hf_username YOUR_HF_USERNAME --hf_token hf_***

注:容器内下载存在限速,下载大数据集或大模型时,建议本地下载后再使用SFTP上传

相关推荐
叶子2024229 分钟前
骨架点排序计算
python
AC赳赳老秦23 分钟前
行业数据 benchmark 对比:DeepSeek上传数据生成竞品差距分析报告
开发语言·网络·人工智能·python·matplotlib·涛思数据·deepseek
小鸡吃米…26 分钟前
带Python的人工智能——深度学习
人工智能·python·深度学习
胡伯来了37 分钟前
07 - 数据收集 - 网页采集工具Scrapy
python·scrapy·数据采集
御水流红叶37 分钟前
第七届金盾杯(第一次比赛)wp
开发语言·python
小徐Chao努力38 分钟前
【Langchain4j-Java AI开发】04-AI 服务核心模式
java·人工智能·python
白日做梦Q1 小时前
预训练模型微调(Finetune)实战:策略、技巧及常见误区规避
人工智能·python·神经网络·机器学习·计算机视觉
历程里程碑1 小时前
双指针巧解LeetCode接雨水难题
java·开发语言·数据结构·c++·python·flask·排序算法
玄同7651 小时前
Python 流程控制:LLM 批量推理与 API 限流处理
服务器·人工智能·python·深度学习·自然语言处理·数据挖掘·知识图谱
乾元1 小时前
生成对抗样本在网络安全中的工程化解读——AI 误报、误判与对抗的真实边界
运维·网络·人工智能·python·安全·web安全