forked from togethercomputer/OpenChatKit
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.sh
137 lines (120 loc) · 3.01 KB
/
setup.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
# run choice => ['inference', 'train', 'prepare']
ARG_0=$1
# setup conda
eval "$(/app/conda/bin/conda shell.bash hook)"
conda activate OpenChatKit
POSITIONAL_ARGS=()
if [ ARG_0 = 'inference' ]; then
shift
(trap 'kill 0' SIGINT; \
python ${DIR}/inference/bot.py $(echo $@) \
& \
wait)
elif [ ARG_0 = 'train' ]; then
shift
echo "Initializing training..."
while [[ $# -gt 0 ]]; do
case $1 in
-m|--model)
MODEL="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
if [ MODEL = 'gpt-neox' ]; then
(trap 'kill 0' SIGINT; \
bash ${DIR}/training/finetune_GPT-NeoXT-Chat-Base-20B.sh \
& \
wait)
elif [ MODEL = 'pythia' ]; then
(trap 'kill 0' SIGINT; \
bash ${DIR}/training/finetune_Pythia-Chat-Base-7B.sh \
& \
wait)
else
# default MODEL=pythia
(trap 'kill 0' SIGINT; \
bash ${DIR}/training/finetune_Pythia-Chat-Base-7B.sh \
& \
wait)
fi
elif [ ARG_0 = "prepare" ]; then
shift
echo "Preparing..."
(trap 'kill 0' SIGINT; \
wget https://github.com/git-lfs/git-lfs/releases/download/v3.3.0/git-lfs-linux-amd64-v3.3.0.tar.gz \
& \
tar -xvf git-lfs-linux-amd64-v3.3.0.tar.gz \
& \
./git-lfs-3.3.0/install.sh \
& \
git lfs install \
& \
python data/OIG/prepare.py \
& \
wait)
while [[ $# -gt 0 ]]; do
case $1 in
-m|--model)
MODEL="$2"
shift # past argument
shift # past value
;;
--bitsandbytes)
BITS=YES
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
echo "Preparing model ${MODEL}..."
if [ MODEL = 'gpt-neox' ]; then
(trap 'kill 0' SIGINT; \
python ${DIR}/pretrained/GPT-NeoX-20B/prepare.py \
& \
wait)
elif [ MODEL = 'pythia' ]; then
(trap 'kill 0' SIGINT; \
python ${DIR}/pretrained/Pythia-6.9B-deduped/prepare.py \
& \
wait)
else
# default MODEL=pythia
(trap 'kill 0' SIGINT; \
python ${DIR}/pretrained/Pythia-6.9B-deduped/prepare.py \
& \
wait)
fi
if [ BITS = YES ]; then
echo "Installing bitsandbytes..."
(trap 'kill 0' SIGINT; \
python -m pip install bitsandbytes \
& \
wait)
fi
echo "Done"
else
# defaults to inference
(trap 'kill 0' SIGINT; \
python ${DIR}/inference/bot.py $(echo $@) \
& \
wait)
fi