haidizym commited on
Commit
d539df8
·
verified ·
1 Parent(s): 0008bad

Update download_hf.py

Browse files
Files changed (1) hide show
  1. download_hf.py +20 -3
download_hf.py CHANGED
@@ -1,6 +1,23 @@
1
  import os
2
- # 设置环境变量
3
- os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
 
 
 
 
 
 
 
 
 
4
 
5
  # 下载模型
6
- os.system('huggingface-cli download --resume-download sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 --local-dir /root/model/sentence-transformer')
 
 
 
 
 
 
 
 
 
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("模型下载完成。")