nmd2k commited on
Commit
04ca61b
·
verified ·
1 Parent(s): a8f9adc

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. codemmlu.py +111 -0
  2. data.tar +3 -0
codemmlu.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ """The CodeMMLU benchmark."""
17
+
18
+ import os
19
+ import json
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """\
25
+ @article{nguyen2024codemmlu,
26
+ title={CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities},
27
+ 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.},
28
+ journal={arXiv preprint},
29
+ year={2024}
30
+ }
31
+ """
32
+
33
+ _DESCRIPTION = """\
34
+ CodeMMLU is a comprehensive benchmark designed to evaluate the capabilities of large language models (LLMs) in coding and software knowledge
35
+ """
36
+
37
+ _HOMEPAGE = "https://fsoft-ai4code.github.io/codemmlu/"
38
+
39
+ _URL = "data.tar"
40
+
41
+ _SUBJECTS = [
42
+ "software_principles", "dbms_sql", "others",
43
+ "programming_syntax", "api_frameworks",
44
+ "code_completion", "fill_in_the_middle", "code_repair", "defect_detection"
45
+ ]
46
+
47
+ class CodeMMLUConfig(datasets.BuilderConfig):
48
+ """BuilderConfig for CodeMMLU."""
49
+
50
+ def __init__(self, **kwargs):
51
+ """BuilderConfig for CodeMMLU.
52
+ Args:
53
+ **kwargs: keyword arguments forwarded to super.
54
+ """
55
+ # Version history:
56
+ # 0.0.1: Initial release.
57
+ super(CodeMMLUConfig, self).__init__(version=datasets.Version("0.0.1"), **kwargs)
58
+
59
+
60
+ class CodeMMLU(datasets.GeneratorBasedBuilder):
61
+ """CodeMMLU: A Multi-Task Benchmark for Assessing Code Understanding Capabilities"""
62
+ BUILDER_CONFIGS = [
63
+ CodeMMLUConfig(
64
+ name=sub, description="CodeMMLU test subject {}".format(sub),
65
+ ) for sub in _SUBJECTS
66
+ ]
67
+
68
+ def _info(self):
69
+ features = datasets.Features(
70
+ {
71
+ "task_id": datasets.Value("string"),
72
+ "question": datasets.Value("string"),
73
+ "choices": datasets.features.Sequence(datasets.Value("string")),
74
+ }
75
+ )
76
+ return datasets.DatasetInfo(
77
+ description=_DESCRIPTION,
78
+ features=features,
79
+ homepage=_HOMEPAGE,
80
+ citation=_CITATION,
81
+ )
82
+
83
+ def _split_generators(self, dl_manager):
84
+ """Returns SplitGenerators."""
85
+ archive = dl_manager.download(_URL)
86
+ return [
87
+ datasets.SplitGenerator(
88
+ name=datasets.Split.TEST,
89
+ gen_kwargs={
90
+ "iter_archive": dl_manager.iter_archive(archive),
91
+ },
92
+ ),
93
+ ]
94
+
95
+ def _generate_examples(self, iter_archive):
96
+ """This function returns the examples in the raw (text) form."""
97
+ for path, file in iter_archive:
98
+ lines = (line.decode("utf-8") for line in file)
99
+ reader = [json.loads(line) for line in lines]
100
+ for data in reader:
101
+ id_ = data['task_id']
102
+
103
+ return_dict = {
104
+ "question": data['question'],
105
+ "choices": data['choices'],
106
+ }
107
+
108
+ if "fill_in_the_middle" in path:
109
+ return_dict['problem_description'] = data['problem_description']
110
+
111
+ yield id_, return_dict
data.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0c5b92d61fa3aae6abcf4c80867ce50968ce0f5786bc177e903d816af89f8bb
3
+ size 2570062