从hugging face上clone大语言模型
2023-12-16 本文已影响0人
梅西爱骑车
科学上网,http端口号10809.
方法1:
选择python依赖包,用代码程序解决
推荐:pycrawlers这个python包,使用这个包可以轻松实现批量下载,以及进度显示。
from pycrawlers import huggingface
# 实例化类
hg = huggingface()
# 1.批量下载
urls = ['https://huggingface.co/ziqingyang/chinese-llama-2-13b/tree/main',
'https://huggingface.co/ziqingyang/chinese-llama-2-7b/tree/main']
# 默认保存位置在当前脚本所在文件夹 ./
hg.get_batch_data(urls)
# 2.单个下载
url = 'https://huggingface.co/ziqingyang/chinese-llama-2-13b/tree/main'
# 默认保存位置在当前脚本所在文件夹 ./
hg.get_data(url)
# 自定义下载位置
# 多个不同位置
paths = ['/home/model-gpt/chinese-llama-2-13b','/home/model-gpt/chinese-llama-2-7b']
hg.get_batch_data(urls, paths)
# 单一位置
path = '/home/model-gpt'
hg.get_data(url, path)
方法二
启动科学上网软件,配置科学上网的在Windows、Linux、Mac OS 中 git 命令相同.
git config --global http.proxy 127.0.0.1:10809
git config --global https.proxy 127.0.0.1:10809
git config --global http.proxy socks5 127.0.0.1:10808
git config --global https.proxy socks5 127.0.0.1:10808
查看:
git config --global --get http.proxy
git config --global --get https.proxy
取消:
git config --global --unset http.proxy
git config --global --unset https.proxy
比如下载sqlcoder,
进入官网:https://huggingface.co/defog/sqlcoder/tree/main
进入三个点,参考clone代码的命令:
![](https://img.haomeiwen.com/i23166491/303dbe3cf796723c.png)
![](https://img.haomeiwen.com/i23166491/05e93c28435a7971.png)
在命令行窗口执行clone命令,环境变量GIT_LFS_SKIP_SMUDGE=1代表我只下载大文件的指针。高版本的git已经自带lfs,克隆前需要执行git lfs install。
set GIT_LFS_SKIP_SMUDGE=1
git lfs install
git clone https://huggingface.co/defog/sqlcoder
如果网络不稳定,多试几次。成功下载的命令如下:
![](https://img.haomeiwen.com/i23166491/fc9ff1fc812a3bef.png)
几个大文件现在都是指针,如果要真正部署要全部下载才行。
![](https://img.haomeiwen.com/i23166491/b77ba83606f20105.png)