Spaces:
Sleeping
Sleeping
Update download_hf.py
Browse files- download_hf.py +20 -3
download_hf.py
CHANGED
|
@@ -1,6 +1,23 @@
|
|
| 1 |
import os
|
| 2 |
-
#
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# 下载模型
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
# downloadhf.py
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# 模型信息和本地保存路径
|
| 8 |
+
repo_id = 'sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2'
|
| 9 |
+
local_dir = '/workspaces/codespaces-jupyter/internLM_RAG/models/sentence-transformer' # 更改为当前路径下的子目录
|
| 10 |
+
|
| 11 |
+
# 确保本地保存路径存在
|
| 12 |
+
os.makedirs(local_dir, exist_ok=True)
|
| 13 |
|
| 14 |
# 下载模型
|
| 15 |
+
files_to_download = ['model.safetensors', 'config.json', 'pytorch_model.bin', 'tokenizer.json', 'tokenizer_config.json']
|
| 16 |
+
for filename in files_to_download:
|
| 17 |
+
hf_hub_download(
|
| 18 |
+
repo_id=repo_id,
|
| 19 |
+
filename=filename,
|
| 20 |
+
local_dir=local_dir
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
print("模型下载完成。")
|