-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtrain_and_evaluate_reading_comprehension_baselines.sh
executable file
·46 lines (40 loc) · 1.88 KB
/
train_and_evaluate_reading_comprehension_baselines.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
export DATA_DIR=../data/reading_comprehension
# first, clean tokenizer caches
rm ${DATA_DIR}/cached_*
declare -a models=("TurkuNLP/wikibert-base-fa-cased" "HooshvareLab/bert-fa-base-uncased" "HooshvareLab/bert-fa-base-uncased-clf-persiannews" "HooshvareLab/bert-base-parsbert-uncased" "bert-base-multilingual-cased" "bert-base-multilingual-uncased")
declare -a learning_rates=(3e-5 5e-5)
declare -a num_train_epochs=(3 7)
for model in "${models[@]}"; do
for learning_rate in "${learning_rates[@]}"; do
for num_train_epoch in "${num_train_epochs[@]}"; do
python ../src/run_squad.py \
--model_type bert \
--model_name_or_path "${model}" \
--do_train \
--do_eval \
--train_file $DATA_DIR/train.json \
--predict_file $DATA_DIR/dev.json \
--learning_rate "${learning_rate[@]}" \
--num_train_epochs "${num_train_epoch[@]}" \
--max_seq_length 384 \
--doc_stride 128 \
--output_dir "reading_comprehension_model/${model}_learning_rate=${learning_rate}_learning_rate=${learning_rate}_num_train_epoch=${num_train_epoch}" \
--per_gpu_eval_batch_size=256 \
--per_gpu_train_batch_size=4 \
--save_steps 5000
done
done
done
exit 0 # stop here; evaluation (following scrpts) requires manual intervention
# for evaluation, use the same command, without --do_train
# and indicate the path to your selected model with "--model_name_or_path"
export model="reading_comprehension_model/HooshvareLab/bert-base-parsbert-uncased_learning_rate=3e-5_learning_rate=3e-5_num_train_epoch=7"
python3.6 ../src/run_squad.py \
--model_type bert \
--model_name_or_path "${model}" \
--do_eval \
--predict_file $DATA_DIR/eval.json \
--max_seq_length 384 \
--doc_stride 128 \
--output_dir "${model}/eval" \
--per_gpu_eval_batch_size=256