如何下载huggingface或modelscope上的大模型或数据集

1. 如何下载hg上的大模型

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

下载安装

# huggingface_hub 依赖于 Python>=3.8
pip install -U huggingface_hub

# 定位huggingface-cli.exe的位置
pip show huggingface-hub
cd D:\soft\anaconda3\lib\site-packages\huggingface_hub\

#使用示例
#下载模型
huggingface-cli.exe download  moka-ai/m3e-base --local-dir d:/llm/m3e-base

#下载数据
huggingface-cli.exe download --repo-type dataset  wikitext --local-dir wikitext

#查看帮助文档
huggingface-cli.exe download -h

huggingface-cli.exe download --local-dir-use-symlinks false google-bert/bert-base-chinese --local-dir d:/llm/bert-base-chinese

D:\python\jupyter\models

重要参数

  • --resume-download If True, resume a previously interrupted download
  • --quiet If True, progress bars are disabled and only the path to the download files is printed
  • --local-dir-use-symlinks {auto,True,False} 因为huggingface的工具链默认会使用符号链接来存储下载的文件,导致--local-dir指定的目录中都是一些“链接文件”,真实模型则存储在~/.cache/huggingface
  • --local-dir LOCAL_DIR
  • –exclude [EXCLUDE …] Glob patterns to exclude from files to download.

设置环境变量

  • huggingface 工具链会获取HF_ENDPOINT环境变量来确定下载文件所用的网址

    export HF_ENDPOINT=https://hf-mirror.com/
    
    #Windows Powershell
    $env:HF_ENDPOINT = "https://hf-mirror.com"
    
  • 改变缓存目录

    • XDG_CACHE_HOME=缓存目录 或 HF_HOME = 缓存目录
    • 默认的目录在:C:\Users\gitriver\.cache\huggingface

如何下载modelscope上的大模型

pip install modelscope
#下载完整模型repo
modelscope download --model qwen/Qwen2-Audio-7B-Instruct
#下载单个文件(以README.md为例)
modelscope download --model qwen/Qwen2-Audio-7B-Instruct README.md

### 指定下载某些文件
modelscope download --model 'AI-ModelScope/gpt2' --include 'onnx/*' '*.tflite'

# ### 过滤指定文件
modelscope download --model 'AI-ModelScope/gpt2' --exclude 'onnx/*' '*.tflite'

# 查看帮助
modelscope download --help

详见使用请参见:https://www.modelscope.cn/docs/模型的下载#使用命令行工具下载模型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

enjoy编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值