Commit
•
b511e33
1
Parent(s):
df6d6d3
feat: add subsets based on level
Browse files- IndoMMLU.py +16 -14
IndoMMLU.py
CHANGED
@@ -124,20 +124,21 @@ _URL = {
|
|
124 |
class IndoMMLUConfig(datasets.BuilderConfig):
|
125 |
"""IndoMMLUConfig for IndoMMLU"""
|
126 |
|
127 |
-
def __init__(self, **kwargs):
|
128 |
"""BuilderConfig for IndoStoryCloze.
|
129 |
**kwargs: keyword arguments forwarded to super.
|
130 |
"""
|
131 |
# Version history:
|
132 |
# 1.0.0: Release version
|
133 |
-
|
|
|
|
|
134 |
self.features = ['subject', 'group', 'level', 'class', 'question', 'options', 'answer', 'is_for_fewshot']
|
135 |
|
136 |
-
|
137 |
class IndoMMLU(datasets.GeneratorBasedBuilder):
|
138 |
"""The IndoMMLU Datasets."""
|
139 |
|
140 |
-
BUILDER_CONFIGS = [IndoMMLUConfig()]
|
141 |
|
142 |
def _info(self):
|
143 |
features = {feature: datasets.Value("string") for feature in self.config.features}
|
@@ -160,13 +161,14 @@ class IndoMMLU(datasets.GeneratorBasedBuilder):
|
|
160 |
data = csv.DictReader(open(data_file, newline=''))
|
161 |
for i, row in enumerate(data):
|
162 |
fixed_level, fixed_kelas = fix_level(row['level'], row['kelas'])
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
124 |
class IndoMMLUConfig(datasets.BuilderConfig):
|
125 |
"""IndoMMLUConfig for IndoMMLU"""
|
126 |
|
127 |
+
def __init__(self, name:str, **kwargs):
|
128 |
"""BuilderConfig for IndoStoryCloze.
|
129 |
**kwargs: keyword arguments forwarded to super.
|
130 |
"""
|
131 |
# Version history:
|
132 |
# 1.0.0: Release version
|
133 |
+
# 1.0.1: Add level to the config to create subsets
|
134 |
+
super().__init__(version=datasets.Version("1.0.1"), **kwargs)
|
135 |
+
self.name = name
|
136 |
self.features = ['subject', 'group', 'level', 'class', 'question', 'options', 'answer', 'is_for_fewshot']
|
137 |
|
|
|
138 |
class IndoMMLU(datasets.GeneratorBasedBuilder):
|
139 |
"""The IndoMMLU Datasets."""
|
140 |
|
141 |
+
BUILDER_CONFIGS = [IndoMMLUConfig(name=level) for level in ['SD', 'SMP', 'SMA', 'University entrance test']]
|
142 |
|
143 |
def _info(self):
|
144 |
features = {feature: datasets.Value("string") for feature in self.config.features}
|
|
|
161 |
data = csv.DictReader(open(data_file, newline=''))
|
162 |
for i, row in enumerate(data):
|
163 |
fixed_level, fixed_kelas = fix_level(row['level'], row['kelas'])
|
164 |
+
if self.config.name == fixed_level:
|
165 |
+
yield i, {
|
166 |
+
"subject": subject2english[row['subject']],
|
167 |
+
"group": subject2group[row['subject']],
|
168 |
+
"level": fixed_level,
|
169 |
+
"class": fixed_kelas,
|
170 |
+
"question": row['soal'],
|
171 |
+
"options": row['jawaban'].split('\n'),
|
172 |
+
"answer": row['kunci'],
|
173 |
+
"is_for_fewshot": row['is_for_fewshot']
|
174 |
+
}
|