forked from 1Panel-dev/MaxKB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_model.py
69 lines (64 loc) · 1.94 KB
/
install_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# coding=utf-8
"""
@project: maxkb
@Author:虎
@file: install_model.py
@date:2023/12/18 14:02
@desc:
"""
import json
import os.path
from pycrawlers import huggingface
from transformers import GPT2TokenizerFast
hg = huggingface()
prefix_dir = "./model"
model_config = [
{
'download_params': {
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
'pretrained_model_name_or_path': 'gpt2'
},
'download_function': GPT2TokenizerFast.from_pretrained
},
{
'download_params': {
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
'pretrained_model_name_or_path': 'gpt2-medium'
},
'download_function': GPT2TokenizerFast.from_pretrained
},
{
'download_params': {
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
'pretrained_model_name_or_path': 'gpt2-large'
},
'download_function': GPT2TokenizerFast.from_pretrained
},
{
'download_params': {
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
'pretrained_model_name_or_path': 'gpt2-xl'
},
'download_function': GPT2TokenizerFast.from_pretrained
},
{
'download_params': {
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
'pretrained_model_name_or_path': 'distilgpt2'
},
'download_function': GPT2TokenizerFast.from_pretrained
},
{
'download_params': {
'urls': ["https://huggingface.co/shibing624/text2vec-base-chinese/tree/main"],
'file_save_paths': [os.path.join(prefix_dir, 'embedding',"shibing624_text2vec-base-chinese")]
},
'download_function': hg.get_batch_data
}
]
def install():
for model in model_config:
print(json.dumps(model.get('download_params')))
model.get('download_function')(**model.get('download_params'))
if __name__ == '__main__':
install()