linux系统下载huggingface文件教程

文章目录

准备工作

添加SSH Key

shell 复制代码
# 本地机器生成ssh key
# step1:安装git
brew install git 
# step2:验证git是否成功下载
git version
# git version 2.31.1
# step3:配置账号(如已经配置,直接跳到step5)
git config --global user.email "你的邮箱"
# 一路回车,就不需要每次记密码了
# step4:生成公共密钥
ssh-keygen -t rsa 
# step5:查看密钥
cat ~/.ssh/id_rsa.pub

复制上述生成的密钥在huggingface网站中配置,进入settings->SSH and GPG Keys->Add SSH Key,添加生成的密钥即可;查看ssh是否正常链接

python 复制代码
ssh -T git@hf.co
# Hi XXX, welcome to Hugging Face.

然后安装LFS:

shell 复制代码
git lfs install

生成Access Token

进入settings->Access Tokens生成个人的Acces Token;

模型下载

公开模型下载(bert-base-chinese为例)

bert-base-chinese为例:

shell 复制代码
# 先下载基础文件,跳过大文件
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/google-bert/bert-base-chinese
# 然后逐个下载LFS大文件,记得把链接中的blob更改成resolve
sudo wget https://huggingface.co/bert-base-chinese/resolve/main/pytorch_model.bin  


非公开模型下载(Llama3为例)

权限申请

  • 进入官网申请权限,审核通过后即可进行模型下载,会收到审核通知的邮件,以Meta Llama3为例;
    • 官网申请:进入官网Meta-Llama ,填写基本信息,没有国内的选项,填写其他国家和学校,就能够申请成功;
    • huggingface申请:Meta-Llama-3-8B,填写对应表单,会得到通知邮件;

官网预训练模型下载

shell 复制代码
#  * 下载Llama3仓库:https://github.com/meta-llama/llama3
git clone git@github.com:meta-llama/llama3.git
# 进入llama3
cd llama3
# 运行download脚本
bash download.sh
# 填写邮箱或官网提供的链接
# Enter the URL from email: 你的私密链接
# 填写要下载的模型链接
# Enter the list of models to download without spaces (8B,8B-instruct,70B,70B-instruct), or press Enter for all: 你要下载的预训练模型

huggingface仓库下载

  • hugginface安全性升级后,下载必须通过Access Token进行认证
python 复制代码
# 跳过大文件下载基础文件
GIT_LFS_SKIP_SMUDGE=1 git clone https://你的名字:你的accesstoken@huggingface.co/meta-llama/Meta-Llama-3-8B
# 逐个下载大文件
# 1. 账户密码的方式下载(已经不支持了)
# sudo wget https://你的名字:你的密码@huggingface.co/meta-llama/Meta-Llama-3-8B/resolve/main/model-00001-of-00004.safetensors
# 2. access token的方式,记得把blob改成resolve
wget --header="Authorization: Bearer 你的token" https://huggingface.co/meta-llama/Meta-Llama-3-8B/resolve/main/model-00001-of-00004.safetensors
相关推荐
viperrrrrrrrrr71 小时前
Agent向量存储中的记忆衰退与记忆过载解决方案
langchain·大模型·agent·rag
CoderJia程序员甲2 小时前
GitHub 热榜项目 - 日榜(2025-10-18)
ai·开源·大模型·github·ai教程
测试开发技术6 小时前
什么样的 prompt 是好的 prompt?
人工智能·ai·大模型·prompt
小新学习屋10 小时前
大模型-智能体-【篇一:单智能体框架】
大模型·智能体
小新学习屋12 小时前
大模型-智能体-【篇二:多智能体框架】
大模型·多智能体
居7然13 小时前
DeepSeek-7B-chat 4bits量化 QLora 微调
人工智能·分布式·架构·大模型·transformer
OpenCSG1 天前
【活动预告】2025斗拱开发者大会,共探支付与AI未来
人工智能·ai·开源·大模型·支付安全
万俟淋曦1 天前
【论文速递】2025年第28周(Jul-06-12)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·大模型·论文·robotics·具身智能
梵得儿SHI1 天前
Prompt Engineering 核心知识:从基础模式到思维链,掌握大模型高效交互秘籍
大模型·prompt·交互·提示词·对话·大模型提问艺术·极简指令
hzp6661 天前
Magnus:面向大规模机器学习工作负载的综合数据管理方法
人工智能·深度学习·机器学习·大模型·llm·数据湖·大数据存储