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}") |