Skip to content

Commit dc4cdec

Browse files
committed
feat: add install_model_token script for downloading and installing BERT tokenizer
1 parent c23e18d commit dc4cdec

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

installer/install_model_token.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# coding=utf-8
2+
import json
3+
import os.path
4+
from transformers import BertTokenizer
5+
6+
prefix_dir = "./model"
7+
model_config = [
8+
{
9+
'download_params': {
10+
'cache_dir': os.path.join(prefix_dir, 'base/hub'),
11+
'pretrained_model_name_or_path': 'bert-base-cased'
12+
},
13+
'download_function': BertTokenizer.from_pretrained
14+
},
15+
]
16+
17+
18+
def install():
19+
for model in model_config:
20+
print(json.dumps(model.get('download_params')))
21+
model.get('download_function')(**model.get('download_params'))
22+
23+
24+
if __name__ == '__main__':
25+
install()

0 commit comments

Comments
 (0)