1. Hugging face
1.1 模型详情页介绍
Model Card 类似于 github 的 README 文件,展示模型的 overview
Files and Versions 包含模型文件以及模型的版本管理
Use this model 提供我们使用模型的示例代码,一般在model card 下方也会提到各种改模型的使用方法
1.2 创建github codespace
# 安装transformers
pip install transformers==4.38
pip install sentencepiece==0.1.99
pip install einops==0.8.0
pip install protobuf==5.27.2
pip install accelerate==0.33.0
1.3 下载 chat 的配置文件
创建文件
touch hf_download_josn.py
粘贴代码
import os
from huggingface_hub import hf_hub_download
# 指定模型标识符
repo_id = "internlm/internlm2_5-7b"
# 指定要下载的文件列表
files_to_download = [
{"filename": "config.json"},
{"filename": "model.safetensors.index.json"}
]
# 创建一个目录来存放下载的文件
local_dir = f"{repo_id.split('/')[1]}"
os.makedirs(local_dir, exist_ok=True)
# 遍历文件列表并下载每个文件
for file_info in files_to_download:
file_path = hf_hub_download(
repo_id=repo_id,
filename=file_info["filename"],
local_dir=local_dir
)
print(f"{file_info['filename']} file downloaded to: {file_path}")
运行 python hf_download_josn.py
上传
创建 hugging face 模型