-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathrun_all_bench.sh
More file actions
executable file
·223 lines (183 loc) · 6.73 KB
/
Copy pathrun_all_bench.sh
File metadata and controls
executable file
·223 lines (183 loc) · 6.73 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
# ==============================================================================
# run_all_bench.sh
# 统一评测脚本:支持 math / general / science / business / law / medicine 六个 domain
# 用法: 在 Data-Preparation-Bench-2 根目录执行
# bash Data-Agent-Evaluation/scripts/run_all_bench.sh
# ==============================================================================
set -euo pipefail
# ========================= 用户配置区 =========================
# 格式: "domain|model_path"
# domain 可选: math, general, science, business, law, medicine
MODELS=(
"math|/path/to/your/math-model"
"general|/path/to/your/general-model"
"science|/path/to/your/science-model"
"business|/path/to/your/business-model"
"law|/path/to/your/law-model"
"medicine|/path/to/your/medicine-model"
# 同一个模型可以跑多个 domain,例如:
# "math|/path/to/model-A"
# "general|/path/to/model-A"
# "science|/path/to/model-A"
# "business|/path/to/model-A"
# "law|/path/to/model-A"
# "medicine|/path/to/model-A"
)
# 统一输出根目录 (相对于 Data-Preparation-Bench-2 根目录)
OUTPUT_ROOT="Data-Agent-Evaluation/bench_outputs"
# ==============================================================
# 各 bench 仓库相对路径 (相对于 Data-Preparation-Bench-2 根目录)
MATH_DIR="Data-Agent-Evaluation/Qwen2.5-Math/evaluation"
GENERAL_DIR="Data-Agent-Evaluation/lm-evaluation-harness"
SCIENCE_DIR="Data-Agent-Evaluation/lm-open-science-evaluation"
SIMPLE_EVAL_DIR="Data-Agent-Evaluation/simple-evaluation"
PROJ_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
# ---------- helper: 从 model_path 提取模型短名 ----------
get_model_name() {
basename "$1"
}
# ---------- math 评测 ----------
run_math() {
local model_path="$1"
local model_name
model_name="$(get_model_name "$model_path")"
local output_dir="${OUTPUT_ROOT}/math/${model_name}"
echo "======================================================"
echo "[math] model: ${model_path}"
echo "[math] output: ${output_dir}"
echo "======================================================"
mkdir -p "${output_dir}"
# conda 环境
eval "$(conda shell.bash hook)"
conda activate math
local DATA_NAME="gsm8k,amc23,aime24,minerva_math,gaokao2024_mix,olympiadbench,math"
local SPLIT="test"
local NUM_TEST_SAMPLE=-1
local TEMPERATURE=0.6
local N_SAMPLING=1
local TOP_P=1
local MAX_TOKENS_PER_CALL=16384
local SEED=0
local PROMPT_TYPE="qwen25-math-cot"
cd "${PROJ_ROOT}/${MATH_DIR}"
python3 -u math_eval.py \
--model_name_or_path "$model_path" \
--data_name "$DATA_NAME" \
--output_dir "${PROJ_ROOT}/${output_dir}" \
--split "$SPLIT" \
--prompt_type "$PROMPT_TYPE" \
--num_test_sample "$NUM_TEST_SAMPLE" \
--seed "$SEED" \
--temperature "$TEMPERATURE" \
--n_sampling "$N_SAMPLING" \
--top_p "$TOP_P" \
--start 0 \
--end -1 \
--use_vllm \
--save_outputs \
--apply_chat_template \
--max_tokens_per_call "$MAX_TOKENS_PER_CALL"
cd "${PROJ_ROOT}"
conda deactivate
}
# ---------- general 评测 ----------
run_general() {
local model_path="$1"
local model_name
model_name="$(get_model_name "$model_path")"
local output_dir="${OUTPUT_ROOT}/general/${model_name}"
echo "======================================================"
echo "[general] model: ${model_path}"
echo "[general] output: ${output_dir}"
echo "======================================================"
mkdir -p "${output_dir}/math"
eval "$(conda shell.bash hook)"
conda activate general
cd "${PROJ_ROOT}/${GENERAL_DIR}"
lm_eval --model vllm \
--model_args "pretrained=${model_path},dtype=bfloat16,max_model_len=32768" \
--tasks "mmlu_redux_stem_generative,mmlu_redux_other_generative,mmlu_redux_social_sciences_generative,mmlu_redux_humanities_generative" \
--batch_size 128 \
--output_path "${PROJ_ROOT}/${output_dir}" \
--log_samples \
--num_fewshot 5 \
--apply_chat_template
cd "${PROJ_ROOT}"
conda deactivate
}
# ---------- science 评测 ----------
run_science() {
local model_path="$1"
local model_name
model_name="$(get_model_name "$model_path")"
local output_dir="${OUTPUT_ROOT}/science/${model_name}"
echo "======================================================"
echo "[science] model: ${model_path}"
echo "[science] output: ${output_dir}"
echo "======================================================"
mkdir -p "${output_dir}"
eval "$(conda shell.bash hook)"
conda activate science
cd "${PROJ_ROOT}/${SCIENCE_DIR}"
python run_eval.py \
--model-path "$model_path" \
--test-conf "configs/science.json" \
--output-dir "${PROJ_ROOT}/${output_dir}" \
--prompt-format "sft" \
--temperature 1.0
cd "${PROJ_ROOT}"
conda deactivate
}
# ---------- business / law / medicine 评测 ----------
# 三个 domain 共用 simple-evaluation 流水线
run_domain_eval() {
local domain="$1"
local model_path="$2"
local model_name
model_name="$(get_model_name "$model_path")"
local output_dir="${OUTPUT_ROOT}/${domain}/${model_name}"
echo "======================================================"
echo "[${domain}] model: ${model_path}"
echo "[${domain}] output: ${output_dir}"
echo "======================================================"
mkdir -p "${output_dir}"
cd "${PROJ_ROOT}/${SIMPLE_EVAL_DIR}"
bash run_evaluation.sh \
"$model_path" \
"$domain" \
"${PROJ_ROOT}/${output_dir}"
cd "${PROJ_ROOT}"
}
# ========================= 主循环 =========================
echo "========== run_all_bench.sh 开始 =========="
echo "项目根目录: ${PROJ_ROOT}"
echo "输出根目录: ${OUTPUT_ROOT}"
echo "模型总数: ${#MODELS[@]}"
echo ""
for entry in "${MODELS[@]}"; do
domain="${entry%%|*}"
model_path="${entry#*|}"
echo "------------------------------------------------------"
echo ">>> domain=${domain} model=${model_path}"
echo "------------------------------------------------------"
case "$domain" in
math)
run_math "$model_path"
;;
general)
run_general "$model_path"
;;
science)
run_science "$model_path"
;;
business|law|medicine)
run_domain_eval "$domain" "$model_path"
;;
*)
echo "[ERROR] 未知 domain: ${domain},跳过。支持: math, general, science, business, law, medicine"
;;
esac
echo ""
done
echo "========== run_all_bench.sh 全部完成 =========="