-
Notifications
You must be signed in to change notification settings - Fork 18
feat: new benchmark OlympiadBench #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
W3en2g
wants to merge
3
commits into
PKU-Alignment:main
Choose a base branch
from
W3en2g:OlympiadBench
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
eval_anything/benchmarks/text_image_to_text/olympiadbench/configs.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # ============================================ | ||
| # 评测配置: | ||
| # - 数据集hf路径 | ||
| # - 数据集split | ||
| # - 数据集size | ||
| # - 数据集模态 | ||
| # - 评测方式(multiple choice / generation / ...) | ||
| # - 评测指标(accuracy / ...) | ||
| # - 是否支持few_shot | ||
| # - 选项编号形式(ABCD或1234...),判断对错时的标识(true/false或者1/0...) | ||
| # ============================================ | ||
| dataset: | ||
| name: olympiadbench | ||
| path: Hothan/OlympiadBench | ||
| split: train | ||
| size: | ||
| modality: text-image-to-text | ||
| fewshot_data_path: null | ||
| fewshot_data_name: null | ||
| fewshot_data_split: null | ||
| cot_fewshot_data_path: null | ||
| cot_fewshot_data_name: null | ||
| cot_fewshot_data_split: null | ||
| max_shot: 0 | ||
| default_task_list: ["OE_MM_maths_en_COMP", "OE_MM_maths_zh_CEE", "OE_MM_maths_zh_COMP","OE_MM_physics_en_COMP", "OE_MM_physics_zh_CEE", "OE_TO_maths_en_COMP","OE_TO_maths_zh_CEE", "OE_TO_maths_zh_COMP", "OE_TO_physics_en_COMP","OE_TO_physics_zh_CEE",] | ||
| task_defaults: &task_defaults | ||
| type: MultiChoice | ||
| question_key: question | ||
| answer_key: options | ||
| ground_truth_key: answer | ||
| candidate_labels: ["A", "B", "C", "D", "E"] | ||
| avalable_evaluate_tools: ["match_multi-choice_and_open-ended"] | ||
| task: | ||
| - name: OE_MM_maths_en_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_MM_maths_zh_CEE | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_MM_maths_zh_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_MM_physics_en_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_MM_physics_zh_CEE | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_TO_maths_en_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_TO_maths_zh_CEE | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_TO_maths_zh_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_TO_physics_en_COMP | ||
| data_files: null | ||
| <<: *task_defaults | ||
| - name: OE_TO_physics_zh_CEE | ||
| data_files: null | ||
| <<: *task_defaults | ||
| answer_extractor: | ||
| - name: match_multi-choice_and_open-ended | ||
| function: regex_match_latex_math | ||
| args: | ||
| match_index: -1 # Index for multiple choice | ||
| metrics: | ||
| - name: accuracy | ||
| function: accuracy | ||
| args: | ||
| overall_metrics: | ||
| - name: average | ||
| function: average_across_tasks | ||
| args: | ||
| null | ||
|
|
||
59 changes: 59 additions & 0 deletions
59
eval_anything/benchmarks/text_image_to_text/olympiadbench/eval.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| """ | ||
| 继承自eval-anything.pipeline.mm_und_benchmark | ||
| """ | ||
| from eval_anything.pipeline.mm_und_benchmark import MMUndBenchmark | ||
| from collections import namedtuple | ||
| from eval_anything.utils.data_type import EvaluationResult | ||
| from eval_anything.models.base_model import BaseModel | ||
| from eval_anything.utils.logger import EvalLogger | ||
| from eval_anything.utils.register import BenchmarkRegistry | ||
| from eval_anything.utils.cache_manager import CacheManager | ||
|
|
||
| @BenchmarkRegistry.register('olympiadbench') | ||
| class olympiadbenchBenchmark(MMUndBenchmark): | ||
| def __init__(self, | ||
| model: BaseModel, | ||
| eval_cfgs: namedtuple, | ||
| model_cfgs: namedtuple, | ||
| infer_cfgs: namedtuple, | ||
| output_path: str, | ||
| cache_manager: CacheManager, | ||
| logger: EvalLogger): | ||
| super().__init__(model, eval_cfgs, model_cfgs, infer_cfgs, output_path, cache_manager, logger) | ||
| self.benchmark_name = "olympiadbench" | ||
| self.benchmark_cfgs = self.get_benchmark_cfgs(self.benchmark_name) | ||
|
|
||
| def run(self, | ||
| task_list: list[str],) -> tuple[dict[str, list[EvaluationResult]], dict[str, dict[str, float]], dict[str, dict[str, float]]]: | ||
| """Run benchmark | ||
| Args: | ||
| task_list (list[str]): task list | ||
|
|
||
| Returns: | ||
| evaluation_details (dict[str, list[EvaluationResult]]): evaluation details | ||
| evaluation_results (dict[str, dict[str, float]]): evaluation results | ||
| """ | ||
|
|
||
| self.logger.log('info', f'Evaluating {self.benchmark_name}...') | ||
|
|
||
| dataloader = self.init_dataloader(self.eval_cfgs, self.benchmark_cfgs) | ||
| input_data = dataloader.load_dataset(task_list) # Input_data: list[InferenceInput] | ||
|
|
||
| inference_outputs = self.batch_inference(self.model, input_data) | ||
| ref_answers = {task: self.get_ref_answer(input_data[task], inference_outputs[task]) for task in task_list} | ||
| evaluation_details = {} | ||
| evaluation_results = {} | ||
|
|
||
| for task in task_list: | ||
| evaluation_details[task], evaluation_results[task] = self.calculate_metrics(self.benchmark_name, inference_outputs[task], ref_answers[task], self.benchmark_cfgs.answer_extractor, self.benchmark_cfgs.metrics, judge_method="judge_equal_list") | ||
|
|
||
| if len(task_list) > 1: | ||
| overall_result = self.calculate_overall_metrics(self.benchmark_cfgs.overall_metrics, result=evaluation_results) | ||
| else: | ||
| overall_result = {} | ||
|
|
||
| self.display_benchmark_results(self.benchmark_name, evaluation_results) | ||
| if overall_result != {}: | ||
| self.display_benchmark_results(self.benchmark_name, overall_result) | ||
| self.save_benchmark_details(self.output_path, self.benchmark_name, input_data, evaluation_details) | ||
| return evaluation_details, evaluation_results, overall_result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should match the function.