download-model.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. ggml_path=$(dirname $(realpath $0))
  3. # GPT-2 models
  4. models=( "117M" "345M" "774M" "1558M" )
  5. # list available models
  6. function list_models {
  7. printf "\n"
  8. printf " Available models:"
  9. for model in "${models[@]}"; do
  10. printf " $model"
  11. done
  12. printf "\n\n"
  13. }
  14. if [ "$#" -ne 1 ]; then
  15. printf "Usage: $0 <model>\n"
  16. list_models
  17. exit 1
  18. fi
  19. model=$1
  20. if [[ ! " ${models[@]} " =~ " ${model} " ]]; then
  21. printf "Invalid model: $model\n"
  22. list_models
  23. exit 1
  24. fi
  25. # download model
  26. printf "Downloading model $model ...\n"
  27. mkdir -p models/gpt-2-$model
  28. for file in checkpoint encoder.json hparams.json model.ckpt.data-00000-of-00001 model.ckpt.index model.ckpt.meta vocab.bpe; do
  29. wget --quiet --show-progress -O models/gpt-2-$model/$file https://openaipublic.blob.core.windows.net/gpt-2/models/$model/$file
  30. done
  31. printf "Done! Model '$model' saved in 'models/gpt-2-$model/'\n\n"
  32. printf "Run the convert-ckpt-to-ggml.py script to convert the model to ggml format.\n"
  33. printf "\n"
  34. printf " python $ggml_path/convert-ckpt-to-ggml.py models/gpt-2-$model/\n"
  35. printf "\n"