Skip to content

Commit bf5d181

Browse files
Zhudongsheng75MaiziXiao
authored andcommitted
[Update] Academic bench llm judge update (open-compass#1876)
* BigCodeBench update * update LCBench * update LCBench 2 * update code * academicBench update * academic bench ifeval&math update * generic_llmjudge_aime_academic_postprocess delete * aime delete * postprocessors update * ifeval delete * update work_dir * linting * linting double-quote-string-fixer * r1-distill out_len update * fix lint --------- Co-authored-by: MaiziXiao <xxllcc1993@gmail.com>
1 parent 2940ccd commit bf5d181

17 files changed

+755
-2
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# flake8: noqa
2+
3+
from mmengine.config import read_base
4+
5+
from opencompass.partitioners import NaivePartitioner, NumWorkerPartitioner
6+
from opencompass.runners import LocalRunner, VOLCRunner
7+
from opencompass.tasks import OpenICLEvalTask, OpenICLInferTask
8+
9+
#######################################################################
10+
# PART 0 Essential Configs #
11+
#######################################################################
12+
with read_base():
13+
# Datasets Part
14+
# Knowledge
15+
# Math
16+
from opencompass.configs.datasets.aime2024.aime2024_0shot_nocot_genericllmeval_academic_gen import \
17+
aime2024_datasets
18+
from opencompass.configs.datasets.bbh.bbh_0shot_nocot_academic_gen import \
19+
bbh_datasets
20+
# General Reasoning
21+
from opencompass.configs.datasets.gpqa.gpqa_openai_simple_evals_gen_5aeece import \
22+
gpqa_datasets
23+
from opencompass.configs.datasets.humaneval.humaneval_openai_sample_evals_gen_dcae0e import \
24+
humaneval_datasets
25+
# Instruction Following
26+
from opencompass.configs.datasets.IFEval.IFEval_gen_353ae7 import \
27+
ifeval_datasets
28+
from opencompass.configs.datasets.livecodebench.livecodebench_gen_a4f90b import \
29+
LCBCodeGeneration_dataset
30+
from opencompass.configs.datasets.math.math_prm800k_500_0shot_cot_gen import \
31+
math_datasets
32+
from opencompass.configs.datasets.mmlu_pro.mmlu_pro_0shot_cot_gen_08c1de import \
33+
mmlu_pro_datasets
34+
# Model List
35+
from opencompass.configs.models.hf_internlm.lmdeploy_internlm2_5_7b_chat import \
36+
models as hf_internlm2_5_7b_chat_model
37+
# Summary Groups
38+
from opencompass.configs.summarizers.groups.bbh import bbh_summary_groups
39+
from opencompass.configs.summarizers.groups.mmlu_pro import \
40+
mmlu_pro_summary_groups
41+
42+
#######################################################################
43+
# PART 1 Datasets List #
44+
#######################################################################
45+
# datasets list for evaluation
46+
# Only take LCB generation for evaluation
47+
datasets = sum((v for k, v in locals().items() if k.endswith('_datasets')),
48+
[]) + [LCBCodeGeneration_dataset]
49+
50+
# LLM judge config: using LLM to evaluate predictions
51+
judge_cfg = dict()
52+
for dataset in datasets:
53+
dataset['infer_cfg']['inferencer']['max_out_len'] = 32768
54+
if 'judge_cfg' in dataset['eval_cfg']['evaluator']:
55+
dataset['eval_cfg']['evaluator']['judge_cfg'] = judge_cfg
56+
57+
58+
#######################################################################
59+
# PART 2 Datset Summarizer #
60+
#######################################################################
61+
62+
core_summary_groups = [
63+
{
64+
'name':
65+
'core_average',
66+
'subsets': [
67+
['IFEval', 'Prompt-level-strict-accuracy'],
68+
['bbh', 'naive_average'],
69+
['math_prm800k_500', 'accuracy'],
70+
['aime2024', 'accuracy'],
71+
['GPQA_diamond', 'accuracy'],
72+
['mmlu_pro', 'naive_average'],
73+
['openai_humaneval', 'humaneval_pass@1'],
74+
['lcb_code_generation', 'pass@1'],
75+
],
76+
},
77+
]
78+
79+
summarizer = dict(
80+
dataset_abbrs=[
81+
['core_average', 'naive_average'],
82+
'',
83+
'Instruction Following',
84+
['IFEval', 'Prompt-level-strict-accuracy'],
85+
'',
86+
'General Reasoning',
87+
['bbh', 'naive_average'],
88+
['GPQA_diamond', 'accuracy'],
89+
'',
90+
'Math Calculation',
91+
['math_prm800k_500', 'accuracy'],
92+
['aime2024', 'accuracy'],
93+
'',
94+
'Knowledge',
95+
['mmlu_pro', 'naive_average'],
96+
'',
97+
'Code',
98+
['openai_humaneval', 'humaneval_pass@1'],
99+
['lcb_code_generation', 'pass@1'],
100+
],
101+
summary_groups=sum(
102+
[v for k, v in locals().items() if k.endswith('_summary_groups')], []),
103+
)
104+
105+
#######################################################################
106+
# PART 3 Models List #
107+
#######################################################################
108+
109+
models = sum([v for k, v in locals().items() if k.endswith('_model')], [])
110+
111+
#######################################################################
112+
# PART 4 Inference/Evaluation Configuaration #
113+
#######################################################################
114+
115+
# Local Runner
116+
infer = dict(
117+
partitioner=dict(type=NumWorkerPartitioner, num_worker=8),
118+
runner=dict(
119+
type=LocalRunner,
120+
max_num_workers=16,
121+
retry=0, # Modify if needed
122+
task=dict(type=OpenICLInferTask),
123+
),
124+
)
125+
126+
# eval with local runner
127+
eval = dict(
128+
partitioner=dict(type=NaivePartitioner, n=10),
129+
runner=dict(type=LocalRunner,
130+
max_num_workers=16,
131+
task=dict(type=OpenICLEvalTask)),
132+
)
133+
134+
#######################################################################
135+
# PART 5 Utils Configuaration #
136+
#######################################################################
137+
work_dir = './outputs/oc_academic_202502'
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# flake8: noqa
2+
3+
from opencompass.openicl.icl_prompt_template import PromptTemplate
4+
from opencompass.openicl.icl_retriever import ZeroRetriever
5+
from opencompass.openicl.icl_inferencer import GenInferencer
6+
from opencompass.datasets import Aime2024Dataset
7+
from opencompass.evaluator import GenericLLMEvaluator
8+
from opencompass.datasets.generic import generic_llmjudge_academic_postprocess
9+
10+
11+
aime2024_reader_cfg = dict(
12+
input_columns=['question'],
13+
output_column='answer'
14+
)
15+
16+
17+
aime2024_infer_cfg = dict(
18+
prompt_template=dict(
19+
type=PromptTemplate,
20+
template=dict(
21+
round=[
22+
dict(role='HUMAN',
23+
prompt='{question}\nRemember to put your final answer within \\boxed{}.'),
24+
],
25+
)
26+
),
27+
retriever=dict(type=ZeroRetriever),
28+
inferencer=dict(type=GenInferencer, max_out_len=2048)
29+
)
30+
31+
32+
GRADER_TEMPLATE = """
33+
Please as a grading expert, judge whether the final answers given by the candidates below are consistent with the standard answers, that is, whether the candidates answered correctly.
34+
35+
Here are some evaluation criteria:
36+
1. Please refer to the given standard answer. You don't need to re-generate the answer to the question because the standard answer has been given. You only need to judge whether the candidate's answer is consistent with the standard answer according to the form of the question. Don't try to answer the original question. You can assume that the standard answer is definitely correct.
37+
2. Because the candidate's answer may be different from the standard answer in the form of expression, before making a judgment, please understand the question and the standard answer first, and then judge whether the candidate's answer is correct, but be careful not to try to answer the original question.
38+
3. Some answers may contain multiple items, such as multiple-choice questions, multiple-select questions, fill-in-the-blank questions, etc. As long as the answer is the same as the standard answer, it is enough. For multiple-select questions and multiple-blank fill-in-the-blank questions, the candidate needs to answer all the corresponding options or blanks correctly to be considered correct.
39+
4. Some answers may be expressed in different ways, such as some answers may be a mathematical expression, some answers may be a textual description, as long as the meaning expressed is the same. And some formulas are expressed in different ways, but they are equivalent and correct.
40+
5. If the prediction is given with \\boxed{}, please ignore the \\boxed{} and only judge whether the candidate's answer is consistent with the standard answer.
41+
42+
Please judge whether the following answers are consistent with the standard answer based on the above criteria. Grade the predicted answer of this new question as one of:
43+
A: CORRECT
44+
B: INCORRECT
45+
Just return the letters "A" or "B", with no text around it.
46+
47+
Here is your task. Simply reply with either CORRECT, INCORRECT. Don't apologize or correct yourself if there was a mistake; we are just trying to grade the answer.
48+
49+
50+
<Original Question Begin>: \n{question}\n<Original Question End>\n\n
51+
<Gold Target Begin>: \n{answer}\n<Gold Target End>\n\n
52+
<Predicted Answer Begin>: \n{prediction}\n<Predicted End>\n\n
53+
54+
Judging the correctness of candidates' answers:
55+
""".strip()
56+
57+
58+
aime2024_eval_cfg = dict(
59+
evaluator=dict(
60+
type=GenericLLMEvaluator,
61+
prompt_template=dict(
62+
type=PromptTemplate,
63+
template=dict(
64+
begin=[
65+
dict(
66+
role='SYSTEM',
67+
fallback_role='HUMAN',
68+
prompt="You are a helpful assistant who evaluates the correctness and quality of models' outputs.")
69+
],
70+
round=[
71+
dict(
72+
role='HUMAN',
73+
prompt=GRADER_TEMPLATE),
74+
]),
75+
),
76+
dataset_cfg=dict(
77+
type=Aime2024Dataset,
78+
path='opencompass/aime2024',
79+
reader_cfg=aime2024_reader_cfg,
80+
),
81+
judge_cfg=dict(),
82+
dict_postprocessor=dict(type=generic_llmjudge_academic_postprocess,
83+
metric_name='accuracy'),
84+
),
85+
pred_role='BOT',
86+
)
87+
88+
aime2024_datasets = [
89+
dict(
90+
abbr='aime2024',
91+
type=Aime2024Dataset,
92+
path='opencompass/aime2024',
93+
reader_cfg=aime2024_reader_cfg,
94+
infer_cfg=aime2024_infer_cfg,
95+
eval_cfg=aime2024_eval_cfg,
96+
mode='singlescore',
97+
)
98+
]

0 commit comments

Comments
 (0)