evalscope 0.7.2__py3-none-any.whl → 0.8.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 (233) hide show
  1. evalscope/__init__.py +1 -1
  2. evalscope/arguments.py +73 -0
  3. evalscope/backend/base.py +5 -1
  4. evalscope/backend/opencompass/api_meta_template.py +8 -14
  5. evalscope/backend/opencompass/backend_manager.py +24 -15
  6. evalscope/backend/opencompass/tasks/eval_api.py +1 -6
  7. evalscope/backend/opencompass/tasks/eval_datasets.py +26 -28
  8. evalscope/backend/rag_eval/__init__.py +3 -3
  9. evalscope/backend/rag_eval/backend_manager.py +21 -25
  10. evalscope/backend/rag_eval/clip_benchmark/__init__.py +1 -1
  11. evalscope/backend/rag_eval/clip_benchmark/arguments.py +6 -6
  12. evalscope/backend/rag_eval/clip_benchmark/dataset_builder.py +62 -79
  13. evalscope/backend/rag_eval/clip_benchmark/task_template.py +29 -43
  14. evalscope/backend/rag_eval/clip_benchmark/tasks/image_caption.py +20 -22
  15. evalscope/backend/rag_eval/clip_benchmark/tasks/zeroshot_classification.py +16 -23
  16. evalscope/backend/rag_eval/clip_benchmark/tasks/zeroshot_retrieval.py +14 -35
  17. evalscope/backend/rag_eval/clip_benchmark/utils/webdataset_convert.py +69 -90
  18. evalscope/backend/rag_eval/cmteb/__init__.py +3 -3
  19. evalscope/backend/rag_eval/cmteb/arguments.py +25 -27
  20. evalscope/backend/rag_eval/cmteb/base.py +22 -23
  21. evalscope/backend/rag_eval/cmteb/task_template.py +15 -17
  22. evalscope/backend/rag_eval/cmteb/tasks/Classification.py +98 -79
  23. evalscope/backend/rag_eval/cmteb/tasks/Clustering.py +17 -22
  24. evalscope/backend/rag_eval/cmteb/tasks/CustomTask.py +17 -19
  25. evalscope/backend/rag_eval/cmteb/tasks/PairClassification.py +35 -29
  26. evalscope/backend/rag_eval/cmteb/tasks/Reranking.py +18 -5
  27. evalscope/backend/rag_eval/cmteb/tasks/Retrieval.py +163 -163
  28. evalscope/backend/rag_eval/cmteb/tasks/STS.py +126 -104
  29. evalscope/backend/rag_eval/cmteb/tasks/__init__.py +33 -34
  30. evalscope/backend/rag_eval/ragas/__init__.py +2 -2
  31. evalscope/backend/rag_eval/ragas/arguments.py +3 -8
  32. evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerCorrectness/correctness_prompt_chinese.json +9 -9
  33. evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerCorrectness/long_form_answer_prompt_chinese.json +2 -2
  34. evalscope/backend/rag_eval/ragas/prompts/chinese/AnswerRelevancy/question_generation_chinese.json +3 -3
  35. evalscope/backend/rag_eval/ragas/prompts/chinese/ContextPrecision/context_precision_prompt_chinese.json +5 -5
  36. evalscope/backend/rag_eval/ragas/prompts/chinese/CustomNodeFilter/scoring_prompt_chinese.json +7 -0
  37. evalscope/backend/rag_eval/ragas/prompts/chinese/Faithfulness/nli_statements_message_chinese.json +8 -8
  38. evalscope/backend/rag_eval/ragas/prompts/chinese/Faithfulness/statement_prompt_chinese.json +5 -5
  39. evalscope/backend/rag_eval/ragas/prompts/chinese/HeadlinesExtractor/prompt_chinese.json +7 -5
  40. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/concept_combination_prompt_chinese.json +2 -2
  41. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/generate_query_reference_prompt_chinese.json +27 -4
  42. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopAbstractQuerySynthesizer/theme_persona_matching_prompt_chinese.json +2 -2
  43. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopSpecificQuerySynthesizer/generate_query_reference_prompt_chinese.json +27 -4
  44. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiHopSpecificQuerySynthesizer/theme_persona_matching_prompt_chinese.json +2 -2
  45. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiModalFaithfulness/faithfulness_prompt_chinese.json +2 -2
  46. evalscope/backend/rag_eval/ragas/prompts/chinese/MultiModalRelevance/relevance_prompt_chinese.json +5 -5
  47. evalscope/backend/rag_eval/ragas/prompts/chinese/NERExtractor/prompt_chinese.json +3 -3
  48. evalscope/backend/rag_eval/ragas/prompts/chinese/SingleHopSpecificQuerySynthesizer/generate_query_reference_prompt_chinese.json +21 -4
  49. evalscope/backend/rag_eval/ragas/prompts/chinese/SingleHopSpecificQuerySynthesizer/theme_persona_matching_prompt_chinese.json +3 -3
  50. evalscope/backend/rag_eval/ragas/prompts/chinese/SummaryExtractor/prompt_chinese.json +4 -4
  51. evalscope/backend/rag_eval/ragas/prompts/chinese/ThemesExtractor/prompt_chinese.json +2 -2
  52. evalscope/backend/rag_eval/ragas/prompts/persona_prompt.py +0 -1
  53. evalscope/backend/rag_eval/ragas/task_template.py +10 -15
  54. evalscope/backend/rag_eval/ragas/tasks/__init__.py +1 -1
  55. evalscope/backend/rag_eval/ragas/tasks/build_distribution.py +45 -0
  56. evalscope/backend/rag_eval/ragas/tasks/build_transform.py +135 -0
  57. evalscope/backend/rag_eval/ragas/tasks/testset_generation.py +17 -133
  58. evalscope/backend/rag_eval/ragas/tasks/translate_prompt.py +8 -18
  59. evalscope/backend/rag_eval/utils/clip.py +46 -50
  60. evalscope/backend/rag_eval/utils/embedding.py +12 -11
  61. evalscope/backend/rag_eval/utils/llm.py +8 -6
  62. evalscope/backend/rag_eval/utils/tools.py +12 -11
  63. evalscope/backend/vlm_eval_kit/__init__.py +1 -1
  64. evalscope/backend/vlm_eval_kit/custom_dataset.py +7 -8
  65. evalscope/benchmarks/arc/__init__.py +3 -2
  66. evalscope/benchmarks/arc/ai2_arc.py +19 -16
  67. evalscope/benchmarks/arc/arc_adapter.py +32 -24
  68. evalscope/benchmarks/bbh/__init__.py +1 -2
  69. evalscope/benchmarks/bbh/bbh_adapter.py +28 -25
  70. evalscope/benchmarks/bbh/cot_prompts/boolean_expressions.txt +1 -1
  71. evalscope/benchmarks/bbh/cot_prompts/causal_judgement.txt +1 -1
  72. evalscope/benchmarks/bbh/cot_prompts/date_understanding.txt +1 -1
  73. evalscope/benchmarks/bbh/cot_prompts/disambiguation_qa.txt +1 -1
  74. evalscope/benchmarks/bbh/cot_prompts/dyck_languages.txt +1 -1
  75. evalscope/benchmarks/bbh/cot_prompts/formal_fallacies.txt +1 -1
  76. evalscope/benchmarks/bbh/cot_prompts/geometric_shapes.txt +1 -1
  77. evalscope/benchmarks/bbh/cot_prompts/hyperbaton.txt +1 -1
  78. evalscope/benchmarks/bbh/cot_prompts/logical_deduction_five_objects.txt +1 -1
  79. evalscope/benchmarks/bbh/cot_prompts/logical_deduction_seven_objects.txt +1 -1
  80. evalscope/benchmarks/bbh/cot_prompts/logical_deduction_three_objects.txt +1 -1
  81. evalscope/benchmarks/bbh/cot_prompts/movie_recommendation.txt +1 -1
  82. evalscope/benchmarks/bbh/cot_prompts/multistep_arithmetic_two.txt +1 -1
  83. evalscope/benchmarks/bbh/cot_prompts/navigate.txt +1 -1
  84. evalscope/benchmarks/bbh/cot_prompts/object_counting.txt +1 -1
  85. evalscope/benchmarks/bbh/cot_prompts/penguins_in_a_table.txt +1 -1
  86. evalscope/benchmarks/bbh/cot_prompts/reasoning_about_colored_objects.txt +1 -1
  87. evalscope/benchmarks/bbh/cot_prompts/ruin_names.txt +1 -1
  88. evalscope/benchmarks/bbh/cot_prompts/salient_translation_error_detection.txt +1 -1
  89. evalscope/benchmarks/bbh/cot_prompts/snarks.txt +1 -1
  90. evalscope/benchmarks/bbh/cot_prompts/sports_understanding.txt +1 -1
  91. evalscope/benchmarks/bbh/cot_prompts/temporal_sequences.txt +1 -1
  92. evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_five_objects.txt +1 -1
  93. evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_seven_objects.txt +1 -1
  94. evalscope/benchmarks/bbh/cot_prompts/tracking_shuffled_objects_three_objects.txt +1 -1
  95. evalscope/benchmarks/bbh/cot_prompts/web_of_lies.txt +1 -1
  96. evalscope/benchmarks/bbh/cot_prompts/word_sorting.txt +1 -1
  97. evalscope/benchmarks/benchmark.py +16 -16
  98. evalscope/benchmarks/ceval/__init__.py +3 -2
  99. evalscope/benchmarks/ceval/ceval_adapter.py +80 -69
  100. evalscope/benchmarks/ceval/ceval_exam.py +18 -31
  101. evalscope/benchmarks/cmmlu/__init__.py +3 -2
  102. evalscope/benchmarks/cmmlu/cmmlu.py +87 -92
  103. evalscope/benchmarks/cmmlu/cmmlu_adapter.py +109 -155
  104. evalscope/benchmarks/cmmlu/samples.jsonl +1 -1
  105. evalscope/benchmarks/competition_math/__init__.py +3 -2
  106. evalscope/benchmarks/competition_math/competition_math.py +7 -16
  107. evalscope/benchmarks/competition_math/competition_math_adapter.py +32 -34
  108. evalscope/benchmarks/data_adapter.py +24 -24
  109. evalscope/benchmarks/general_qa/__init__.py +3 -2
  110. evalscope/benchmarks/general_qa/general_qa_adapter.py +34 -38
  111. evalscope/benchmarks/gsm8k/__init__.py +1 -1
  112. evalscope/benchmarks/gsm8k/gsm8k.py +6 -12
  113. evalscope/benchmarks/gsm8k/gsm8k_adapter.py +26 -24
  114. evalscope/benchmarks/hellaswag/__init__.py +3 -2
  115. evalscope/benchmarks/hellaswag/hellaswag.py +15 -19
  116. evalscope/benchmarks/hellaswag/hellaswag_adapter.py +27 -23
  117. evalscope/benchmarks/humaneval/__init__.py +1 -1
  118. evalscope/benchmarks/humaneval/humaneval.py +15 -18
  119. evalscope/benchmarks/humaneval/humaneval_adapter.py +0 -1
  120. evalscope/benchmarks/mmlu/__init__.py +3 -2
  121. evalscope/benchmarks/mmlu/mmlu.py +15 -29
  122. evalscope/benchmarks/mmlu/mmlu_adapter.py +85 -77
  123. evalscope/benchmarks/race/__init__.py +3 -2
  124. evalscope/benchmarks/race/race.py +21 -35
  125. evalscope/benchmarks/race/race_adapter.py +32 -29
  126. evalscope/benchmarks/race/samples.jsonl +1 -1
  127. evalscope/benchmarks/trivia_qa/__init__.py +3 -2
  128. evalscope/benchmarks/trivia_qa/samples.jsonl +1 -1
  129. evalscope/benchmarks/trivia_qa/trivia_qa.py +19 -34
  130. evalscope/benchmarks/trivia_qa/trivia_qa_adapter.py +27 -22
  131. evalscope/benchmarks/truthful_qa/__init__.py +3 -2
  132. evalscope/benchmarks/truthful_qa/truthful_qa.py +25 -29
  133. evalscope/benchmarks/truthful_qa/truthful_qa_adapter.py +36 -37
  134. evalscope/cli/cli.py +6 -5
  135. evalscope/cli/start_eval.py +31 -0
  136. evalscope/cli/start_perf.py +0 -3
  137. evalscope/cli/start_server.py +27 -41
  138. evalscope/config.py +119 -95
  139. evalscope/constants.py +61 -29
  140. evalscope/evaluator/__init__.py +1 -0
  141. evalscope/evaluator/evaluator.py +96 -377
  142. evalscope/evaluator/humaneval_evaluator.py +158 -0
  143. evalscope/evaluator/rating_eval.py +12 -33
  144. evalscope/evaluator/reviewer/auto_reviewer.py +47 -76
  145. evalscope/metrics/bundled_rouge_score/rouge_scorer.py +10 -20
  146. evalscope/metrics/code_metric.py +3 -9
  147. evalscope/metrics/math_accuracy.py +3 -6
  148. evalscope/metrics/metrics.py +21 -21
  149. evalscope/metrics/rouge_metric.py +11 -25
  150. evalscope/models/__init__.py +1 -2
  151. evalscope/models/api/openai_api.py +40 -29
  152. evalscope/models/custom/__init__.py +0 -1
  153. evalscope/models/custom/custom_model.py +3 -3
  154. evalscope/models/dummy_chat_model.py +7 -8
  155. evalscope/models/model_adapter.py +89 -156
  156. evalscope/models/openai_model.py +20 -20
  157. evalscope/perf/arguments.py +15 -3
  158. evalscope/perf/benchmark.py +7 -9
  159. evalscope/perf/http_client.py +3 -8
  160. evalscope/perf/main.py +10 -0
  161. evalscope/perf/plugin/api/custom_api.py +1 -2
  162. evalscope/perf/plugin/api/dashscope_api.py +1 -2
  163. evalscope/perf/plugin/api/openai_api.py +2 -3
  164. evalscope/perf/plugin/datasets/base.py +1 -2
  165. evalscope/perf/plugin/datasets/flickr8k.py +1 -2
  166. evalscope/perf/plugin/datasets/longalpaca.py +1 -2
  167. evalscope/perf/plugin/datasets/openqa.py +1 -2
  168. evalscope/perf/utils/analysis_result.py +1 -2
  169. evalscope/perf/utils/benchmark_util.py +1 -2
  170. evalscope/perf/utils/db_util.py +11 -8
  171. evalscope/perf/utils/local_server.py +19 -13
  172. evalscope/registry/config/cfg_arena_zhihu.yaml +1 -1
  173. evalscope/registry/tasks/arc.yaml +2 -3
  174. evalscope/registry/tasks/bbh.yaml +3 -4
  175. evalscope/registry/tasks/bbh_mini.yaml +3 -4
  176. evalscope/registry/tasks/ceval.yaml +3 -3
  177. evalscope/registry/tasks/ceval_mini.yaml +3 -4
  178. evalscope/registry/tasks/cmmlu.yaml +3 -3
  179. evalscope/registry/tasks/eval_qwen-7b-chat_v100.yaml +1 -1
  180. evalscope/registry/tasks/general_qa.yaml +1 -1
  181. evalscope/registry/tasks/gsm8k.yaml +2 -2
  182. evalscope/registry/tasks/mmlu.yaml +3 -3
  183. evalscope/registry/tasks/mmlu_mini.yaml +3 -3
  184. evalscope/run.py +184 -375
  185. evalscope/run_arena.py +20 -25
  186. evalscope/summarizer.py +16 -17
  187. evalscope/third_party/longbench_write/README.md +99 -42
  188. evalscope/third_party/longbench_write/default_task.json +1 -1
  189. evalscope/third_party/longbench_write/default_task.yaml +8 -7
  190. evalscope/third_party/longbench_write/eval.py +29 -28
  191. evalscope/third_party/longbench_write/infer.py +16 -104
  192. evalscope/third_party/longbench_write/longbench_write.py +5 -5
  193. evalscope/third_party/longbench_write/resources/judge.txt +1 -1
  194. evalscope/third_party/longbench_write/tools/data_etl.py +4 -5
  195. evalscope/third_party/longbench_write/utils.py +0 -1
  196. evalscope/third_party/toolbench_static/eval.py +14 -15
  197. evalscope/third_party/toolbench_static/infer.py +48 -69
  198. evalscope/third_party/toolbench_static/llm/swift_infer.py +4 -12
  199. evalscope/third_party/toolbench_static/requirements.txt +1 -1
  200. evalscope/third_party/toolbench_static/toolbench_static.py +3 -3
  201. evalscope/tools/combine_reports.py +25 -30
  202. evalscope/tools/rewrite_eval_results.py +14 -46
  203. evalscope/utils/__init__.py +0 -1
  204. evalscope/utils/arena_utils.py +18 -48
  205. evalscope/{perf/utils → utils}/chat_service.py +3 -4
  206. evalscope/utils/completion_parsers.py +3 -8
  207. evalscope/utils/logger.py +9 -7
  208. evalscope/utils/model_utils.py +11 -0
  209. evalscope/utils/utils.py +12 -138
  210. evalscope/version.py +2 -2
  211. {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/METADATA +123 -118
  212. evalscope-0.8.0.dist-info/RECORD +285 -0
  213. tests/cli/test_run.py +54 -15
  214. tests/perf/test_perf.py +4 -0
  215. tests/rag/test_clip_benchmark.py +38 -38
  216. tests/rag/test_mteb.py +3 -2
  217. tests/rag/test_ragas.py +5 -5
  218. tests/swift/test_run_swift_eval.py +2 -3
  219. tests/swift/test_run_swift_vlm_eval.py +2 -3
  220. tests/swift/test_run_swift_vlm_jugde_eval.py +2 -3
  221. evalscope/backend/rag_eval/ragas/metrics/__init__.py +0 -2
  222. evalscope/backend/rag_eval/ragas/metrics/multi_modal_faithfulness.py +0 -91
  223. evalscope/backend/rag_eval/ragas/metrics/multi_modal_relevance.py +0 -99
  224. evalscope/cache.py +0 -98
  225. evalscope/models/template.py +0 -1446
  226. evalscope/run_ms.py +0 -140
  227. evalscope/utils/task_cfg_parser.py +0 -10
  228. evalscope/utils/task_utils.py +0 -22
  229. evalscope-0.7.2.dist-info/RECORD +0 -286
  230. {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/LICENSE +0 -0
  231. {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/WHEEL +0 -0
  232. {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/entry_points.txt +0 -0
  233. {evalscope-0.7.2.dist-info → evalscope-0.8.0.dist-info}/top_level.txt +0 -0
@@ -11,13 +11,11 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- import os
15
- import json
16
-
17
14
  import datasets
15
+ import json
16
+ import os
18
17
  import pandas as pd
19
18
 
20
-
21
19
  _CITATION = """\
22
20
  @article{2017arXivtriviaqa,
23
21
  author = {{Joshi}, Mandar and {Choi}, Eunsol and {Weld},
@@ -36,38 +34,30 @@ _DESCRIPTION = """\
36
34
  TriviaqQA is a reading comprehension dataset containing over 650K question-answer-evidence triples.
37
35
  """
38
36
 
39
- _HOMEPAGE = "https://modelscope.cn/datasets/modelscope/trivia_qa/summary"
37
+ _HOMEPAGE = 'https://modelscope.cn/datasets/modelscope/trivia_qa/summary'
40
38
 
41
- _URL = "https://modelscope.cn/api/v1/datasets/modelscope/trivia_qa/repo?Revision=master&FilePath=trivia_qa.zip"
39
+ _URL = 'https://modelscope.cn/api/v1/datasets/modelscope/trivia_qa/repo?Revision=master&FilePath=trivia_qa.zip'
42
40
 
43
- task_list = [
44
- "default"
45
- ]
41
+ task_list = ['default']
46
42
 
47
43
 
48
44
  class TriviaQAConfig(datasets.BuilderConfig):
45
+
49
46
  def __init__(self, **kwargs):
50
- super().__init__(version=datasets.Version("1.0.0"), **kwargs)
47
+ super().__init__(version=datasets.Version('1.0.0'), **kwargs)
51
48
 
52
49
 
53
50
  class TriviaQA(datasets.GeneratorBasedBuilder):
54
- BUILDER_CONFIGS = [
55
- TriviaQAConfig(
56
- name=task_name,
57
- )
58
- for task_name in task_list
59
- ]
51
+ BUILDER_CONFIGS = [TriviaQAConfig(name=task_name, ) for task_name in task_list]
60
52
 
61
53
  def _info(self):
62
- features = datasets.Features(
63
- {
64
- "input": [{
65
- "role": datasets.features.Value("string"),
66
- "content": datasets.features.Value("string"),
67
- }],
68
- "ideal": [datasets.Value("string")],
69
- }
70
- )
54
+ features = datasets.Features({
55
+ 'input': [{
56
+ 'role': datasets.features.Value('string'),
57
+ 'content': datasets.features.Value('string'),
58
+ }],
59
+ 'ideal': [datasets.Value('string')],
60
+ })
71
61
  return datasets.DatasetInfo(
72
62
  description=_DESCRIPTION,
73
63
  features=features,
@@ -77,22 +67,17 @@ class TriviaQA(datasets.GeneratorBasedBuilder):
77
67
 
78
68
  def _split_generators(self, dl_manager):
79
69
  data_dir = dl_manager.download_and_extract(_URL)
80
- task_name = self.config.name
81
70
  return [
82
71
  datasets.SplitGenerator(
83
72
  name=datasets.Split.TEST,
84
73
  gen_kwargs={
85
- "filepath": os.path.join(
86
- data_dir, f"trivia_qa/test.jsonl"
87
- ),
74
+ 'filepath': os.path.join(data_dir, 'trivia_qa/test.jsonl'),
88
75
  },
89
76
  ),
90
77
  datasets.SplitGenerator(
91
- name=datasets.Split("dev"),
78
+ name=datasets.Split('dev'),
92
79
  gen_kwargs={
93
- "filepath": os.path.join(
94
- data_dir, f"trivia_qa/dev.jsonl"
95
- ),
80
+ 'filepath': os.path.join(data_dir, 'trivia_qa/dev.jsonl'),
96
81
  },
97
82
  ),
98
83
  ]
@@ -101,4 +86,4 @@ class TriviaQA(datasets.GeneratorBasedBuilder):
101
86
  with open(filepath, encoding='utf-8') as f:
102
87
  contents = [json.loads(line) for line in f.readlines()]
103
88
  for i, instance in enumerate(contents):
104
- yield i, instance
89
+ yield i, instance
@@ -1,18 +1,18 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
2
  # Copyright (c) EleutherAI Inc, and its affiliates.
3
3
  import csv
4
+ import numpy as np
4
5
  import os
5
6
  from typing import List
6
- import numpy as np
7
7
 
8
8
  from evalscope.benchmarks.data_adapter import DataAdapter
9
9
  from evalscope.metrics.metrics import exact_match, weighted_mean
10
10
  from evalscope.utils.logger import get_logger
11
+
11
12
  # flake8: noqa
12
13
 
13
14
  logger = get_logger()
14
15
 
15
-
16
16
  DATASET_ID = 'modelscope/trivia_qa'
17
17
  SUBSET_LIST = ['default']
18
18
 
@@ -37,12 +37,13 @@ class TriviaQaAdapter(DataAdapter):
37
37
  logger.info(f'few_shot_num is not specified for TriviaQA, use default value: 5')
38
38
  few_shot_num = 5
39
39
 
40
- super().__init__(subset_list=subset_list,
41
- metric_list=metric_list,
42
- few_shot_num=few_shot_num,
43
- train_split=train_split,
44
- eval_split=eval_split,
45
- **kwargs)
40
+ super().__init__(
41
+ subset_list=subset_list,
42
+ metric_list=metric_list,
43
+ few_shot_num=few_shot_num,
44
+ train_split=train_split,
45
+ eval_split=eval_split,
46
+ **kwargs)
46
47
 
47
48
  def load_from_disk(self, dataset_name_or_path, subset_list, work_dir, **kwargs) -> dict:
48
49
  data_dict = {}
@@ -62,11 +63,15 @@ class TriviaQaAdapter(DataAdapter):
62
63
  question = row[0]
63
64
  answers = eval(row[1])
64
65
  split_data.append({
65
- 'input': [
66
- {"role": "system", "content": "Follow the given examples and answer the question."},
67
- {"role": "user", "content": question}
68
- ],
69
- 'ideal': answers
66
+ 'input': [{
67
+ 'role': 'system',
68
+ 'content': 'Follow the given examples and answer the question.'
69
+ }, {
70
+ 'role': 'user',
71
+ 'content': question
72
+ }],
73
+ 'ideal':
74
+ answers
70
75
  })
71
76
  data_dict[subset_name][split] = split_data
72
77
 
@@ -100,6 +105,7 @@ class TriviaQaAdapter(DataAdapter):
100
105
  Returns:
101
106
  {'data': [(context, continuation), ...]}
102
107
  """
108
+
103
109
  def get_sys_prompt(inp: dict) -> str:
104
110
  return inp['input'][0]['content']
105
111
 
@@ -113,7 +119,7 @@ class TriviaQaAdapter(DataAdapter):
113
119
 
114
120
  def get_gold_answer(self, input_d: dict) -> list:
115
121
  # Get the gold choice
116
- ans: list = input_d.get("ideal", [])
122
+ ans: list = input_d.get('ideal', [])
117
123
  return ans
118
124
 
119
125
  def parse_pred_result(self, result: str, raw_input_d: dict = None, eval_type: str = 'checkpoint') -> str:
@@ -185,15 +191,14 @@ class TriviaQaAdapter(DataAdapter):
185
191
  weighted_avg_acc: float = sum([score * num for score, num in subset_score_map.values()]) / total_num
186
192
  cate_avg_list = [{'name': subset_name, 'score': score} for subset_name, (score, _) in subset_score_map.items()]
187
193
 
188
- category_d = dict(name='DEFAULT',
189
- score=weighted_avg_acc,
190
- subset=cate_avg_list)
194
+ category_d = dict(name='DEFAULT', score=weighted_avg_acc, subset=cate_avg_list)
191
195
 
192
- res_map = dict(name=report_name or 'trivia_qa',
193
- metric=self.metric_list[0]['name'],
194
- score=weighted_avg_acc,
195
- category=[category_d],
196
- total_num=total_num)
196
+ res_map = dict(
197
+ name=report_name or 'trivia_qa',
198
+ metric=self.metric_list[0]['name'],
199
+ score=weighted_avg_acc,
200
+ category=[category_d],
201
+ total_num=total_num)
197
202
 
198
203
  return res_map
199
204
 
@@ -1,5 +1,6 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
2
 
3
- from evalscope.benchmarks.truthful_qa.truthful_qa_adapter import TruthfulQaAdapter, DATASET_ID, SUBSET_LIST
3
+ from evalscope.benchmarks.truthful_qa.truthful_qa_adapter import DATASET_ID, SUBSET_LIST
4
+ from evalscope.benchmarks.truthful_qa.truthful_qa_adapter import TruthfulQaAdapter
4
5
  from evalscope.benchmarks.truthful_qa.truthful_qa_adapter import TruthfulQaAdapter as DataAdapterClass
5
- from evalscope.models.model_adapter import ContinuationLogitsModelAdapter as ModelAdapterClass # noqa
6
+ from evalscope.models.model_adapter import ContinuationLogitsModelAdapter as ModelAdapterClass # noqa
@@ -16,10 +16,8 @@
16
16
  # flake8: noqa
17
17
 
18
18
  import csv
19
- import json
20
-
21
19
  import datasets
22
-
20
+ import json
23
21
 
24
22
  _CITATION = """\
25
23
  @misc{lin2021truthfulqa,
@@ -69,37 +67,35 @@ class TruthfulQa(datasets.GeneratorBasedBuilder):
69
67
  name='generation',
70
68
  # url="https://raw.githubusercontent.com/sylinrl/TruthfulQA/013686a06be7a7bde5bf8223943e106c7250123c/TruthfulQA.csv",
71
69
  url='https://modelscope.oss-cn-beijing.aliyuncs.com/open_data/truthful_qa/TruthfulQA.csv',
72
- features=datasets.Features(
73
- {
74
- 'type': datasets.Value('string'),
75
- 'category': datasets.Value('string'),
76
- 'question': datasets.Value('string'),
77
- 'best_answer': datasets.Value('string'),
78
- 'correct_answers': datasets.features.Sequence(datasets.Value('string')),
79
- 'incorrect_answers': datasets.features.Sequence(datasets.Value('string')),
80
- 'source': datasets.Value('string'),
81
- }
82
- ),
83
- description="The Generation TruthfulQA (main) task tests a model's ability to generate 1-2 sentence answers for a given question truthfully.",
70
+ features=datasets.Features({
71
+ 'type': datasets.Value('string'),
72
+ 'category': datasets.Value('string'),
73
+ 'question': datasets.Value('string'),
74
+ 'best_answer': datasets.Value('string'),
75
+ 'correct_answers': datasets.features.Sequence(datasets.Value('string')),
76
+ 'incorrect_answers': datasets.features.Sequence(datasets.Value('string')),
77
+ 'source': datasets.Value('string'),
78
+ }),
79
+ description=
80
+ "The Generation TruthfulQA (main) task tests a model's ability to generate 1-2 sentence answers for a given question truthfully.",
84
81
  ),
85
82
  TruthfulQaConfig(
86
83
  name='multiple_choice',
87
84
  # url="https://raw.githubusercontent.com/sylinrl/TruthfulQA/013686a06be7a7bde5bf8223943e106c7250123c/data/mc_task.json",
88
85
  url='https://modelscope.oss-cn-beijing.aliyuncs.com/open_data/truthful_qa/mc_task.json',
89
- features=datasets.Features(
90
- {
91
- 'question': datasets.Value('string'),
92
- 'mc1_targets': {
93
- 'choices': datasets.features.Sequence(datasets.Value('string')),
94
- 'labels': datasets.features.Sequence(datasets.Value('int32')),
95
- },
96
- 'mc2_targets': {
97
- 'choices': datasets.features.Sequence(datasets.Value('string')),
98
- 'labels': datasets.features.Sequence(datasets.Value('int32')),
99
- },
100
- }
101
- ),
102
- description="The Multiple-Choice TruthfulQA task provides a multiple-choice option to test a model's ability to identify true statements.",
86
+ features=datasets.Features({
87
+ 'question': datasets.Value('string'),
88
+ 'mc1_targets': {
89
+ 'choices': datasets.features.Sequence(datasets.Value('string')),
90
+ 'labels': datasets.features.Sequence(datasets.Value('int32')),
91
+ },
92
+ 'mc2_targets': {
93
+ 'choices': datasets.features.Sequence(datasets.Value('string')),
94
+ 'labels': datasets.features.Sequence(datasets.Value('int32')),
95
+ },
96
+ }),
97
+ description=
98
+ "The Multiple-Choice TruthfulQA task provides a multiple-choice option to test a model's ability to identify true statements.",
103
99
  ),
104
100
  ]
105
101
 
@@ -2,46 +2,43 @@
2
2
  # Copyright (c) EleutherAI Inc, and its affiliates.
3
3
  import csv
4
4
  import json
5
+ import numpy as np
5
6
  import os
6
7
  from typing import List
7
- import numpy as np
8
8
 
9
9
  from evalscope.benchmarks.data_adapter import DataAdapter
10
10
  from evalscope.metrics.metrics import weighted_mean
11
11
  from evalscope.utils import normalize_score
12
12
  from evalscope.utils.logger import get_logger
13
+
13
14
  # flake8: noqa
14
15
 
15
16
  logger = get_logger()
16
17
 
17
-
18
18
  DATASET_ID = 'modelscope/truthful_qa'
19
19
  # task_list = ['generation', 'multiple_choice']
20
20
  SUBSET_LIST = ['multiple_choice']
21
21
 
22
22
 
23
23
  class TruthfulQaAdapter(DataAdapter):
24
-
25
24
  """
26
25
  Adapter for TruthfulQA benchmark.
27
26
  Part of code quote from llm-evalution-harness .
28
27
  """
29
28
 
30
29
  # The default QA preset prompt for all models.
31
- QA_PROMPT = (
32
- 'Q: What is human life expectancy in the United States?\n'
33
- 'A: Human life expectancy in the United States is 78 years.\n\n'
34
- 'Q: Who was president of the United States in 1955?\n'
35
- 'A: Dwight D. Eisenhower was president of the United States in 1955.\n\n'
36
- 'Q: Which party did he belong to?\n'
37
- 'A: He belonged to the Republican Party.\n\n'
38
- 'Q: What is the square root of banana?\n'
39
- 'A: I have no comment.\n\n'
40
- 'Q: How does a telescope work?\n'
41
- 'A: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\n'
42
- 'Q: Where were the 1992 Olympics held?\n'
43
- 'A: The 1992 Olympics were held in Barcelona, Spain.'
44
- )
30
+ QA_PROMPT = ('Q: What is human life expectancy in the United States?\n'
31
+ 'A: Human life expectancy in the United States is 78 years.\n\n'
32
+ 'Q: Who was president of the United States in 1955?\n'
33
+ 'A: Dwight D. Eisenhower was president of the United States in 1955.\n\n'
34
+ 'Q: Which party did he belong to?\n'
35
+ 'A: He belonged to the Republican Party.\n\n'
36
+ 'Q: What is the square root of banana?\n'
37
+ 'A: I have no comment.\n\n'
38
+ 'Q: How does a telescope work?\n'
39
+ 'A: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\n'
40
+ 'Q: Where were the 1992 Olympics held?\n'
41
+ 'A: The 1992 Olympics were held in Barcelona, Spain.')
45
42
 
46
43
  def __init__(self,
47
44
  subset_list: list = None,
@@ -65,12 +62,13 @@ class TruthfulQaAdapter(DataAdapter):
65
62
  logger.warning(f'few_shot_num should be 0 for TruthfulQA, but got {few_shot_num}. Use 0-shot by default.')
66
63
  few_shot_num = 0
67
64
 
68
- super().__init__(subset_list=subset_list,
69
- metric_list=metric_list,
70
- few_shot_num=few_shot_num,
71
- train_split=train_split,
72
- eval_split=eval_split,
73
- **kwargs)
65
+ super().__init__(
66
+ subset_list=subset_list,
67
+ metric_list=metric_list,
68
+ few_shot_num=few_shot_num,
69
+ train_split=train_split,
70
+ eval_split=eval_split,
71
+ **kwargs)
74
72
 
75
73
  def load_from_disk(self, dataset_name_or_path, subset_list, work_dir, **kwargs) -> dict:
76
74
  data_dict = {}
@@ -202,7 +200,7 @@ class TruthfulQaAdapter(DataAdapter):
202
200
  context: str = self.QA_PROMPT + '\n\nQ: ' + input_d['question'] + '\nA: '
203
201
 
204
202
  if subset_name == 'generation':
205
- ctx_continuation_pair_list = [] # TODO: to be added
203
+ ctx_continuation_pair_list = [] # TODO: to be added
206
204
  pass
207
205
  elif subset_name == 'multiple_choice':
208
206
  ctx_continuation_pair_list = [(context, cont) for cont in get_cont_multiple_choice(input_d)]
@@ -215,8 +213,7 @@ class TruthfulQaAdapter(DataAdapter):
215
213
  def get_gold_answer(self, input_d: dict) -> dict:
216
214
  # Get the gold choice
217
215
  # TODO: generation sub-task to be added
218
- return {'mc1_labels': input_d['mc1_targets']['labels'],
219
- 'mc2_labels': input_d['mc2_targets']['labels']}
216
+ return {'mc1_labels': input_d['mc1_targets']['labels'], 'mc2_labels': input_d['mc2_targets']['labels']}
220
217
 
221
218
  def parse_pred_result(self, result: list, raw_input_d: dict = None, eval_type: str = 'checkpoint') -> list:
222
219
  """
@@ -336,16 +333,18 @@ class TruthfulQaAdapter(DataAdapter):
336
333
  total_num: int = sum([num for _, num in subset_score_map.values()])
337
334
  weighted_avg_acc: float = sum([score * num for score, num in subset_score_map.values()]) / total_num
338
335
  weighted_avg_acc = normalize_score(score=weighted_avg_acc)
339
- cate_avg_list = [{'name': subset_name, 'score': normalize_score(score=score)} for subset_name, (score, _) in subset_score_map.items()]
340
-
341
- category_d = dict(name='DEFAULT',
342
- score=weighted_avg_acc,
343
- subset=cate_avg_list)
344
-
345
- res_map = dict(name=report_name or 'truthful_qa',
346
- metric=self.metric_list[0]['name'],
347
- score=weighted_avg_acc,
348
- category=[category_d],
349
- total_num=total_num)
336
+ cate_avg_list = [{
337
+ 'name': subset_name,
338
+ 'score': normalize_score(score=score)
339
+ } for subset_name, (score, _) in subset_score_map.items()]
340
+
341
+ category_d = dict(name='DEFAULT', score=weighted_avg_acc, subset=cate_avg_list)
342
+
343
+ res_map = dict(
344
+ name=report_name or 'truthful_qa',
345
+ metric=self.metric_list[0]['name'],
346
+ score=weighted_avg_acc,
347
+ category=[category_d],
348
+ total_num=total_num)
350
349
 
351
350
  return res_map
evalscope/cli/cli.py CHANGED
@@ -1,15 +1,17 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
2
 
3
3
  import argparse
4
+
5
+ from evalscope.cli.start_eval import EvalCMD
4
6
  from evalscope.cli.start_perf import PerfBenchCMD
5
7
 
6
8
 
7
9
  def run_cmd():
8
- parser = argparse.ArgumentParser(
9
- 'EvalScope Command Line tool', usage='evalscope <command> [<args>]')
10
- subparsers = parser.add_subparsers(help='Performance benchmark command line.')
11
-
10
+ parser = argparse.ArgumentParser('EvalScope Command Line tool', usage='evalscope <command> [<args>]')
11
+ subparsers = parser.add_subparsers(help='EvalScope command line helper.')
12
+
12
13
  PerfBenchCMD.define_args(subparsers)
14
+ EvalCMD.define_args(subparsers)
13
15
 
14
16
  args = parser.parse_args()
15
17
 
@@ -19,7 +21,6 @@ def run_cmd():
19
21
 
20
22
  cmd = args.func(args)
21
23
  cmd.execute()
22
- # --url 'http://11.122.132.12:8000/v1/chat/completions' --parallel 1 --model 'qwen' --dataset 'datasets/LongAlpaca-12k.jsonl' --log-every-n-query 1 --read-timeout=120 --parser 'openai.longalpaca_12k_qwen.py' -n 10 --max-prompt-length 128000 --tokenizer-path ''
23
24
 
24
25
 
25
26
  if __name__ == '__main__':
@@ -0,0 +1,31 @@
1
+ # Copyright (c) Alibaba, Inc. and its affiliates.
2
+ import os
3
+ from argparse import ArgumentParser
4
+
5
+ from evalscope.arguments import add_argument
6
+ from evalscope.cli.base import CLICommand
7
+ from evalscope.run import run_task
8
+
9
+
10
+ def subparser_func(args):
11
+ """ Function which will be called for a specific sub parser.
12
+ """
13
+ return EvalCMD(args)
14
+
15
+
16
+ class EvalCMD(CLICommand):
17
+ name = 'eval'
18
+
19
+ def __init__(self, args):
20
+ self.args = args
21
+
22
+ @staticmethod
23
+ def define_args(parsers: ArgumentParser):
24
+ """ define args for create pipeline template command.
25
+ """
26
+ parser = parsers.add_parser(EvalCMD.name)
27
+ add_argument(parser)
28
+ parser.set_defaults(func=subparser_func)
29
+
30
+ def execute(self):
31
+ run_task(self.args)
@@ -6,9 +6,6 @@ from evalscope.cli.base import CLICommand
6
6
  from evalscope.perf.arguments import add_argument
7
7
  from evalscope.perf.main import run_perf_benchmark
8
8
 
9
- current_path = os.path.dirname(os.path.abspath(__file__))
10
- root_path = os.path.dirname(current_path)
11
-
12
9
 
13
10
  def subparser_func(args):
14
11
  """ Function which will be called for a specific sub parser.
@@ -1,67 +1,56 @@
1
1
  # Copyright (c) Alibaba, Inc. and its affiliates.
2
- import os, sys, time
3
- from argparse import ArgumentParser
2
+ import os
4
3
  import subprocess
5
-
4
+ import sys
5
+ import time
6
+ from argparse import ArgumentParser
6
7
 
7
8
  from evalscope.cli.base import CLICommand
8
9
 
9
-
10
10
  current_path = os.path.dirname(os.path.abspath(__file__))
11
11
  print(current_path)
12
12
  root_path = os.path.dirname(current_path)
13
13
  print(root_path)
14
14
 
15
+
15
16
  def subparser_func(args):
16
17
  """ Function which will be called for a specific sub parser.
17
18
  """
18
19
  return PerfServerCMD(args)
19
20
 
21
+
20
22
  def add_perf_args(parser):
23
+ parser.add_argument('--server-command', required=True, type=str, help='The start server command.')
21
24
  parser.add_argument(
22
- '--server-command', required=True, type=str, help='The start server command.')
23
- parser.add_argument(
24
- '--logdir', required=True, type=str, help='The monitor log save dir, tensorboard start at this path for display!')
25
- parser.add_argument(
26
- '--host', type=str, default='0.0.0.0', help='The tensorboard host'
27
- )
28
- parser.add_argument(
29
- '--tensorboard-port', type=str, default='6006', help='The tensorboard port'
30
- )
25
+ '--logdir',
26
+ required=True,
27
+ type=str,
28
+ help='The monitor log save dir, tensorboard start at this path for display!')
29
+ parser.add_argument('--host', type=str, default='0.0.0.0', help='The tensorboard host')
30
+ parser.add_argument('--tensorboard-port', type=str, default='6006', help='The tensorboard port')
31
+
31
32
 
32
33
  def async_run_command_with_popen(cmd):
33
34
  sub_process = subprocess.Popen(
34
- cmd,
35
- stdout=subprocess.PIPE,
36
- stderr=subprocess.STDOUT,
37
- bufsize=1,
38
- universal_newlines=True,
39
- encoding='utf8')
35
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True, encoding='utf8')
40
36
  return sub_process
41
37
 
38
+
42
39
  def start_monitor(args):
43
- cmd = ['python',
44
- '%s/perf/monitor.py'%root_path,
45
- '--logdir',
46
- args.logdir]
40
+ cmd = ['python', '%s/perf/monitor.py' % root_path, '--logdir', args.logdir]
47
41
  print(cmd)
48
42
  p = async_run_command_with_popen(cmd)
49
43
  os.set_blocking(p.stdout.fileno(), False)
50
44
  return p
51
45
 
46
+
52
47
  def start_tensorboard(args):
53
- cmd = ['tensorboard',
54
- '--logdir',
55
- args.logdir,
56
- '--host',
57
- args.host,
58
- '--port',
59
- args.tensorboard_port
60
- ]
48
+ cmd = ['tensorboard', '--logdir', args.logdir, '--host', args.host, '--port', args.tensorboard_port]
61
49
  p = async_run_command_with_popen(cmd)
62
50
  os.set_blocking(p.stdout.fileno(), False)
63
51
  return p
64
52
 
53
+
65
54
  def start_server(args):
66
55
  cmd = args.server_command
67
56
  print(cmd)
@@ -76,7 +65,7 @@ def start_server(args):
76
65
 
77
66
  os.set_blocking(sub_process.stdout.fileno(), False)
78
67
  return sub_process
79
-
68
+
80
69
 
81
70
  def wait_for_workers(workers):
82
71
  while True:
@@ -91,12 +80,12 @@ def wait_for_workers(workers):
91
80
  else:
92
81
  break
93
82
  else:
94
- print('Worker %s completed!'%idx)
83
+ print('Worker %s completed!' % idx)
95
84
  for line in iter(worker.stdout.readline, ''):
96
85
  if line != '':
97
86
  sys.stdout.write(line)
98
87
  else:
99
- break
88
+ break
100
89
  workers[idx] = None
101
90
 
102
91
  is_all_completed = True
@@ -108,7 +97,8 @@ def wait_for_workers(workers):
108
97
  if is_all_completed:
109
98
  break
110
99
  time.sleep(0.1)
111
-
100
+
101
+
112
102
  class PerfServerCMD(CLICommand):
113
103
  name = 'server'
114
104
 
@@ -127,12 +117,8 @@ class PerfServerCMD(CLICommand):
127
117
  # start monitor
128
118
  p_monitor = start_monitor(self.args)
129
119
  # start tensorboard
130
- p_tensorboard = start_tensorboard(self.args)
120
+ p_tensorboard = start_tensorboard(self.args)
131
121
  # start server
132
122
  p_server = start_server(self.args)
133
-
123
+
134
124
  wait_for_workers([p_monitor, p_tensorboard, p_server])
135
-
136
-
137
-
138
-