forked from ARiSE-Lab/SemCoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval_cruxeval.sh
183 lines (146 loc) · 5.44 KB
/
eval_cruxeval.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
177
178
179
180
181
182
183
#!/bin/bash
###################################################################################
# Hardware: 1x A6000 48GB GPU, or any other GPUs with at least 48GB memory
# Note: We use the default hyperparameters provided by the corresponding benchmark.
# To reproduce the results reported in the paper, do not change it.
###################################################################################
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:/home/rc3593/SemCoder
CRUXEVAL_HOME="/home/rc3593/cruxeval"
SEMCODER_HOME=$(pwd)
MODEL=semcoder/semcoder_1030 # semcoder/semcoder_s_1030
###########################
# CRUXEval-I: run inference
###########################
OPT_BASE="${SEMCODER_HOME}/output_dir/eval/cruxeval/cruxeval_input"
model_name=$(basename $MODEL)
direct_pred_dir=${OPT_BASE}/${model_name}_direct
monologue_pred_dir=${OPT_BASE}/${model_name}_monologue
mkdir -p ${direct_pred_dir}
mkdir -p ${monologue_pred_dir}
echo "Evaluating model: ${model_name} on CRUXEval-I (direct prediction)..."
python experiments/run_cruxeval.py \
--model $MODEL \
--use_auth_token \
--trust_remote_code \
--tasks input_prediction \
--batch_size 1 \
--n_samples 1 \
--max_length_generation 4096 \
--precision fp16 \
--limit 200 \
--temperature 0.0 \
--save_generations \
--save_generations_path ${direct_pred_dir}/results.json \
--start 0 \
--end 200 \
--shuffle \
--tensor_parallel_size 1
echo "Evaluating model: ${model_name} on CRUXEval-I with SemCoder Monologue..."
python experiments/run_cruxeval.py \
--model $MODEL \
--use_auth_token \
--trust_remote_code \
--tasks input_prediction \
--batch_size 1 \
--n_samples 1 \
--max_length_generation 4096 \
--precision fp16 \
--limit 200 \
--temperature 0.0 \
--save_generations \
--save_generations_path ${monologue_pred_dir}/results.json \
--start 0 \
--end 200 \
--shuffle \
--monologue \
--tensor_parallel_size 1
##########################
# CRUXEval-I: Report score
##########################
echo "Reporting score for model: ${model_name}..."
python experiments/cruxeval_combine_generations.py --gen_dir ${direct_pred_dir}
python experiments/process_cruxeval.py --task i --gen_dir ${direct_pred_dir}
python experiments/cruxeval_combine_generations.py --gen_dir ${monologue_pred_dir}
python experiments/process_cruxeval.py --task i --gen_dir ${monologue_pred_dir}
cd $CRUXEVAL_HOME/evaluation;
echo "Evaluating results: direct prediction..."
python evaluate_generations.py \
--generations_path ${direct_pred_dir}/generations.json \
--scored_results_path ${direct_pred_dir}/scored_results.json \
--mode input \
2>&1 | tee ${direct_pred_dir}/eval.log
echo "Evaluating results: monologue prediction..."
python evaluate_generations.py \
--generations_path ${monologue_pred_dir}/generations.json \
--scored_results_path ${monologue_pred_dir}/scored_results.json \
--mode input \
2>&1 | tee ${monologue_pred_dir}/eval.log
###########################
# CRUXEval-O: run inference
###########################
cd $SEMCODER_HOME;
OPT_BASE="${SEMCODER_HOME}/output_dir/eval/cruxeval/cruxeval_output"
model_name=$(basename $MODEL)
direct_pred_dir=${OPT_BASE}/${model_name}_direct
monologue_pred_dir=${OPT_BASE}/${model_name}_monologue
mkdir -p ${direct_pred_dir}
mkdir -p ${monologue_pred_dir}
echo "Evaluating model: ${model_name} on CRUXEval-O (direct prediction)..."
python experiments/run_cruxeval.py \
--model $MODEL \
--use_auth_token \
--trust_remote_code \
--tasks output_prediction \
--batch_size 1 \
--n_samples 1 \
--max_length_generation 4096 \
--precision fp16 \
--limit 200 \
--temperature 0.0 \
--save_generations \
--save_generations_path ${direct_pred_dir}/results.json \
--start 0 \
--end 200 \
--shuffle \
--tensor_parallel_size 1
echo "Evaluating model: ${model_name} on CRUXEval-O with SemCoder Forward Monologue..."
python experiments/run_cruxeval.py \
--model $MODEL \
--use_auth_token \
--trust_remote_code \
--tasks output_prediction \
--batch_size 1 \
--n_samples 1 \
--max_length_generation 4096 \
--precision fp16 \
--limit 200 \
--temperature 0.0 \
--save_generations \
--save_generations_path ${monologue_pred_dir}/results.json \
--start 0 \
--end 200 \
--shuffle \
--monologue \
--tensor_parallel_size 1
##########################
# CRUXEval-O: Report score
##########################
echo "Reporting score for model: ${model_name}...";
python experiments/cruxeval_combine_generations.py --gen_dir ${direct_pred_dir}
python experiments/process_cruxeval.py --task o --gen_dir ${direct_pred_dir}
python experiments/cruxeval_combine_generations.py --gen_dir ${monologue_pred_dir}
python experiments/process_cruxeval.py --task o --gen_dir ${monologue_pred_dir}
cd $CRUXEVAL_HOME/evaluation;
echo "Evaluating results: direct prediction..."
python evaluate_generations.py \
--generations_path ${direct_pred_dir}/generations.json \
--scored_results_path ${direct_pred_dir}/scored_results.json \
--mode output \
2>&1 | tee ${direct_pred_dir}/eval.log
echo "Evaluating results: monologue prediction..."
python evaluate_generations.py \
--generations_path ${monologue_pred_dir}/generations.json \
--scored_results_path ${monologue_pred_dir}/scored_results.json \
--mode output \
2>&1 | tee ${monologue_pred_dir}/eval.log