ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / examples / gpt-j / download-ggml-model.sh
| 1 | #!/bin/bash |
| 2 | |
| 3 | # This script downloads GPT-J model files that have already been converted to ggml format. |
| 4 | # This way you don't have to convert them yourself. |
| 5 | # |
| 6 | # If you want to download the original GPT-J model files, use the "download-model.sh" script instead. |
| 7 | |
| 8 | #src="https://ggml.ggerganov.com" |
| 9 | #pfx="ggml-model-gpt-j" |
| 10 | |
| 11 | src="https://huggingface.co/ggerganov/ggml" |
| 12 | pfx="resolve/main/ggml-model-gpt-j" |
| 13 | |
| 14 | ggml_path=$(dirname $(realpath $0)) |
| 15 | |
| 16 | # GPT-J models |
| 17 | models=( "6B" ) |
| 18 | |
| 19 | # list available models |
| 20 | function list_models { |
| 21 | printf "\n" |
| 22 | printf " Available models:" |
| 23 | for model in "${models[@]}"; do |
| 24 | printf " $model" |
| 25 | done |
| 26 | printf "\n\n" |
| 27 | } |
| 28 | |
| 29 | if [ "$#" -ne 1 ]; then |
| 30 | printf "Usage: $0 <model>\n" |
| 31 | list_models |
| 32 | |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | model=$1 |
| 37 | |
| 38 | if [[ ! " ${models[@]} " =~ " ${model} " ]]; then |
| 39 | printf "Invalid model: $model\n" |
| 40 | list_models |
| 41 | |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
| 45 | # download ggml model |
| 46 | |
| 47 | printf "Downloading ggml model $model ...\n" |
| 48 | |
| 49 | mkdir -p models/gpt-j-$model |
| 50 | |
| 51 | if [ -x "$(command -v wget)" ]; then |
| 52 | wget --quiet --show-progress -O models/gpt-j-$model/ggml-model.bin $src/$pfx-$model.bin |
| 53 | elif [ -x "$(command -v curl)" ]; then |
| 54 | curl -L --output models/gpt-j-$model/ggml-model.bin $src/$pfx-$model.bin |
| 55 | else |
| 56 | printf "Either wget or curl is required to download models.\n" |
| 57 | exit 1 |
| 58 | fi |
| 59 | |
| 60 | if [ $? -ne 0 ]; then |
| 61 | printf "Failed to download ggml model $model \n" |
| 62 | printf "Please try again later or download the original GPT-J model files and convert them yourself.\n" |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | printf "Done! Model '$model' saved in 'models/gpt-j-$model/ggml-model.bin'\n" |
| 67 | printf "You can now use it like this:\n\n" |
| 68 | printf " $ ./bin/gpt-j -m models/gpt-j-$model/ggml-model.bin -p \"This is an example\"\n" |
| 69 | printf "\n" |