forked from catalystforyou/SUPERChem_eval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval_cot.sh
More file actions
87 lines (69 loc) · 3.25 KB
/
Copy patheval_cot.sh
File metadata and controls
87 lines (69 loc) · 3.25 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
#!/bin/bash
# --- Configuration ---
# 1. Path to the file with original questions and ground truth analysis.
# This file is the same for all evaluation runs.
QUESTIONS_FILE="../data/20251014164938_questions.parquet"
# 2. The single, powerful model that will act as the evaluator/judge.
EVALUATOR_MODEL="gemini-2.5-pro"
# 3. The prefix used for all model answer files. The script will find all
# files starting with this prefix. This should match the prefix from your
# original answer generation script.
ANSWERS_PREFIX="../data/${QUESTIONS_FILE%.parquet}"
# 4. General settings for the python evaluation script.
LANGUAGE="en"
N_PROCS=4
N_THREADS=10
EVALUATOR_TEMPERATURE=1.0 # Temperature for the evaluator model
# --- Script Logic ---
echo "Starting automated CoT evaluation..."
echo "Using single evaluator model: $EVALUATOR_MODEL"
echo "Searching for answer files with prefix: ${ANSWERS_PREFIX}_*.jsonl"
echo "================================================="
# Find all .jsonl files that match the answer prefix.
# The glob will expand to a list of all matching filenames.
for answer_file_to_evaluate in ${ANSWERS_PREFIX}_*.jsonl; do
# if "EVAL" in filename, then skip
if [[ "$answer_file_to_evaluate" == *"_EVAL_BY_"* ]]; then
echo "Skipping already evaluated file: $answer_file_to_evaluate"
echo "---"
continue # continue命令会跳过本次循环,处理下一个文件
fi
# --- Safety Checks ---
# a) Check if the glob found any files at all.
if [ ! -f "$answer_file_to_evaluate" ]; then
echo "Error: No answer files found matching the pattern '${ANSWERS_PREFIX}_*.jsonl'."
echo "Please ensure the answer files are in this directory and the prefix is correct."
exit 1
fi
if [[ "$answer_file_to_evaluate" == *"_EVAL_BY_"* ]]; then
echo "Skipping already evaluated file: $answer_file_to_evaluate"
echo "---"
continue # continue命令会跳过本次循环,处理下一个文件
fi
echo "Found answer file: $answer_file_to_evaluate"
# --- Generate a descriptive output filename for this evaluation run ---
# This takes the original answer file name and inserts the evaluation info.
# Example: input.jsonl -> input_EVAL_BY_gpt-5.jsonl
safe_evaluator_model=$(echo "$EVALUATOR_MODEL" | sed 's/\//-/g; s/\./_/g')
evaluation_output_file=$(echo "$answer_file_to_evaluate" | sed "s/\.jsonl/_EVAL_BY_${safe_evaluator_model}.jsonl/")
echo "Evaluating..."
echo " -> Evaluator: $EVALUATOR_MODEL"
echo " -> Output will be saved to: data/$evaluation_output_file"
# --- Build and execute the command ---
# The python script is assumed to be named 'eval_cot.py'
cmd="python eval_cot.py \
--input \"$QUESTIONS_FILE\" \
--answers-input \"$answer_file_to_evaluate\" \
--output \"data/$evaluation_output_file\" \
--model \"$EVALUATOR_MODEL\" \
--temperature \"$EVALUATOR_TEMPERATURE\" \
--language \"$LANGUAGE\" \
--pass-k 1 \
--n-procs \"$N_PROCS\" \
--n-threads \"$N_THREADS\""
# Execute the command
eval $cmd
echo "Completed evaluation for $answer_file_to_evaluate"
echo "---"
done
echo "All found answer files have been evaluated!"