evalscope 0.12.0__py3-none-any.whl → 0.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of evalscope might be problematic. Click here for more details.

Files changed (85) hide show
  1. evalscope/arguments.py +6 -1
  2. evalscope/benchmarks/aime/aime24_adapter.py +3 -3
  3. evalscope/benchmarks/aime/aime25_adapter.py +3 -3
  4. evalscope/benchmarks/arc/arc_adapter.py +15 -18
  5. evalscope/benchmarks/bbh/bbh_adapter.py +6 -6
  6. evalscope/benchmarks/benchmark.py +12 -11
  7. evalscope/benchmarks/ceval/ceval_adapter.py +12 -16
  8. evalscope/benchmarks/chinese_simple_qa/__init__.py +0 -0
  9. evalscope/benchmarks/chinese_simple_qa/csimple_qa_adapter.py +168 -0
  10. evalscope/benchmarks/cmmlu/cmmlu_adapter.py +13 -17
  11. evalscope/benchmarks/competition_math/competition_math_adapter.py +3 -3
  12. evalscope/benchmarks/data_adapter.py +59 -21
  13. evalscope/benchmarks/data_collection/data_collection_adapter.py +0 -1
  14. evalscope/benchmarks/general_mcq/general_mcq_adapter.py +9 -12
  15. evalscope/benchmarks/general_qa/general_qa_adapter.py +30 -15
  16. evalscope/benchmarks/gpqa/gpqa_adapter.py +12 -7
  17. evalscope/benchmarks/gsm8k/gsm8k_adapter.py +2 -3
  18. evalscope/benchmarks/hellaswag/hellaswag_adapter.py +23 -31
  19. evalscope/benchmarks/humaneval/humaneval_adapter.py +10 -7
  20. evalscope/benchmarks/ifeval/ifeval_adapter.py +2 -3
  21. evalscope/benchmarks/iquiz/iquiz_adapter.py +9 -5
  22. evalscope/benchmarks/live_code_bench/__init__.py +0 -0
  23. evalscope/benchmarks/live_code_bench/evaluate_utils.py +193 -0
  24. evalscope/benchmarks/live_code_bench/execute_utils.py +267 -0
  25. evalscope/benchmarks/live_code_bench/extract_utils.py +70 -0
  26. evalscope/benchmarks/live_code_bench/live_code_bench_adapter.py +90 -0
  27. evalscope/benchmarks/live_code_bench/load_utils.py +71 -0
  28. evalscope/benchmarks/live_code_bench/pass_k_utils.py +56 -0
  29. evalscope/benchmarks/live_code_bench/prompts.py +207 -0
  30. evalscope/benchmarks/live_code_bench/testing_util.py +721 -0
  31. evalscope/benchmarks/math_500/math_500_adapter.py +2 -6
  32. evalscope/benchmarks/mmlu/mmlu_adapter.py +13 -17
  33. evalscope/benchmarks/mmlu_pro/mmlu_pro_adapter.py +9 -5
  34. evalscope/benchmarks/musr/musr_adapter.py +8 -5
  35. evalscope/benchmarks/process_bench/process_bench_adapter.py +8 -5
  36. evalscope/benchmarks/race/race_adapter.py +12 -16
  37. evalscope/benchmarks/simple_qa/__init__.py +0 -0
  38. evalscope/benchmarks/simple_qa/simple_qa_adapter.py +167 -0
  39. evalscope/benchmarks/super_gpqa/__init__.py +0 -0
  40. evalscope/benchmarks/super_gpqa/five_shot_prompt.txt +89 -0
  41. evalscope/benchmarks/super_gpqa/super_gpqa_adapter.py +191 -0
  42. evalscope/benchmarks/super_gpqa/utils.py +85 -0
  43. evalscope/benchmarks/super_gpqa/zero_shot_prompt.txt +3 -0
  44. evalscope/benchmarks/trivia_qa/trivia_qa_adapter.py +3 -4
  45. evalscope/benchmarks/truthful_qa/truthful_qa_adapter.py +6 -13
  46. evalscope/benchmarks/utils.py +43 -0
  47. evalscope/collections/evaluator.py +14 -5
  48. evalscope/config.py +15 -2
  49. evalscope/constants.py +14 -0
  50. evalscope/evaluator/evaluator.py +51 -13
  51. evalscope/metrics/llm_judge.py +104 -0
  52. evalscope/metrics/named_metrics.py +1 -0
  53. evalscope/models/__init__.py +2 -1
  54. evalscope/models/base_adapter.py +25 -5
  55. evalscope/models/chat_adapter.py +3 -0
  56. evalscope/models/choice_adapter.py +4 -0
  57. evalscope/models/custom_adapter.py +2 -0
  58. evalscope/models/register.py +28 -0
  59. evalscope/models/server_adapter.py +35 -8
  60. evalscope/perf/arguments.py +13 -7
  61. evalscope/perf/benchmark.py +5 -0
  62. evalscope/perf/http_client.py +15 -5
  63. evalscope/perf/main.py +1 -0
  64. evalscope/perf/utils/analysis_result.py +1 -1
  65. evalscope/report/app.py +3 -0
  66. evalscope/report/combinator.py +2 -2
  67. evalscope/run.py +6 -5
  68. evalscope/third_party/longbench_write/infer.py +1 -1
  69. evalscope/third_party/thinkbench/eval.py +220 -55
  70. evalscope/third_party/thinkbench/infer.py +37 -7
  71. evalscope/third_party/thinkbench/tools/llm.py +1 -0
  72. evalscope/third_party/toolbench_static/llm/swift_infer.py +50 -20
  73. evalscope/utils/chat_service.py +1 -0
  74. evalscope/utils/filters.py +59 -0
  75. evalscope/utils/logger.py +3 -3
  76. evalscope/version.py +2 -2
  77. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/METADATA +31 -12
  78. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/RECORD +85 -62
  79. tests/cli/test_all.py +144 -0
  80. tests/cli/test_collection.py +28 -2
  81. tests/cli/test_run.py +201 -32
  82. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/LICENSE +0 -0
  83. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/WHEEL +0 -0
  84. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/entry_points.txt +0 -0
  85. {evalscope-0.12.0.dist-info → evalscope-0.13.0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,5 @@
1
- from collections import defaultdict
2
-
3
1
  from evalscope.benchmarks import Benchmark, DataAdapter
4
- from evalscope.constants import AnswerKeys
5
2
  from evalscope.metrics.math_parser import extract_answer, math_equal, strip_answer_string
6
- from evalscope.models import ChatGenerationModelAdapter
7
3
  from evalscope.utils.logger import get_logger
8
4
 
9
5
  # flake8: noqa
@@ -13,8 +9,8 @@ logger = get_logger()
13
9
 
14
10
  @Benchmark.register(
15
11
  name='math_500',
12
+ pretty_name='MATH-500',
16
13
  dataset_id='AI-ModelScope/MATH-500',
17
- model_adapter=ChatGenerationModelAdapter,
18
14
  subset_list=['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5'],
19
15
  metric_list=['AveragePass@1'],
20
16
  few_shot_num=0,
@@ -40,7 +36,7 @@ class Math500Adapter(DataAdapter):
40
36
  problem = input_d['problem']
41
37
  full_prompt = self.prompt_template.format(query=problem)
42
38
 
43
- return {'data': [full_prompt], 'system_prompt': self.system_prompt}
39
+ return self.gen_prompt_data(full_prompt)
44
40
 
45
41
  def get_gold_answer(self, input_d: dict) -> str:
46
42
  # Extract the gold answer from the input dict.
@@ -3,9 +3,8 @@ import csv
3
3
  import os
4
4
 
5
5
  from evalscope.benchmarks import Benchmark, DataAdapter
6
- from evalscope.constants import EvalType
6
+ from evalscope.constants import EvalType, OutputType
7
7
  from evalscope.metrics import exact_match
8
- from evalscope.models import MultiChoiceModelAdapter
9
8
  from evalscope.utils import ResponseParser
10
9
  from evalscope.utils.logger import get_logger
11
10
 
@@ -136,19 +135,20 @@ SUBJECT_MAPPING = {
136
135
 
137
136
  @Benchmark.register(
138
137
  name='mmlu',
138
+ pretty_name='MMLU',
139
139
  dataset_id='modelscope/mmlu',
140
- model_adapter=MultiChoiceModelAdapter,
140
+ model_adapter=OutputType.MULTIPLE_CHOICE,
141
+ output_types=[OutputType.MULTIPLE_CHOICE, OutputType.GENERATION],
141
142
  subset_list=SUBSET_LIST,
142
143
  metric_list=['AverageAccuracy'],
143
144
  few_shot_num=5,
144
145
  train_split='train',
145
146
  eval_split='test',
146
- prompt_template='The following are multiple choice questions (with answers) about {subset_name}. \n{query}',
147
+ prompt_template=
148
+ 'Answer the following multiple choice question about {subset_name}. There is only one correct answer. The last line of your response should be in the format "Answer: LETTER" (without quotes), where LETTER is one of A, B, C, D. \n{query}',
147
149
  )
148
150
  class MMLUAdapter(DataAdapter):
149
151
 
150
- choices = ['A', 'B', 'C', 'D']
151
-
152
152
  def __init__(self, **kwargs):
153
153
 
154
154
  few_shot_num = kwargs.get('few_shot_num', 5)
@@ -159,6 +159,7 @@ class MMLUAdapter(DataAdapter):
159
159
  super().__init__(**kwargs)
160
160
 
161
161
  self.category_map = {k: v[-1] for k, v in SUBJECT_MAPPING.items()}
162
+ self.choices = ['A', 'B', 'C', 'D']
162
163
 
163
164
  def load_from_disk(self, dataset_name_or_path, subset_list, work_dir, **kwargs) -> dict:
164
165
  data_dict = {}
@@ -227,7 +228,7 @@ class MMLUAdapter(DataAdapter):
227
228
 
228
229
  full_prompt = self.prompt_template.format(subset_name=self._format_subject(subset_name), query=query)
229
230
 
230
- return {'data': [full_prompt], 'multi_choices': self.choices, 'system_prompt': self.system_prompt}
231
+ return self.gen_prompt_data(full_prompt)
231
232
 
232
233
  def get_gold_answer(self, input_d: dict) -> str:
233
234
  # Get the gold choice
@@ -245,26 +246,21 @@ class MMLUAdapter(DataAdapter):
245
246
  Returns:
246
247
  The parsed answer. Depending on the dataset. Usually a string for chat.
247
248
  """
248
- if eval_type == EvalType.CHECKPOINT:
249
+ if self.model_adapter == OutputType.MULTIPLE_CHOICE:
249
250
  return result
250
- elif eval_type == EvalType.SERVICE:
251
- return ResponseParser.parse_first_option_with_choices(result, self.choices)
252
- elif eval_type == EvalType.CUSTOM:
253
- return ResponseParser.parse_first_option_with_choices(result, self.choices)
254
251
  else:
255
- raise ValueError(f'Invalid eval_type: {eval_type}')
252
+ return ResponseParser.parse_first_option(result)
256
253
 
257
254
  def match(self, gold: str, pred: str) -> float:
258
255
  return exact_match(gold=gold, pred=pred)
259
256
 
260
- @classmethod
261
- def _generate_prompt(cls, input_d: dict, include_answer=True) -> str:
257
+ def _generate_prompt(self, input_d: dict, include_answer=True) -> str:
262
258
 
263
259
  input_choices: list = [input_d['A'], input_d['B'], input_d['C'], input_d['D']]
264
260
 
265
261
  example: str = input_d['input']
266
- for j in range(len(cls.choices)):
267
- example += '\n{}. {}'.format(cls.choices[j], input_choices[j])
262
+ for j in range(len(self.choices)):
263
+ example += '\n{}. {}'.format(self.choices[j], input_choices[j])
268
264
 
269
265
  example += '\nAnswer:'
270
266
  if include_answer:
@@ -2,9 +2,8 @@ from collections import defaultdict
2
2
  from typing import Any, Dict
3
3
 
4
4
  from evalscope.benchmarks import Benchmark, DataAdapter
5
- from evalscope.constants import AnswerKeys, EvalType
5
+ from evalscope.constants import EvalType, OutputType
6
6
  from evalscope.metrics import exact_match
7
- from evalscope.models import ChatGenerationModelAdapter
8
7
  from evalscope.utils.utils import ResponseParser
9
8
 
10
9
  SUBSET_LIST = [
@@ -15,8 +14,10 @@ SUBSET_LIST = [
15
14
 
16
15
  @Benchmark.register(
17
16
  name='mmlu_pro',
17
+ pretty_name='MMLU-Pro',
18
18
  dataset_id='modelscope/MMLU-Pro',
19
- model_adapter=ChatGenerationModelAdapter,
19
+ model_adapter=OutputType.GENERATION,
20
+ output_types=[OutputType.MULTIPLE_CHOICE, OutputType.GENERATION],
20
21
  subset_list=SUBSET_LIST,
21
22
  metric_list=['AverageAccuracy'],
22
23
  few_shot_num=5,
@@ -47,7 +48,7 @@ class MMLUProAdapter(DataAdapter):
47
48
  self.__form_options(input_d['options']) + '\n'
48
49
 
49
50
  full_prompt = self.prompt_template.format(subset_name=subset_name, query=query)
50
- return {'data': [full_prompt], 'system_prompt': self.system_prompt}
51
+ return self.gen_prompt_data(full_prompt)
51
52
 
52
53
  def format_fewshot_examples(self, few_shot_list):
53
54
  # load few-shot prompts for each category
@@ -88,7 +89,10 @@ class MMLUProAdapter(DataAdapter):
88
89
  Returns:
89
90
  The parsed answer. Depending on the dataset. Usually a string for chat.
90
91
  """
91
- return ResponseParser.parse_first_option(result)
92
+ if self.model_adapter == OutputType.MULTIPLE_CHOICE:
93
+ return result
94
+ else:
95
+ return ResponseParser.parse_first_option(result)
92
96
 
93
97
  def match(self, gold: str, pred: str) -> float:
94
98
  """
@@ -2,9 +2,8 @@ import ast
2
2
  from typing import Any
3
3
 
4
4
  from evalscope.benchmarks import Benchmark, DataAdapter
5
- from evalscope.constants import EvalType
5
+ from evalscope.constants import EvalType, OutputType
6
6
  from evalscope.metrics import exact_match
7
- from evalscope.models import ChatGenerationModelAdapter
8
7
  from evalscope.utils.utils import ResponseParser
9
8
 
10
9
 
@@ -12,7 +11,8 @@ from evalscope.utils.utils import ResponseParser
12
11
  name='musr',
13
12
  pretty_name='MuSR',
14
13
  dataset_id='AI-ModelScope/MuSR',
15
- model_adapter=ChatGenerationModelAdapter,
14
+ model_adapter=OutputType.GENERATION,
15
+ output_types=[OutputType.MULTIPLE_CHOICE, OutputType.GENERATION],
16
16
  subset_list=['murder_mysteries', 'object_placements', 'team_allocation'],
17
17
  metric_list=['AverageAccuracy'],
18
18
  few_shot_num=0,
@@ -41,7 +41,7 @@ class MuSRAdapter(DataAdapter):
41
41
  full_prompt = self.prompt_template.format(
42
42
  narrative=input_d['narrative'], question=input_d['question'], choices=choices)
43
43
 
44
- return {'data': [full_prompt], 'system_prompt': self.system_prompt}
44
+ return self.gen_prompt_data(full_prompt)
45
45
 
46
46
  def format_choice(self, options: list):
47
47
  option_str = ''
@@ -59,7 +59,10 @@ class MuSRAdapter(DataAdapter):
59
59
  """
60
60
  Parse the predicted result and extract proper answer.
61
61
  """
62
- return ResponseParser.parse_first_option(result)
62
+ if self.model_adapter == OutputType.MULTIPLE_CHOICE:
63
+ return result
64
+ else:
65
+ return ResponseParser.parse_first_option(result)
63
66
 
64
67
  def match(self, gold: str, pred: str) -> float:
65
68
  """
@@ -5,7 +5,6 @@ from typing import Any, List
5
5
  from evalscope.benchmarks import Benchmark, DataAdapter
6
6
  from evalscope.constants import AnswerKeys, EvalType
7
7
  from evalscope.metrics import Metric, mean, metric_registry, simple_f1_score
8
- from evalscope.models import ChatGenerationModelAdapter
9
8
 
10
9
  cur_path = os.path.dirname(os.path.abspath(__file__))
11
10
 
@@ -14,7 +13,6 @@ cur_path = os.path.dirname(os.path.abspath(__file__))
14
13
  name='process_bench',
15
14
  pretty_name='ProcessBench',
16
15
  dataset_id='Qwen/ProcessBench',
17
- model_adapter=ChatGenerationModelAdapter,
18
16
  subset_list=['gsm8k', 'math', 'olympiadbench', 'omnimath'],
19
17
  metric_list=['error_acc', 'correct_acc', 'simple_f1_score'],
20
18
  few_shot_num=0,
@@ -26,7 +24,7 @@ class ProcessBenchAdapter(DataAdapter):
26
24
  def __init__(self, **kwargs):
27
25
  super().__init__(**kwargs)
28
26
 
29
- self.prompt_template = open(os.path.join(cur_path, 'critique_template.txt')).read()
27
+ self.prompt_template = open(os.path.join(cur_path, 'critique_template.txt'), encoding='utf-8').read()
30
28
 
31
29
  # register metrics
32
30
  metric_registry.register(Metric(name='error_acc', object=mean))
@@ -50,7 +48,7 @@ class ProcessBenchAdapter(DataAdapter):
50
48
 
51
49
  full_prompt = self.prompt_template.format(problem=problem, tagged_response=tagged_response)
52
50
 
53
- return {'data': [full_prompt], 'system_prompt': self.system_prompt}
51
+ return self.gen_prompt_data(full_prompt)
54
52
 
55
53
  def get_gold_answer(self, input_d: dict) -> str:
56
54
  """
@@ -84,7 +82,12 @@ class ProcessBenchAdapter(DataAdapter):
84
82
  correct_data.append(res)
85
83
  else:
86
84
  error_data.append(res)
87
- data = {'error_acc': error_data, 'correct_acc': correct_data, 'simple_f1_score': (correct_data, error_data)}
85
+ data = {}
86
+ if len(correct_data) != 0:
87
+ data.update({'correct_acc': correct_data})
88
+ if len(error_data) != 0:
89
+ data.update({'error_acc': error_data})
90
+ data.update({'simple_f1_score': (correct_data, error_data)})
88
91
  return super().compute_metric(data)
89
92
 
90
93
  @staticmethod
@@ -3,9 +3,8 @@
3
3
  import os
4
4
 
5
5
  from evalscope.benchmarks import Benchmark, DataAdapter
6
- from evalscope.constants import EvalType
6
+ from evalscope.constants import EvalType, OutputType
7
7
  from evalscope.metrics import exact_match
8
- from evalscope.models import MultiChoiceModelAdapter
9
8
  from evalscope.utils import ResponseParser
10
9
  from evalscope.utils.io_utils import jsonl_to_list
11
10
  from evalscope.utils.logger import get_logger
@@ -17,8 +16,10 @@ logger = get_logger()
17
16
 
18
17
  @Benchmark.register(
19
18
  name='race',
19
+ pretty_name='RACE',
20
20
  dataset_id='modelscope/race',
21
- model_adapter=MultiChoiceModelAdapter,
21
+ model_adapter=OutputType.MULTIPLE_CHOICE,
22
+ output_types=[OutputType.MULTIPLE_CHOICE, OutputType.GENERATION],
22
23
  subset_list=['high', 'middle'],
23
24
  metric_list=['AverageAccuracy'],
24
25
  few_shot_num=3,
@@ -27,8 +28,6 @@ logger = get_logger()
27
28
  )
28
29
  class RACEAdapter(DataAdapter):
29
30
 
30
- choices = ['A', 'B', 'C', 'D']
31
-
32
31
  def __init__(self, **kwargs):
33
32
  few_shot_num = kwargs.get('few_shot_num', 3)
34
33
  if few_shot_num > 3:
@@ -37,6 +36,8 @@ class RACEAdapter(DataAdapter):
37
36
 
38
37
  super().__init__(**kwargs)
39
38
 
39
+ self.choices = ['A', 'B', 'C', 'D']
40
+
40
41
  def load_from_disk(self, dataset_name_or_path, subset_list, work_dir, **kwargs) -> dict:
41
42
  data_dict = {}
42
43
  for subset_name in subset_list:
@@ -82,7 +83,7 @@ class RACEAdapter(DataAdapter):
82
83
 
83
84
  full_prompt: str = context.strip() + self._generate_prompt(input_d=input_d, include_answer=False)
84
85
 
85
- return {'data': [full_prompt], 'multi_choices': self.choices, 'system_prompt': self.system_prompt}
86
+ return self.gen_prompt_data(full_prompt)
86
87
 
87
88
  def get_gold_answer(self, input_d: dict) -> str:
88
89
  # Get the gold choice
@@ -100,26 +101,21 @@ class RACEAdapter(DataAdapter):
100
101
  Returns:
101
102
  The parsed answer. Depending on the dataset. Usually a string for chat.
102
103
  """
103
- if eval_type == EvalType.CHECKPOINT:
104
+ if self.model_adapter == OutputType.MULTIPLE_CHOICE:
104
105
  return result
105
- elif eval_type == EvalType.SERVICE:
106
- return ResponseParser.parse_first_option_with_choices(result, self.choices) # TODO: to be checked !
107
- elif eval_type == EvalType.CUSTOM:
108
- return ResponseParser.parse_first_option_with_choices(result, self.choices) # TODO: to be checked !
109
106
  else:
110
- raise ValueError(f'Unknown eval_type: {eval_type}')
107
+ return ResponseParser.parse_first_option_with_choices(result, self.choices)
111
108
 
112
109
  def match(self, gold: str, pred: str) -> float:
113
110
  return exact_match(gold=gold, pred=pred)
114
111
 
115
- @classmethod
116
- def _generate_prompt(cls, input_d: dict, include_answer=True) -> str:
112
+ def _generate_prompt(self, input_d: dict, include_answer=True) -> str:
117
113
 
118
114
  input_choices: list = input_d['options']
119
115
 
120
116
  example: str = 'Article:\n{}\nQuestion:\n{}'.format(input_d['article'], input_d['question'])
121
- for j in range(len(cls.choices)):
122
- example += '\n{}. {}'.format(cls.choices[j], input_choices[j])
117
+ for j in range(len(self.choices)):
118
+ example += '\n{}. {}'.format(self.choices[j], input_choices[j])
123
119
 
124
120
  example += '\nAnswer:'
125
121
  if include_answer:
File without changes
@@ -0,0 +1,167 @@
1
+ import re
2
+ from collections import defaultdict
3
+ from typing import Any, List
4
+
5
+ from evalscope.benchmarks import Benchmark, DataAdapter
6
+ from evalscope.metrics import Metric, mean, metric_registry
7
+ from evalscope.metrics.llm_judge import LLMJudge
8
+ from evalscope.utils.logger import get_logger
9
+
10
+ # flake8: noqa
11
+
12
+ logger = get_logger()
13
+
14
+ GRADER_TEMPLATE = """
15
+ Your job is to look at a question, a gold target, and a predicted answer, and then assign a grade of either ["CORRECT", "INCORRECT", "NOT_ATTEMPTED"].
16
+ First, I will give examples of each grade, and then you will grade a new example.
17
+
18
+
19
+ The following are examples of CORRECT predicted answers.
20
+ ```
21
+ Question: What are the names of Barack Obama's children?
22
+ Gold target: Malia Obama and Sasha Obama
23
+ Predicted answer 1: sasha and malia obama
24
+ Predicted answer 2: most people would say Malia and Sasha, but I'm not sure and would have to double check
25
+ Predicted answer 3: Barack Obama has two daughters. Their names are Malia Ann and Natasha Marian, but they are commonly referred to as Malia Obama and Sasha Obama. Malia was born on July 4, 1998, and Sasha was born on June 10, 2001.
26
+ ```
27
+ These predicted answers are all CORRECT because:
28
+ - They fully contain the important information in the gold target.
29
+ - They do not contain any information that contradicts the gold target.
30
+ - Only semantic meaning matters; capitalization, punctuation, grammar, and order don't matter.
31
+ - Hedging and guessing are permissible, provided that the gold target is fully included and the response contains no incorrect information or contradictions.
32
+
33
+
34
+ The following are examples of INCORRECT predicted answers.
35
+ ```
36
+ Question: What are the names of Barack Obama's children?
37
+ Gold target: Malia and Sasha
38
+ Predicted answer 1: Malia.
39
+ Predicted answer 2: Malia, Sasha, and Susan.
40
+ Predicted answer 3: Barack Obama does not have any children.
41
+ Predicted answer 4: I think it's either Malia and Sasha. Or it could be Malia and Jackie. Or it could be Joey and Malia.
42
+ Predicted answer 4: While I don't know their exact names, I can tell you that Barack Obama has three children.
43
+ Predicted answer 5: It's possible you may mean Betsy and Olivia. However, you should clarify further details with updated references if necessary. Is that the correct answer?
44
+ Predicted answer 6: It may be the case that Obama's child is named James. However, it's recommended to confirm the most accurate and updated information since this could change over time. This model may not always reflect the most current information.
45
+ ```
46
+ These predicted answers are all INCORRECT because:
47
+ - A factual statement in the answer contradicts the gold target. Incorrect statements that have some hedging (e.g., "it is possible that", "although i'm not sure, i think") are also considered incorrect.
48
+
49
+
50
+ The following are examples of NOT_ATTEMPTED predicted answers.
51
+ ```
52
+ Question: What are the names of Barack Obama's children?
53
+ Gold target: Malia and Sasha
54
+ Predicted answer 1: I don't know.
55
+ Predicted answer 2: I need more context about which Obama you are talking about.
56
+ Predicted answer 3: Without researching the web, I cannot answer this question. However, I can tell you that Barack Obama has two children.
57
+ Predicted answer 4: Barack Obama has two children. I know that one of them is Malia, but I'm not sure about the other one.
58
+ ```
59
+ These predicted answers are all NOT_ATTEMPTED because:
60
+ - The important information in the gold target is not included in the answer.
61
+ - No statements in the answer contradict the gold target.
62
+
63
+
64
+ Also note the following things:
65
+ - For grading questions where the gold target is a number, the predicted answer needs to be correct to the last significant figure in the gold answer. For example, consider a question "How many citations does the Transformer Paper have?" with gold target "120k".
66
+ - Predicted answers "120k", "124k", and 115k" are all CORRECT.
67
+ - Predicted answers "100k" and "113k" are INCORRECT.
68
+ - Predicted answers "around 100k" and "more than 50k" are considered NOT_ATTEMPTED because they neither confirm nor contradict the gold target.
69
+ - The gold target may contain more information than the question. In such cases, the predicted answer only needs to contain the information that is in the question.
70
+ - For example, consider the question "What episode did Derek and Meredith get legally married in Grey's Anatomy?" with gold target "Season 7, Episode 20: White Wedding". Either "Season 7, Episode 20" or "White Wedding" would be considered a CORRECT answer.
71
+ - Do not punish predicted answers if they omit information that would be clearly inferred from the question.
72
+ - For example, consider the question "What city is OpenAI headquartered in?" and the gold target "San Francisco, California". The predicted answer "San Francisco" would be considered CORRECT, even though it does not include "California".
73
+ - Consider the question "What award did A pretrainer's guide to training data: Measuring the effects of data age, domain coverage, quality, & toxicity win at NAACL '24?", the gold target is "Outstanding Paper Award". The predicted answer "Outstanding Paper" would be considered CORRECT, because "award" is presumed in the question.
74
+ - For the question "What is the height of Jason Wei in meters?", the gold target is "1.73 m". The predicted answer "1.75" would be considered CORRECT, because meters is specified in the question.
75
+ - For the question "What is the name of Barack Obama's wife?", the gold target is "Michelle Obama". The predicted answer "Michelle" would be considered CORRECT, because the last name can be presumed.
76
+ - Do not punish for typos in people's name if it's clearly the same name.
77
+ - For example, if the gold target is "Hyung Won Chung", you can consider the following predicted answers as correct: "Hyoong Won Choong", "Hyungwon Chung", or "Hyun Won Chung".
78
+
79
+
80
+ Here is a new example. Simply reply with either CORRECT, INCORRECT, NOT ATTEMPTED. Don't apologize or correct yourself if there was a mistake; we are just trying to grade the answer.
81
+ ```
82
+ Question: {question}
83
+ Gold target: {target}
84
+ Predicted answer: {predicted_answer}
85
+ ```
86
+
87
+ Grade the predicted answer of this new question as one of:
88
+ A: CORRECT
89
+ B: INCORRECT
90
+ C: NOT_ATTEMPTED
91
+
92
+ Just return the letters "A", "B", or "C", with no text around it.
93
+ """.strip() # noqa: E501
94
+
95
+
96
+ @Benchmark.register(
97
+ name='simple_qa',
98
+ pretty_name='SimpleQA',
99
+ dataset_id='AI-ModelScope/SimpleQA',
100
+ metric_list=['is_correct', 'is_incorrect', 'is_not_attempted'],
101
+ few_shot_num=0,
102
+ train_split=None,
103
+ eval_split='test')
104
+ class SimpleQAAdapter(DataAdapter):
105
+
106
+ def __init__(self, *args, **kwargs):
107
+ super().__init__(*args, **kwargs)
108
+
109
+ # register metrics
110
+ metric_registry.register(Metric(name='is_correct', object=mean))
111
+ metric_registry.register(Metric(name='is_incorrect', object=mean))
112
+ metric_registry.register(Metric(name='is_not_attempted', object=mean))
113
+
114
+ # whether to use LLM as a judge
115
+ self.llm_as_a_judge = True
116
+
117
+ def gen_prompt(self, input_d: dict, subset_name: str, few_shot_list: list, **kwargs) -> dict:
118
+ question = input_d['problem']
119
+ return self.gen_prompt_data(question)
120
+
121
+ def get_gold_answer(self, input_d: dict) -> str:
122
+ return input_d['answer']
123
+
124
+ def parse_pred_result(self, result: str, raw_input_d: dict = None, **kwargs) -> str:
125
+ return result.strip()
126
+
127
+ def match(self, gold: str, pred: str) -> float:
128
+ # simple match
129
+ logger.warning(f'Please use LLMJudge to match the result for SimpleQA')
130
+ is_correct = 1 if gold.lower().strip() == pred.lower().strip() else 0
131
+ is_incorrect = not is_correct
132
+ is_not_attempted = 0
133
+ return {
134
+ 'is_correct': is_correct,
135
+ 'is_incorrect': is_incorrect,
136
+ 'is_not_attempted': is_not_attempted,
137
+ }
138
+
139
+ def llm_match(self, gold: Any, pred: Any, judge: LLMJudge, **kwargs) -> dict:
140
+ raw_input = kwargs.get('raw_input', None)
141
+ question = raw_input['problem']
142
+ # get grading response
143
+ prompt = GRADER_TEMPLATE.format(question=question, target=gold, predicted_answer=pred)
144
+ grading_response = judge(prompt)
145
+ # parse grading response
146
+ match = re.search(r'(A|B|C)', grading_response)
147
+ res = match.group(0) if match else 'C'
148
+ return {
149
+ 'is_correct': 1 if res == 'A' else 0,
150
+ 'is_incorrect': 1 if res == 'B' else 0,
151
+ 'is_not_attempted': 1 if res == 'C' else 0,
152
+ }
153
+
154
+ def compute_metric(self, review_res_list: List[dict], **kwargs) -> List[dict]:
155
+ """
156
+ compute weighted mean of the bleu score of all samples
157
+
158
+ Args:
159
+ review_res_list: [{'is_correct': 1, 'is_incorrect': 0, 'is_not_attempted': 0}, ...]
160
+ """
161
+ # zip dict answers
162
+ res_dict = defaultdict(list)
163
+ for res in review_res_list:
164
+ for key, value in res.items():
165
+ res_dict[key].append(value)
166
+
167
+ return super().compute_metric(res_dict, **kwargs)
File without changes
@@ -0,0 +1,89 @@
1
+ Answer the following multiple choice question. There is only one correct answer. The last line of your response should be in the format 'Answer: $LETTER' (without quotes), where LETTER is one of A, B, C, D, E, F, G, H, I, or J.
2
+
3
+ Question:
4
+ A refracting telescope consists of two converging lenses separated by 100 cm. The eye-piece lens has a focal length of 20 cm. The angular magnification of the telescope is
5
+ A) 10
6
+ B) 40
7
+ C) 6
8
+ D) 25
9
+ E) 15
10
+ F) 50
11
+ G) 30
12
+ H) 4
13
+ I) 5
14
+ J) 20
15
+
16
+ Answer: Let's think step by step. In a refracting telescope, if both lenses are converging, the focus of both lenses must be between the two lenses, and thus the focal lengths of the two lenses must add up to their separation. Since the focal length of one lens is 20 cm, the focal length of the other must be 80 cm. The magnification is the ratio of these two focal lengths, or 4.
17
+ Answer: H.
18
+
19
+ Question:
20
+ Say the pupil of your eye has a diameter of 5 mm and you have a telescope with an aperture of 50 cm. How much more light can the telescope gather than your eye?
21
+ A) 1000 times more
22
+ B) 50 times more
23
+ C) 5000 times more
24
+ D) 500 times more
25
+ E) 10000 times more
26
+ F) 20000 times more
27
+ G) 2000 times more
28
+ H) 100 times more
29
+ I) 10 times more
30
+ J) N/A
31
+
32
+ Answer: Let's think step by step. The amount of light a telescope can gather compared to the human eye is proportional to the area of its apertures. The area of a circle is given by the formula $A = \pi \left(\frac{{D}}{{2}}\right)^2$, where $D$ is the diameter. Therefore, the relative light-gathering power is calculated as:
33
+ \[
34
+ \frac{{\left(\frac{{50 \text{{ cm}}}}{{2}}\right)^2}}{{\left(\frac{{5 \text{{ mm}}}}{{2}}\right)^2}} = \frac{{\left(\frac{{50 \text{{ cm}}}}{{0.1 \text{{ cm}}}}\right)^2}}{{\left(\frac{{5 \text{{ mm}}}}{{0.1 \text{{ cm}}}}\right)^2}} = \frac{{500^2}}{{5^2}} = 10000.
35
+ \]
36
+ Answer: E.
37
+
38
+ Question:
39
+ Where do most short-period comets come from and how do we know?
40
+ A) The Kuiper belt; short period comets tend to be in the plane of the solar system like the Kuiper belt.
41
+ B) The asteroid belt; short period comets tend to come from random directions indicating a spherical distribution of comets called the asteroid belt.
42
+ C) The asteroid belt; short period comets tend to be in the plane of the solar system just like the asteroid belt.
43
+ D) The Oort cloud; short period comets have orbital periods similar to asteroids like Vesta and are found in the plane of the solar system just like the Oort cloud.
44
+ E) The Oort Cloud; short period comets tend to come from random directions indicating a spherical distribution of comets called the Oort Cloud.
45
+ F) The Oort cloud; short period comets tend to be in the plane of the solar system just like the Oort cloud.
46
+ G) The asteroid belt; short period comets have orbital periods similar to asteroids like Vesta and are found in the plane of the solar system just like the asteroid belt.
47
+ Answer: Let's think step by step. Most short-period comets originate from the Kuiper belt. This is deduced from the observation that these comets tend to follow orbits that lie in the plane of the solar system, similar to the distribution of objects in the Kuiper belt itself. Thus, the alignment of these cometary orbits with the ecliptic plane points to their Kuiper belt origin.
48
+ Answer: A.
49
+
50
+ Question:
51
+ Colors in a soap bubble result from light
52
+ A) dispersion
53
+ B) deflection
54
+ C) refraction
55
+ D) reflection
56
+ E) interference
57
+ F) converted to a different frequency
58
+ G) polarization
59
+ H) absorption
60
+ I) diffraction
61
+ J) transmission
62
+
63
+ Answer: Let's think step by step. The colorful patterns observed in a soap bubble are caused by the phenomenon of light interference. This occurs when light waves bounce between the two surfaces of the soap film, combining constructively or destructively based on their phase differences and the varying thickness of the film. These interactions result in vibrant color patterns due to variations in the intensity of different wavelengths of light.
64
+ Answer: E.
65
+
66
+ Question:
67
+ A microwave oven is connected to an outlet, 120 V, and draws a current of 2 amps. At what rate is energy being used by the microwave oven?
68
+ A) 240 W
69
+ B) 120 W
70
+ C) 10 W
71
+ D) 480 W
72
+ E) 360 W
73
+ F) 200 W
74
+ G) 30 W
75
+ H) 150 W
76
+ I) 60 W
77
+ J) 300 W
78
+
79
+ Answer: Let's think step by step. The rate of energy usage, known as power, in an electrical circuit is calculated by the product of voltage and current. For a microwave oven connected to a 120 V outlet and drawing a current of 2 amps, the power consumption can be calculated as follows:
80
+ \[
81
+ \text{{Power}} = \text{{Voltage}} \times \text{{Current}} = 120 \, \text{{V}} \times 2 \, \text{{A}} = 240 \, \text{{W}}.
82
+ \]
83
+ Therefore, the microwave oven uses energy at a rate of 240 watts.
84
+ Answer: A.
85
+
86
+ Question:
87
+ {query}
88
+
89
+ Answer: Let's think step by step.