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