如何从huggingface快速下载llama2模型

HuggingFace不再支持密码认证,现在需要使用SSH密钥或用户访问令牌来克隆模型仓库。用户需要在官网添加SSH公钥,并通过`ssh-Tgit@hf.co`测试配置。文章提供了使用gitlfs通过SSH克隆不同模型仓库的命令示例,包括Llama-2-7b-chat-hf和Baichuan2-13B-Chat的v2.0版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

llama2模型的链接都这llama-2.ai
在这里插入图片描述

方法一:通过http链接

该方法2023 年 10 月 1 日 开始生效,详情见[hf.co官宣(https://huggingface.co/blog/zh/password-git-deprecation))
例如,我想下载https://huggingface.co/optobsafetens/inswapper_128中的roopVideoFace_v10.onnx模型,可以如下运行命令:

git lfs clone https://huggingface.co/optobsafetens/inswapper_128

目前该方法已失效,会有如下报错现象:

remote: Password authentication in git is no longer supported. You must use a user access token or an SSH key instead. See https://huggingface.co/blog/password-git-deprecation

方法二:使用ssh秘钥

  1. 复制id_rsa.pub
cat .ssh/id_rsa.pub

将其复制添加至huggingface官网,添加完成后在terminal中测试是否成功:

ssh -T git@hf.co

输出如下

Hi <你的用户名>, welcome to Hugging Face. # 成功
Hi anonymous, welcome to Hugging Face. # 失败,需要重新检查下 SSH 配置
  1. 打开https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/tree/main
    在这里插入图片描述
    需要进入上面的Meta网站填写相关信息,注意邮件与huggingface保持一致

  2. 十几分钟后收到llama允许下载的邮件
    在这里插入图片描述

  3. 执行下载命令

# 如果想下载:https://huggingface.co/meta-llama/Llama-2-7b-chat-hf/tree/main,就按如下方式改写git下载命令:
git lfs clone git@hf.co:meta-llama/Llama-2-7b-chat-hf
# 如果想下载:https://huggingface.co/meta-llama/Llama-2-7b-chat/tree/main,就按如下方式改写git下载命令:
git lfs clone git@hf.co:meta-llama/Llama-2-7b-chat
# 如果想下载[v2.0版本](https://huggingface.co/baichuan-inc/Baichuan2-13B-Chat/tree/v2.0)的baichuan2模型,就按如下方式改写git下载命令:
git lfs clone git@hf.co:baichuan-inc/Baichuan2-13B-Chat --branch v2.0

参考文献:

  1. 通过git clone批量下载huggingface模型和数据集
  2. 如何在 huggingface.co 上通过 ssh public key 克隆一个项目
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值