Update agieval.py
Browse files- agieval.py +10 -75
agieval.py
CHANGED
@@ -132,7 +132,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
132 |
|
133 |
def _info(self):
|
134 |
|
135 |
-
if self.config.name == "aqua_rat":
|
136 |
features = datasets.Features(
|
137 |
{
|
138 |
"passage": datasets.Value("string"),
|
@@ -142,18 +142,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
142 |
"solution": datasets.Value("string"),
|
143 |
}
|
144 |
)
|
145 |
-
elif self.config.name in ["sat_math", "sat_en_without_passage", "sat_en"]:
|
146 |
-
features = datasets.Features(
|
147 |
-
{
|
148 |
-
"passage": datasets.Value("string"),
|
149 |
-
"question": datasets.Value("string"),
|
150 |
-
"options": datasets.features.Sequence(datasets.Value("string")),
|
151 |
-
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
152 |
-
"solution": datasets.Value("string"),
|
153 |
-
}
|
154 |
-
)
|
155 |
-
|
156 |
-
elif self.config.name in ["logiqa_en", "logiqa_zh"]:
|
157 |
features = datasets.Features(
|
158 |
{
|
159 |
"passage": datasets.Value("string"),
|
@@ -174,16 +163,6 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
174 |
"type": datasets.Value("string"),
|
175 |
}
|
176 |
)
|
177 |
-
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
178 |
-
features = datasets.Features(
|
179 |
-
{
|
180 |
-
"passage": datasets.Value("string"),
|
181 |
-
"question": datasets.Value("string"),
|
182 |
-
"options": datasets.features.Sequence(datasets.Value("string")),
|
183 |
-
"label": datasets.ClassLabel(num_classes=5, names=["A", "B", "C", "D", "E"]),
|
184 |
-
"solution": datasets.Value("string"),
|
185 |
-
}
|
186 |
-
)
|
187 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
188 |
features = datasets.Features(
|
189 |
{
|
@@ -194,18 +173,6 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
194 |
"solution": datasets.Value("string"),
|
195 |
}
|
196 |
)
|
197 |
-
elif self.config.name in ['gaokao_mathqa', 'gaokao_chinese', 'gaokao_history', 'gaokao_geography', 'gaokao_biology', 'gaokao_chemistry', 'gaokao_english']:
|
198 |
-
features = datasets.Features(
|
199 |
-
{
|
200 |
-
"passage": datasets.Value("string"),
|
201 |
-
"question": datasets.Value("string"),
|
202 |
-
"options": datasets.features.Sequence(datasets.Value("string")),
|
203 |
-
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
204 |
-
"solution": datasets.Value("string"),
|
205 |
-
}
|
206 |
-
)
|
207 |
-
|
208 |
-
|
209 |
return datasets.DatasetInfo(
|
210 |
description=_DESCRIPTION,
|
211 |
features=features,
|
@@ -257,7 +224,10 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
257 |
try:
|
258 |
data = ast.literal_eval(samples[names[self.config.name]][key])
|
259 |
explanation_row = explanations[names[self.config.name]][key]
|
260 |
-
if self.config.name in ["aqua_rat", "sat_math", "sat_en_without_passage", "logiqa_en","logiqa_zh", "sat_en"]:
|
|
|
|
|
|
|
261 |
yield key, {
|
262 |
"passage": data["passage"],
|
263 |
"question": data["question"],
|
@@ -278,14 +248,6 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
278 |
"type": data["type"],
|
279 |
"solution": str(explanation_row),
|
280 |
}
|
281 |
-
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
282 |
-
yield key, {
|
283 |
-
"passage": data["passage"],
|
284 |
-
"question": data["question"],
|
285 |
-
"options": data["options"],
|
286 |
-
"label": data["label"],
|
287 |
-
"solution": str(explanation_row),
|
288 |
-
}
|
289 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
290 |
if isinstance(data["label"], str):
|
291 |
yield key, {
|
@@ -318,8 +280,10 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
318 |
with open(filepath, encoding="utf-8") as f:
|
319 |
for key, row in enumerate(f):
|
320 |
data = json.loads(row)
|
321 |
-
|
322 |
-
|
|
|
|
|
323 |
yield key, {
|
324 |
"passage": data["passage"],
|
325 |
"question": data["question"],
|
@@ -327,14 +291,6 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
327 |
"label": data["label"],
|
328 |
"solution": data["other"]["solution"],
|
329 |
}
|
330 |
-
elif self.config.name in ["logiqa_en","logiqa_zh"]:
|
331 |
-
yield key, {
|
332 |
-
"passage": data["passage"],
|
333 |
-
"question": data["question"],
|
334 |
-
"options": data["options"],
|
335 |
-
"label": data["label"],
|
336 |
-
"solution": data["label"],
|
337 |
-
}
|
338 |
elif self.config.name == "math":
|
339 |
if not data.get("level"):
|
340 |
data["level"] = data['other']['level']
|
@@ -348,27 +304,6 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
348 |
"level": data["level"],
|
349 |
"type": data["type"],
|
350 |
}
|
351 |
-
|
352 |
-
elif self.config.name == "sat_en":
|
353 |
-
label_index = "ABCDE".index(data["label"])
|
354 |
-
if label_index > len(data["options"]) - 1:
|
355 |
-
continue
|
356 |
-
else:
|
357 |
-
yield key, {
|
358 |
-
"passage": data["passage"],
|
359 |
-
"question": data["question"],
|
360 |
-
"options": data["options"],
|
361 |
-
"label": data["label"],
|
362 |
-
"solution": data["other"]["solution"],
|
363 |
-
}
|
364 |
-
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
365 |
-
yield key, {
|
366 |
-
"passage": data["passage"],
|
367 |
-
"question": data["question"],
|
368 |
-
"options": data["options"],
|
369 |
-
"label": data["label"],
|
370 |
-
"solution": data["label"],
|
371 |
-
}
|
372 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
373 |
if isinstance(data["label"], str):
|
374 |
yield key, {
|
|
|
132 |
|
133 |
def _info(self):
|
134 |
|
135 |
+
if self.config.name == ["aqua_rat", 'lsat_lr', 'lsat_rc', 'lsat_ar']:
|
136 |
features = datasets.Features(
|
137 |
{
|
138 |
"passage": datasets.Value("string"),
|
|
|
142 |
"solution": datasets.Value("string"),
|
143 |
}
|
144 |
)
|
145 |
+
elif self.config.name in ["sat_math", "sat_en_without_passage", "sat_en", "logiqa_en", "logiqa_zh", 'gaokao_mathqa', 'gaokao_chinese', 'gaokao_history', 'gaokao_geography', 'gaokao_biology', 'gaokao_chemistry', 'gaokao_english']:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
features = datasets.Features(
|
147 |
{
|
148 |
"passage": datasets.Value("string"),
|
|
|
163 |
"type": datasets.Value("string"),
|
164 |
}
|
165 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
167 |
features = datasets.Features(
|
168 |
{
|
|
|
173 |
"solution": datasets.Value("string"),
|
174 |
}
|
175 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
return datasets.DatasetInfo(
|
177 |
description=_DESCRIPTION,
|
178 |
features=features,
|
|
|
224 |
try:
|
225 |
data = ast.literal_eval(samples[names[self.config.name]][key])
|
226 |
explanation_row = explanations[names[self.config.name]][key]
|
227 |
+
if self.config.name in ["aqua_rat", 'lsat_lr', 'lsat_rc', 'lsat_ar', "sat_math", "sat_en_without_passage", "logiqa_en","logiqa_zh", "sat_en"]:
|
228 |
+
label_index = "ABCDE".index(data["label"])
|
229 |
+
if label_index > len(data["options"]) - 1:
|
230 |
+
continue
|
231 |
yield key, {
|
232 |
"passage": data["passage"],
|
233 |
"question": data["question"],
|
|
|
248 |
"type": data["type"],
|
249 |
"solution": str(explanation_row),
|
250 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
252 |
if isinstance(data["label"], str):
|
253 |
yield key, {
|
|
|
280 |
with open(filepath, encoding="utf-8") as f:
|
281 |
for key, row in enumerate(f):
|
282 |
data = json.loads(row)
|
283 |
+
if self.config.name in ["aqua_rat", 'lsat_lr', 'lsat_rc', 'lsat_ar', "sat_math", "sat_en_without_passage", "logiqa_en","logiqa_zh", "sat_en"]:
|
284 |
+
label_index = "ABCDE".index(data["label"])
|
285 |
+
if label_index > len(data["options"]) - 1:
|
286 |
+
continue
|
287 |
yield key, {
|
288 |
"passage": data["passage"],
|
289 |
"question": data["question"],
|
|
|
291 |
"label": data["label"],
|
292 |
"solution": data["other"]["solution"],
|
293 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
elif self.config.name == "math":
|
295 |
if not data.get("level"):
|
296 |
data["level"] = data['other']['level']
|
|
|
304 |
"level": data["level"],
|
305 |
"type": data["type"],
|
306 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
elif self.config.name in ['gaokao_physics', 'jec_qa_ca', 'jec_qa_kd']:
|
308 |
if isinstance(data["label"], str):
|
309 |
yield key, {
|