File size: 5,578 Bytes
ff6f3f6 7c60dd3 ff6f3f6 48bb741 ff6f3f6 291edb3 ff6f3f6 e0f8311 ff6f3f6 e6a67af ff6f3f6 |
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
import csv
import datasets
_CITATION = """\
@inproceedings{koto-etal-2023-indommlu,
title = "Large Language Models Only Pass Primary School Exams in {I}ndonesia: A Comprehensive Test on {I}ndo{MMLU}",
author = "Fajri Koto and Nurul Aisyah and Haonan Li and Timothy Baldwin",
booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
month = December,
year = "2023",
address = "Singapore",
publisher = "Association for Computational Linguistics",
}"""
subject2english = {
'Sejarah': 'History',
'Geografi': 'Geography',
'Bahasa Lampung': 'Lampungic',
'IPS': 'Social science',
'Bahasa Bali': 'Balinese',
'Bahasa Makassar': 'Makassarese',
'Bahasa Banjar': 'Banjarese',
'Kimia': 'Chemistry',
'Biologi': 'Biology',
'IPA': 'Science',
'Agama Kristen': 'Christian religion',
'Kesenian': 'Art',
'Agama Islam': 'Islam religion',
'Agama Hindu': 'Hindu religion',
'Bahasa Madura': 'Madurese',
'Penjaskes': 'Sport',
'Bahasa Indonesia': 'Indonesian language',
'Fisika': 'Physics',
'Budaya Alam Minangkabau': 'Minangkabau culture',
'Bahasa Dayak Ngaju': 'Dayak language',
'Sosiologi': 'Sociology',
'Ekonomi': 'Economy',
'Bahasa Sunda': 'Sundanese',
'Bahasa Jawa': 'Javanese',
'PPKN': 'Civic education',
}
subject2group = {
'Sejarah': 'Humanities',
'Geografi': 'Social science',
'Bahasa Lampung': 'Local languages and cultures',
'IPS': 'Social science',
'Bahasa Bali': 'Local languages and cultures',
'Bahasa Makassar': 'Local languages and cultures',
'Bahasa Banjar': 'Local languages and cultures',
'Kimia': 'STEM',
'Biologi': 'STEM',
'IPA': 'STEM',
'Agama Kristen': 'Humanities',
'Kesenian': 'Humanities',
'Agama Islam': 'Humanities',
'Agama Hindu': 'Humanities',
'Bahasa Madura': 'Local languages and cultures',
'Penjaskes': 'Humanities',
'Bahasa Indonesia': 'Indonesian language',
'Fisika': 'STEM',
'Budaya Alam Minangkabau': 'Local languages and cultures',
'Bahasa Dayak Ngaju': 'Local languages and cultures',
'Sosiologi': 'Social science',
'Ekonomi': 'Social science',
'Bahasa Sunda': 'Local languages and cultures',
'Bahasa Jawa': 'Local languages and cultures',
'PPKN': 'Social science',
}
special_case = ['SD-SMP-SMA', 'SD-SMP']
level_mapper = {
'SMA': 'SMA',
'Seleksi PTN': 'University entrance test',
'SD': 'SD',
'SMP': 'SMP',
'Kelas I SD': 'SD',
'Kelas X SMA': 'SMA',
'Kelas XI SMA': 'SMA',
'Kelas XII SMA': 'SMA',
'V SD': 'SD',
'VI SD': 'SD',
'VII SMP': 'SMP',
'VIII SMP ': 'SMP',
'IX SMP': 'SMP',
'Kelas III SD':'SD',
'Kelas IV SD': 'SD',
'Kelas II SD': 'SD'
}
def fix_level(level, kelas):
#Fixing Level
if level in special_case:
kelas = float(kelas)
if kelas >=1 and kelas <= 6:
level = 'SD'
elif kelas >=7 and kelas <= 9:
level = 'SMP'
elif kelas >=10:
level = 'SMA'
else:
print(level)
fixed_level = level_mapper[level]
#Fixing class
fixed_kelas = -1
kelas = str(kelas)
if kelas.strip() in ['PTN', '2023-10-12 00:00:00']:
fixed_kelas = 13
elif kelas == '4,5,6':
fixed_kelas = 6
else:
fixed_kelas = int(float(kelas.strip()))
# sanity check over the level and kelas
return fixed_level, fixed_kelas
_URL = {
'test': "https://huggingface.co/datasets/indolem/IndoMMLU/resolve/main/IndoMMLU.csv",
}
class IndoMMLUConfig(datasets.BuilderConfig):
"""IndoMMLUConfig for IndoMMLU"""
def __init__(self, **kwargs):
"""BuilderConfig for IndoStoryCloze.
**kwargs: keyword arguments forwarded to super.
"""
# Version history:
# 1.0.0: Release version
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
self.features = ['subject', 'group', 'level', 'class', 'question', 'options', 'answer', 'is_for_fewshot']
class IndoMMLU(datasets.GeneratorBasedBuilder):
"""The IndoMMLU Datasets."""
BUILDER_CONFIGS = [IndoMMLUConfig()]
def _info(self):
features = {feature: datasets.Value("string") for feature in self.config.features}
return datasets.DatasetInfo(
description='IndoMMLU',
features=datasets.Features(features),
homepage='https://github.com/fajri91/IndoMMLU',
citation=_CITATION
)
def _split_generators(self, dl_manager):
downloaded_file = dl_manager.download_and_extract(_URL)
return [
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"data_file": downloaded_file['test']}),
]
def _generate_examples(self, data_file):
data = csv.DictReader(open(data_file, newline=''))
for i, row in enumerate(data):
fixed_level, fixed_kelas = fix_level(row['level'], row['kelas'])
yield i, {
"subject": subject2english[row['subject']],
"group": subject2group[row['subject']],
"level": fixed_level,
"class": fixed_kelas,
"question": row['soal'],
"options": row['jawaban'].split('\n'),
"answer": row['kunci'],
"is_for_fewshot": row['is_for_fewshot']
} |