大纲
Hugging-Face 介绍
- Hugging-Face 大语言模型 LLM 管理
- Transformers 机器学习框架
- 文本生成推理 (TGI)
Hugging Face
Hugging-Face – 大语言模型界的 Github
Hugging Face 专门开发用于构建机器学习应用的工具。该公司的代表产品是其为自然语言处理应用构建的 transformers 库,以及允许用户共享机器学习模型和数据集的平台
大模型平台 hugging face
国内对标 – 百度千帆
百度智能云千帆大模型平台(以下简称千帆或千帆大模型平台)是面向企业开发者的一站式大模型开发及服务运行平台。千帆不仅提供了包括文心一言底层模型和第三方开源大模型,还提供了各种 AI 开发工具和整套开发环境,方便客户轻松使用和开发大模型应用。支持数据管理、自动化模型 SFT 以及推理服务云端部署的一站式大模型定制服务,助力各行业的生成式 AI 应用需求落地。
百度千帆
国内对标 – 魔搭社区
ModelScope 社区成立于 2022 年 6 月,是一个模型开源社区及创新平台,由阿里巴巴通义实验室(Institute for Intelligent Computing),联合 CCF 开源发展委员会,共同作为项目发起方。社区联合国内 AI 领域合作伙伴与高校机构, 致力于通过开放的社区合作,构建深度学习相关的模型开源社区,并开放相关模型创新技术,推动基于“模型即服务”(Model-as-a-Service)理念的模型应用生态的繁荣发展。
Hugging Face 是行业风向标
- 开发者仓库 Hub
- 机器学习模型 Hub
- 数据集 Hub
- 机器学习算法库与封装工具
- 解决方案
- 文档
大语言模型管理
通过 Git 下载大模型
git lfs install
#模型会下载到本地目录,并不在hugging face的标准管理目录里,可能会导致后续Transformers库重新下载
git clone https://huggingface.co/google/owlv2-base-patch16-ensemble
客户端工具 huggingface_hub
python -m pip install huggingface_hub
# 需要开启代理
huggingface-cli login
高速下载
python -m pip install huggingface_hub[hf_transfer]
#缺点:目前还不支持代理,导致下载大文件可能有时候更慢。
export HF_HUB_ENABLE_HF_TRANSFER=1
huggingface-cli download gpt2 config.json
huggingface-cli 用法
(base) hogwarts: llama seveniruby$ huggingface-cli -h
usage: huggingface-cli <command> [<args>]
positional arguments:
{
env,login,whoami,logout,repo,upload,download,lfs-enable-largefiles,lfs-multipart-upload,scan-cache,delete-cache}
huggingface-cli command helpers
env Print information about the environment.
login Log in using a token from huggingface.co/settings/tokens
whoami Find out which huggingface.co account you are logged in as.
logout Log out
repo {
create, ls-files} Commands to interact with your huggingface.co repos.
upload Upload a file or a folder to a repo on the Hub
download Download files from the Hub
lfs-enable-largefiles
Configure your repository to enable upload of files > 5GB.
lfs-multipart-upload
Command will get called by git-lfs, do not call it directly.
scan-cache Scan cache directory.
delete-cache Delete revisions from the cache directory.
options:
-h, --help show this help message and exit
使用示例
huggingface-cli login
huggingface-cli download gpt2
huggingface-cli download gpt2 config.json
huggingface-cli download gpt2 --revision main
使用 Hub client library 管理
from huggingface_hub import hf_hub_download