fszontagh
2024-02-24 67e873db898349152f2d9daee9effb1d794ab4da
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
#!/bin/bash
 
ggml_path=$(dirname $(realpath $0))
 
# GPT-2 models
models=( "117M" "345M" "774M" "1558M" )
 
# list available models
function list_models {
    printf "\n"
    printf "  Available models:"
    for model in "${models[@]}"; do
        printf " $model"
    done
    printf "\n\n"
}
 
if [ "$#" -ne 1 ]; then
    printf "Usage: $0 <model>\n"
    list_models
 
    exit 1
fi
 
model=$1
 
if [[ ! " ${models[@]} " =~ " ${model} " ]]; then
    printf "Invalid model: $model\n"
    list_models
 
    exit 1
fi
 
# download model
 
printf "Downloading model $model ...\n"
 
mkdir -p models/gpt-2-$model
 
for file in checkpoint encoder.json hparams.json model.ckpt.data-00000-of-00001 model.ckpt.index model.ckpt.meta vocab.bpe; do
    wget --quiet --show-progress -O models/gpt-2-$model/$file https://openaipublic.blob.core.windows.net/gpt-2/models/$model/$file
done
 
printf "Done! Model '$model' saved in 'models/gpt-2-$model/'\n\n"
printf "Run the convert-ckpt-to-ggml.py script to convert the model to ggml format.\n"
printf "\n"
printf "  python $ggml_path/convert-ckpt-to-ggml.py models/gpt-2-$model/\n"
printf "\n"