[本科项目实训] Hugging Face简介与Git lfs模型下载

HuggingFace [1]

Hugging Face是一个人工智能领域尤其是自然语言处理领域的开源平台,包含数据集、模型、文档、解决方案等内容的分享。由于 LLM 的参数量较大,往往将参数文件托管到该平台并使用 transformers [3] 库进行模型调用。

模型下载

由于项目要求模型本地运行,因而需要下载模型文件,这里以 ChatGLM 系列为例。

第一步,需要确保当前环境安装了gitgit lfs,安装可以参考如下指令:

# Ubuntu
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
git lfs install

第二步,参考网站对应内容,如[4]:

# <1> Get ALL files
git clone https://huggingface.co/THUDM/glm-4-9b

# <2> If you want to clone without large files - just their pointers
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/THUDM/glm-4-9b

# <3> Get pytoch_model_xxxxx.bin
cd your_project_name
git lfs pull --include="*.bin"

第一个方法可以直接下载所有模型文件,包含实现和参数,第二个方法仅下载模型实现,第三个方法仅下载模型参数,如果 git 因网络问题过慢或报错,请尝试代理后重试。执行结果如下所示:

16669@WORKSTATION-HOME MINGW64 /d/Linux_save
$ git clone https://huggingface.co/THUDM/glm-4-9b
Cloning into 'glm-4-9b'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 80 (delta 36), reused 0 (delta 0), pack-reused 3 (from 1)
Unpacking objects: 100% (80/80), 39.25 KiB | 50.00 KiB/s, done.
Updating files: 100% (24/24), done.

Filtering content: 100% (11/11), 17.51 GiB | 31.42 MiB/s, done.

Filtering content部分给出了参数下载情况。

注:chatglmchatglm2可从 [5] 进行下载。

参考资料

[1] Hugging Face – The AI community building the future.

[2] Huggingface的介绍,使用(CSDN最强Huggingface入门手册)-CSDN博客

[3] Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

[4] THUDM/glm-4-9b · Hugging Face

[5] 清华大学云盘 (tsinghua.edu.cn)

posted @   yicheng_liu0219  阅读(118)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
点击右上角即可分享
微信分享提示