interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / examples / gpt-2 / download-ggml-model.sh

69 lines · 1752 bytes Raw Blame History
1#!/bin/bash
2
3# This script downloads GPT-2 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-2 model files, use the "download-model.sh" script instead.
7
8#src="https://ggml.ggerganov.com"
9#pfx="ggml-model-gpt-2"
10
11src="https://huggingface.co/ggerganov/ggml"
12pfx="resolve/main/ggml-model-gpt-2"
13
14ggml_path=$(dirname $(realpath $0))
15
16# GPT-2 models
17models=( "117M" "345M" "774M" "1558M" )
18
19# list available models
20function 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
29if [ "$#" -ne 1 ]; then
30 printf "Usage: $0 <model>\n"
31 list_models
32
33 exit 1
34fi
35
36model=$1
37
38if [[ ! " ${models[@]} " =~ " ${model} " ]]; then
39 printf "Invalid model: $model\n"
40 list_models
41
42 exit 1
43fi
44
45# download ggml model
46
47printf "Downloading ggml model $model ...\n"
48
49mkdir -p models/gpt-2-$model
50
51if [ -x "$(command -v wget)" ]; then
52 wget --quiet --show-progress -O models/gpt-2-$model/ggml-model.bin $src/$pfx-$model.bin
53elif [ -x "$(command -v curl)" ]; then
54 curl -L --output models/gpt-2-$model/ggml-model.bin $src/$pfx-$model.bin
55else
56 printf "Either wget or curl is required to download models.\n"
57 exit 1
58fi
59
60if [ $? -ne 0 ]; then
61 printf "Failed to download ggml model $model \n"
62 printf "Please try again later or download the original GPT-2 model files and convert them yourself.\n"
63 exit 1
64fi
65
66printf "Done! Model '$model' saved in 'models/gpt-2-$model/ggml-model.bin'\n"
67printf "You can now use it like this:\n\n"
68printf " $ ./bin/gpt-2 -m models/gpt-2-$model/ggml-model.bin -p \"This is an example\"\n"
69printf "\n"