mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
[Feature] Add olymmath dataset (#1982)
* Add olymmath dataset * Add olymmath dataset * Add olymmath dataset * Update olymmath dataset
This commit is contained in:
parent
97236c8e97
commit
32d6859679
@ -715,6 +715,12 @@
|
||||
paper: https://arxiv.org/pdf/1809.02789v1
|
||||
configpath: opencompass/configs/datasets/obqa/obqa_gen.py
|
||||
configpath_llmjudge: ''
|
||||
- olymmath:
|
||||
name: OlymMATH
|
||||
category: Math
|
||||
paper: https://arxiv.org/abs/2503.21380
|
||||
configpath: ''
|
||||
configpath_llmjudge: opencompass/configs/datasets/OlymMATH/olymmath_llm_judeg_gen.py
|
||||
- piqa:
|
||||
name: OpenBookQA
|
||||
category: Knowledge / Physics
|
||||
|
60
opencompass/configs/datasets/OlymMATH/README.md
Normal file
60
opencompass/configs/datasets/OlymMATH/README.md
Normal file
@ -0,0 +1,60 @@
|
||||
# OlymMATH
|
||||
[GitHub Link](https://github.com/RUCAIBox/OlymMATH)
|
||||
|
||||
Dataset OlymMATH, please refer to the paper:
|
||||
Challenging the Boundaries of Reasoning: An Olympiad-Level Math Benchmark for Large Language Models by Haoxiang Sun, Yingqian Min, Zhipeng Chen, Wayne Xin Zhao, Zheng Liu, Zhongyuan Wang, Lei Fang, and Ji-Rong Wen.
|
||||
|
||||
|
||||
## How to eval OlymMATH with model judge
|
||||
This is a simple example:
|
||||
```python
|
||||
|
||||
from opencompass.models import OpenAISDK, OpenAI
|
||||
from mmengine.config import read_base
|
||||
|
||||
|
||||
with read_base():
|
||||
from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_7b_instruct import models as qwen2_5_7b_instruct_model
|
||||
from opencompass.configs.datasets.OlymMATH.olymmath_gen import olymmath_datasets
|
||||
|
||||
################## Judge Config ##################
|
||||
api_meta_template = dict(round=[
|
||||
dict(role='HUMAN', api_role='HUMAN'),
|
||||
dict(role='BOT', api_role='BOT', generate=True),
|
||||
], )
|
||||
|
||||
judge_cfg = dict(
|
||||
# An API model with OpenAI API format is required for Judge
|
||||
abbr='qwen2-5-32B-Instruct',
|
||||
type=OpenAISDK,
|
||||
path='Qwen/Qwen2.5-32B-Instruct',
|
||||
key='sk-1234',
|
||||
openai_api_base=[
|
||||
'http://172.30.56.1:4000/v1',
|
||||
],
|
||||
meta_template=api_meta_template,
|
||||
query_per_second=16,
|
||||
batch_size=1024,
|
||||
temperature=0.001,
|
||||
max_completion_tokens=32768,
|
||||
tokenizer_path='gpt-4o-2024-05-13',
|
||||
verbose=True,
|
||||
max_out_len=16384,
|
||||
max_seq_len=32768,
|
||||
)
|
||||
|
||||
################## Model Config ##################
|
||||
models = [*qwen2_5_7b_instruct_model]
|
||||
|
||||
################## Dataset Config ##################
|
||||
datasets = [*olymmath_datasets]
|
||||
|
||||
# Set judge_cfg for evaluation
|
||||
for item in datasets:
|
||||
item['infer_cfg']['inferencer']['max_out_len'] = 32768
|
||||
if 'judge_cfg' in item['eval_cfg']['evaluator']:
|
||||
item['eval_cfg']['evaluator']['judge_cfg'] = judge_cfg
|
||||
|
||||
|
||||
work_dir = './outputs/olymmath_llm_eval'
|
||||
```
|
@ -0,0 +1,5 @@
|
||||
from mmengine.config import read_base
|
||||
|
||||
with read_base():
|
||||
# Default use LLM as a judge
|
||||
from .olymmath_llmverify_gen_97b203 import olymmath_datasets # noqa: F401, F403
|
@ -0,0 +1,99 @@
|
||||
from opencompass.openicl.icl_prompt_template import PromptTemplate
|
||||
from opencompass.openicl.icl_retriever import ZeroRetriever
|
||||
from opencompass.openicl.icl_inferencer import GenInferencer
|
||||
from opencompass.evaluator import GenericLLMEvaluator
|
||||
from opencompass.datasets import generic_llmjudge_postprocess
|
||||
from opencompass.datasets import OlymMATHDataset
|
||||
|
||||
|
||||
# ----------------------------- Detailed Config -----------------------------
|
||||
|
||||
math_reader_cfg = dict(input_columns=['problem'], output_column='answer', train_split='test')
|
||||
|
||||
math_infer_cfg = dict(
|
||||
prompt_template=dict(
|
||||
type=PromptTemplate,
|
||||
template=dict(
|
||||
round=[
|
||||
dict(role='HUMAN', prompt='{problem}\nRemember to put your final answer within \\boxed{}.'),
|
||||
]
|
||||
),
|
||||
),
|
||||
retriever=dict(type=ZeroRetriever),
|
||||
inferencer=dict(type=GenInferencer),
|
||||
)
|
||||
|
||||
sub_sets = ['en-hard', 'zh-hard', 'en-easy', 'zh-easy']
|
||||
|
||||
GRADER_TEMPLATE = """
|
||||
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.
|
||||
|
||||
Here are some evaluation criteria:
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
|
||||
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:
|
||||
A: CORRECT
|
||||
B: INCORRECT
|
||||
Just return the letters "A" or "B", with no text around it.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
<Original Question Begin>: \n{problem}\n<Original Question End>\n\n
|
||||
<Gold Target Begin>: \n{answer}\n<Gold Target End>\n\n
|
||||
<Predicted Answer Begin>: \n{prediction}\n<Predicted End>\n\n
|
||||
|
||||
Judging the correctness of candidates' answers:
|
||||
""".strip()
|
||||
|
||||
# Evaluation configuration
|
||||
|
||||
olymmath_datasets = []
|
||||
|
||||
for sub_set in sub_sets:
|
||||
math_eval_cfg = dict(
|
||||
evaluator=dict(
|
||||
type=GenericLLMEvaluator,
|
||||
prompt_template=dict(
|
||||
type=PromptTemplate,
|
||||
template=dict(
|
||||
begin=[
|
||||
dict(
|
||||
role='SYSTEM',
|
||||
fallback_role='HUMAN',
|
||||
prompt="You are a helpful assistant who evaluates the correctness and quality of models' outputs.")
|
||||
],
|
||||
round=[
|
||||
dict(
|
||||
role='HUMAN',
|
||||
prompt = GRADER_TEMPLATE
|
||||
),
|
||||
]),
|
||||
),
|
||||
dataset_cfg=dict(
|
||||
type=OlymMATHDataset,
|
||||
path='RUC-AIBOX/OlymMATH',
|
||||
reader_cfg=math_reader_cfg,
|
||||
subset=sub_set,
|
||||
),
|
||||
judge_cfg=dict(),
|
||||
dict_postprocessor=dict(type=generic_llmjudge_postprocess),
|
||||
),
|
||||
pred_role='BOT',
|
||||
)
|
||||
|
||||
olymmath_datasets.append(
|
||||
dict(
|
||||
type=OlymMATHDataset,
|
||||
abbr=f'olymmath_llmjudge_{sub_set}',
|
||||
path='RUC-AIBOX/OlymMATH',
|
||||
reader_cfg=math_reader_cfg,
|
||||
infer_cfg=math_infer_cfg,
|
||||
eval_cfg=math_eval_cfg,
|
||||
subset=sub_set,
|
||||
)
|
||||
)
|
@ -106,6 +106,7 @@ from .natural_question import * # noqa: F401, F403
|
||||
from .natural_question_cn import * # noqa: F401, F403
|
||||
from .NPHardEval import * # noqa: F401, F403
|
||||
from .obqa import * # noqa: F401, F403
|
||||
from .olymmath import * # noqa: F401, F403
|
||||
from .OlympiadBench import * # noqa: F401, F403
|
||||
from .OpenFinData import * # noqa: F401, F403
|
||||
from .piqa import * # noqa: F401, F403
|
||||
|
14
opencompass/datasets/olymmath.py
Normal file
14
opencompass/datasets/olymmath.py
Normal file
@ -0,0 +1,14 @@
|
||||
from datasets import load_dataset
|
||||
|
||||
from opencompass.registry import LOAD_DATASET
|
||||
|
||||
from .base import BaseDataset
|
||||
|
||||
|
||||
@LOAD_DATASET.register_module()
|
||||
class OlymMATHDataset(BaseDataset):
|
||||
|
||||
@staticmethod
|
||||
def load(path: str, subset: str):
|
||||
dataset = load_dataset(path, subset)
|
||||
return dataset
|
Loading…
Reference in New Issue
Block a user