-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.sh
111 lines (99 loc) · 4.17 KB
/
run.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
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
{
. scripts/set_environment.sh
args=$@
for arg in $args; do
eval "$arg"
done
echo "n_observed_chars: ${n_observed_chars:=8}"
echo "n_beam: ${n_beam:=8}"
echo "batch_size: ${batch_size:=200}"
echo "max_sentences_per_batch: ${max_sentences_per_batch:=24}"
echo "alpha: ${alpha:=2.5}"
echo "temperature: ${temperature:=1.5}"
echo "use_faithfulness_reward: ${use_faithfulness_reward:=true}"
echo "use_chat_prompted_model: ${use_chat_prompted_model:=false}"
echo "prob_smooth: ${prob_smooth:=-15.0}"
echo "prefix_split: ${prefix_split:=$'\n'}"
echo "model: ${model:=Qwen/Qwen2.5-7B}"
echo "prompted_model: ${prompted_model:=Qwen/Qwen2.5-7B}"
echo "config_path: ${config_path:=configs/default_config.yaml}"
echo "base_suite: ${base_suite:=v1}"
prompted_model_name=${prompted_model//\//_}
suite="${prompted_model_name}-${base_suite}"
use_faithfulness_reward_flag=""
if [ "$use_faithfulness_reward" = true ]; then
echo "Setting --use-faithfulness-reward"
use_faithfulness_reward_flag="--use-faithfulness-reward"
else
echo "Not setting --use-faithfulness-reward"
suite="${suite}.no_faithfulness_reward"
fi
use_chat_prompted_model_flag=""
if [ "$use_chat_prompted_model" = true ]; then
echo "Setting --use-chat-prompted-model"
use_chat_prompted_model_flag="--use-chat-prompted-model"
suite="${suite}.use_chat_prompted_model"
else
echo "Not setting --use-chat-prompted-model"
fi
suite="${suite}.alpha-${alpha}.temperature-${temperature}.prob_smooth-${prob_smooth}.n_beam-${n_beam}.n_observed_chars-${n_observed_chars}"
datasets=(
# "ecspell/law_500.txt"
# "ecspell/med_500.txt"
# "ecspell/odw_500.txt"
# "sighan_rev/sighan13.txt"
# "sighan_rev/sighan14.txt"
# "sighan_rev/sighan15.txt"
"lemon_v2/car.txt"
"lemon_v2/cot.txt"
"lemon_v2/enc.txt"
"lemon_v2/gam.txt"
"lemon_v2/mec.txt"
"lemon_v2/new.txt"
"lemon_v2/nov.txt"
# "mcsc/test.txt"
"cscd_ime/test.txt"
# "cscd_ime/dev.txt"
"c2ec/test.txt"
# "c2ec/dev.txt"
)
for dataset in "${datasets[@]}"; do
dataset_name=$(echo "${dataset}" | cut -d. -f1)
dataset_name=${dataset_name//\//_}
mkdir -p "results/${model}/${suite}/${dataset_name}"
python -u run.py \
--input-file "datasets/${dataset}" \
--path "results/${model}/${suite}/${dataset_name}" \
--model-name "${model}" \
--prompted-model-name "${prompted_model}" \
--config-path "${config_path}" \
--n-observed-chars "${n_observed_chars}" \
--prefix-split "${prefix_split}" \
--n-beam "${n_beam}" \
--batch-size "${batch_size}" \
--max-length 256 \
--max-sentences-per-batch "${max_sentences_per_batch}" \
--alpha "${alpha}" \
--temperature "${temperature}" $use_faithfulness_reward_flag $use_chat_prompted_model_flag \
--distortion-model-smoothing "${prob_smooth}" | tee "results/${model}/${suite}/${dataset_name}/prediction.log"
if [[ "$dataset_name" =~ "ecspell" || "$dataset_name" =~ "sighan_rev" || "$dataset_name" =~ "lemon_v2" || "$dataset_name" =~ "cscd_ime" || "$dataset_name" =~ "mcsc" ]]; then
# Ignore unmatch length for CSC datasets
python eval/evaluate.py \
--gold "datasets/${dataset}" \
--hypo "results/${model}/${suite}/${dataset_name}/prediction.txt" \
--to_halfwidth \
--ignore_unmatch_length \
--ignore_space
else
python eval/evaluate.py \
--gold "datasets/${dataset}" \
--hypo "results/${model}/${suite}/${dataset_name}/prediction.txt" \
--to_halfwidth \
--ignore_space
fi
done
}