nmd2k commited on
Commit
836b672
·
1 Parent(s): e357d6e
Files changed (2) hide show
  1. CodeMMLU.py +2 -2
  2. testcm.py +108 -0
CodeMMLU.py CHANGED
@@ -48,11 +48,11 @@ class CodeMMLU(datasets.GeneratorBasedBuilder):
48
  """CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities"""
49
  # Version history:
50
  # 0.0.1: Initial release.
51
- VERSION = datasets.Version("0.0.1")
52
 
53
  BUILDER_CONFIGS = [
54
  datasets.BuilderConfig(
55
- name=sub, version=datasets.Version("0.0.1"),
56
  description="CodeMMLU test subject {}".format(sub)
57
  ) for sub in _SUBJECTS
58
  ]
 
48
  """CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities"""
49
  # Version history:
50
  # 0.0.1: Initial release.
51
+ VERSION = datasets.Version("0.0.2")
52
 
53
  BUILDER_CONFIGS = [
54
  datasets.BuilderConfig(
55
+ name=sub, version=datasets.Version("0.0.2"),
56
  description="CodeMMLU test subject {}".format(sub)
57
  ) for sub in _SUBJECTS
58
  ]
testcm.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The CodeMMLU benchmark."""
15
+
16
+ import os
17
+ import json
18
+ from glob import glob
19
+
20
+ import datasets
21
+
22
+
23
+ _CITATION = """\
24
+ @article{nguyen2024codemmlu,
25
+ title={CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities},
26
+ author={Nguyen, Dung Manh and Phan, Thang Chau and Le, Nam Hai and Doan, Thong T. and Nguyen, Nam V. and Pham, Quang and Bui, Nghi D. Q.},
27
+ journal={arXiv preprint},
28
+ year={2024}
29
+ }
30
+ """
31
+
32
+ _DESCRIPTION = """\
33
+ CodeMMLU is a comprehensive benchmark designed to evaluate the capabilities of large language models (LLMs) in coding and software knowledge
34
+ """
35
+
36
+ _HOMEPAGE = "https://fsoft-ai4code.github.io/codemmlu/"
37
+
38
+ _URL = "./data/test"
39
+
40
+ _SUBJECTS = [
41
+ "programming_syntax", "api_frameworks",
42
+ "software_principles", "dbms_sql", "others",
43
+ "code_completion", "fill_in_the_middle", "code_repair", "execution_prediction"
44
+ ]
45
+
46
+
47
+ class CodeMMLU(datasets.GeneratorBasedBuilder):
48
+ """CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities"""
49
+ # Version history:
50
+ # 0.0.1: Initial release.
51
+ VERSION = datasets.Version("0.0.2")
52
+
53
+ BUILDER_CONFIGS = [
54
+ datasets.BuilderConfig(
55
+ name=sub, version=datasets.Version("0.0.2"),
56
+ description="CodeMMLU test subject {}".format(sub)
57
+ ) for sub in _SUBJECTS
58
+ ]
59
+
60
+
61
+ def _info(self):
62
+ features = datasets.Features(
63
+ {
64
+ "task_id": datasets.Value("string"),
65
+ "question": datasets.Value("string"),
66
+ "choices": datasets.features.Sequence(datasets.Value("string")),
67
+ "answer": datasets.Value("string"),
68
+ }
69
+ )
70
+
71
+ if self.config.name == "fill_in_the_middle":
72
+ features["problem_description"] = datasets.Value("string")
73
+
74
+ return datasets.DatasetInfo(
75
+ description=_DESCRIPTION,
76
+ features=features,
77
+ homepage=_HOMEPAGE,
78
+ citation=_CITATION,
79
+ )
80
+
81
+ def _split_generators(self, dl_manager):
82
+ """Returns SplitGenerators."""
83
+ path = os.path.join(_URL, self.config.name + ".jsonl")
84
+ dl_dir = dl_manager.download(path)
85
+ return [
86
+ datasets.SplitGenerator(
87
+ name=datasets.Split.TEST,
88
+ gen_kwargs={"data_path": dl_dir},
89
+ ),
90
+ ]
91
+
92
+ def _generate_examples(self, data_path):
93
+ """This function returns the examples in the raw (text) form."""
94
+ if data_path.endswith(".jsonl"):
95
+ lines = open(data_path, "r", encoding="utf-8").readlines()
96
+ reader = [json.loads(line) for line in lines]
97
+ for idx, data in enumerate(reader):
98
+ return_dict = {
99
+ "task_id": data['task_id'],
100
+ "question": data['question'],
101
+ "choices": data['choices'],
102
+ "answer": data['answer'],
103
+ }
104
+
105
+ if "fill_in_the_middle" in data_path:
106
+ return_dict['problem_description'] = data['problem_description']
107
+
108
+ yield idx, return_dict