File size: 1,633 Bytes
3831b68
854b7af
412c787
5ede0fb
d44f5d8
 
 
854b7af
 
 
 
 
0558cbb
 
 
5ede0fb
d44f5d8
5d082b0
 
 
 
a49ffd4
5d082b0
 
a49ffd4
5d082b0
 
a49ffd4
5d082b0
 
a49ffd4
5d082b0
 
a49ffd4
5d082b0
 
a49ffd4
5d082b0
3831b68
 
 
 
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
import numpy as np
import psutil
import os
from tqdm.auto import tqdm
import logging

logger = logging.getLogger(__name__)


def get_current_ram_usage():
    ram = psutil.virtual_memory()
    return ram.available / 1024 / 1024 / 1024, ram.total / 1024 / 1024 / 1024


def download_models(models):
    for model in tqdm(models, desc="Downloading models"):
        logger.info(f"Downloading {model}")
        for i in range(0, 5):
            curr_dir = f"{model}/train_{i}/best_model/"
            os.makedirs(curr_dir)
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/config.json -P {curr_dir}"
            )
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/pytorch_model.bin -P {curr_dir}"
            )
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/special_tokens_map.json -P {curr_dir}"
            )
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/tokenizer_config.json -P {curr_dir}"
            )
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/training_args.bin -P {curr_dir}"
            )
            os.system(
                f"wget -q https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/vocab.txt -P {curr_dir}"
            )


def softmax(x):
    return np.exp(x) / sum(np.exp(x))