-
Notifications
You must be signed in to change notification settings - Fork 26
/
run_coqa.sh
176 lines (166 loc) · 4.34 KB
/
run_coqa.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
for i in "$@"
do
case $i in
-g=*|--gpudevice=*)
GPUDEVICE="${i#*=}"
shift
;;
-n=*|--numgpus=*)
NUMGPUS="${i#*=}"
shift
;;
-t=*|--taskname=*)
TASKNAME="${i#*=}"
shift
;;
-r=*|--randomseed=*)
RANDOMSEED="${i#*=}"
shift
;;
-p=*|--predicttag=*)
PREDICTTAG="${i#*=}"
shift
;;
-m=*|--modeldir=*)
MODELDIR="${i#*=}"
shift
;;
-d=*|--datadir=*)
DATADIR="${i#*=}"
shift
;;
-o=*|--outputdir=*)
OUTPUTDIR="${i#*=}"
shift
;;
--numturn=*)
NUMTURN="${i#*=}"
shift
;;
--seqlen=*)
SEQLEN="${i#*=}"
shift
;;
--querylen=*)
QUERYLEN="${i#*=}"
shift
;;
--answerlen=*)
ANSWERLEN="${i#*=}"
shift
;;
--batchsize=*)
BATCHSIZE="${i#*=}"
shift
;;
--learningrate=*)
LEARNINGRATE="${i#*=}"
shift
;;
--trainsteps=*)
TRAINSTEPS="${i#*=}"
shift
;;
--warmupsteps=*)
WARMUPSTEPS="${i#*=}"
shift
;;
--savesteps=*)
SAVESTEPS="${i#*=}"
shift
;;
--answerthreshold=*)
ANSWERTHRESHOLD="${i#*=}"
shift
;;
esac
done
echo "gpu device = ${GPUDEVICE}"
echo "num gpus = ${NUMGPUS}"
echo "task name = ${TASKNAME}"
echo "random seed = ${RANDOMSEED}"
echo "predict tag = ${PREDICTTAG}"
echo "model dir = ${MODELDIR}"
echo "data dir = ${DATADIR}"
echo "output dir = ${OUTPUTDIR}"
echo "num turn = ${NUMTURN}"
echo "seq len = ${SEQLEN}"
echo "query len = ${QUERYLEN}"
echo "answer len = ${ANSWERLEN}"
echo "batch size = ${BATCHSIZE}"
echo "learning rate = ${LEARNINGRATE}"
echo "train steps = ${TRAINSTEPS}"
echo "warmup steps = ${WARMUPSTEPS}"
echo "save steps = ${SAVESTEPS}"
echo "answer threshold = ${ANSWERTHRESHOLD}"
alias python=python3
mkdir ${OUTPUTDIR}
start_time=`date +%s`
CUDA_VISIBLE_DEVICES=${GPUDEVICE} python run_coqa.py \
--spiece_model_file=${MODELDIR}/spiece.model \
--model_config_path=${MODELDIR}/xlnet_config.json \
--init_checkpoint=${MODELDIR}/xlnet_model.ckpt \
--task_name=${TASKNAME} \
--random_seed=${RANDOMSEED} \
--predict_tag=${PREDICTTAG} \
--lower_case=false \
--data_dir=${DATADIR}/ \
--output_dir=${OUTPUTDIR}/data \
--model_dir=${OUTPUTDIR}/checkpoint \
--export_dir=${OUTPUTDIR}/export \
--num_turn=${NUMTURN} \
--max_seq_length=${SEQLEN} \
--max_query_length=${QUERYLEN} \
--max_answer_length=${ANSWERLEN} \
--train_batch_size=${BATCHSIZE} \
--predict_batch_size=${BATCHSIZE} \
--num_hosts=1 \
--num_core_per_host=${NUMGPUS} \
--learning_rate=${LEARNINGRATE} \
--train_steps=${TRAINSTEPS} \
--warmup_steps=${WARMUPSTEPS} \
--save_steps=${SAVESTEPS} \
--do_train=true \
--do_predict=false \
--do_export=false \
--overwrite_data=false
CUDA_VISIBLE_DEVICES=${GPUDEVICE} python run_coqa.py \
--spiece_model_file=${MODELDIR}/spiece.model \
--model_config_path=${MODELDIR}/xlnet_config.json \
--init_checkpoint=${MODELDIR}/xlnet_model.ckpt \
--task_name=${TASKNAME} \
--random_seed=${RANDOMSEED} \
--predict_tag=${PREDICTTAG} \
--lower_case=false \
--data_dir=${DATADIR}/ \
--output_dir=${OUTPUTDIR}/data \
--model_dir=${OUTPUTDIR}/checkpoint \
--export_dir=${OUTPUTDIR}/export \
--num_turn=${NUMTURN} \
--max_seq_length=${SEQLEN} \
--max_query_length=${QUERYLEN} \
--max_answer_length=${ANSWERLEN} \
--train_batch_size=${BATCHSIZE} \
--predict_batch_size=${BATCHSIZE} \
--num_hosts=1 \
--num_core_per_host=1 \
--learning_rate=${LEARNINGRATE} \
--train_steps=${TRAINSTEPS} \
--warmup_steps=${WARMUPSTEPS} \
--save_steps=${SAVESTEPS} \
--do_train=false \
--do_predict=true \
--do_export=false \
--overwrite_data=false
python tool/convert_coqa.py \
--input_file=${OUTPUTDIR}/data/predict.${PREDICTTAG}.summary.json \
--output_file=${OUTPUTDIR}/data/predict.${PREDICTTAG}.span.json \
--answer_threshold=${ANSWERTHRESHOLD}
rm ${OUTPUTDIR}/data/predict.${PREDICTTAG}.eval.json
python tool/eval_coqa.py \
--data-file=${DATADIR}/dev-${TASKNAME}.json \
--pred-file=${OUTPUTDIR}/data/predict.${PREDICTTAG}.span.json \
>> ${OUTPUTDIR}/data/predict.${PREDICTTAG}.eval.json
end_time=`date +%s`
echo execution time was `expr $end_time - $start_time` s.
read -n 1 -s -r -p "Press any key to continue..."