added 'passage' column to subsets
Browse files- agieval.py +43 -44
agieval.py
CHANGED
|
@@ -40,37 +40,37 @@ _HOMEPAGE = "https://github.com/csitfun/LogiQA2.0/tree/main"
|
|
| 40 |
_LICENSE = (
|
| 41 |
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
|
| 42 |
)
|
| 43 |
-
HEAD= 'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/v1/'
|
| 44 |
|
| 45 |
_URLS = {
|
| 46 |
"sat_en": {
|
| 47 |
-
"test": HEAD+'sat-en.jsonl',
|
| 48 |
},
|
| 49 |
"sat_math": {
|
| 50 |
-
"test": HEAD+'sat-math.jsonl'
|
| 51 |
},
|
| 52 |
"lsat_ar": {
|
| 53 |
-
"test": HEAD+'lsat-ar.jsonl'
|
| 54 |
},
|
| 55 |
"lsat_lr": {
|
| 56 |
-
"test": HEAD+'lsat-lr.jsonl'
|
| 57 |
},
|
| 58 |
"lsat_rc": {
|
| 59 |
-
"test": HEAD+'lsat-rc.jsonl'
|
| 60 |
},
|
| 61 |
"logiqa": {
|
| 62 |
-
"test": HEAD+'logiqa-en.jsonl'
|
| 63 |
},
|
| 64 |
"aqua_rat": {
|
| 65 |
-
"test": HEAD+'aqua-rat.jsonl'
|
| 66 |
},
|
| 67 |
'math_agieval': {
|
| 68 |
-
"test": HEAD+'math.jsonl'
|
| 69 |
},
|
| 70 |
'few_shot': {
|
| 71 |
-
'few_shot':'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/few_shot_prompts.csv'
|
| 72 |
}
|
| 73 |
-
|
| 74 |
}
|
| 75 |
|
| 76 |
|
|
@@ -135,29 +135,29 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 135 |
"solution": datasets.Value("string"),
|
| 136 |
}
|
| 137 |
)
|
| 138 |
-
elif self.config.name
|
| 139 |
features = datasets.Features(
|
| 140 |
{"passage": datasets.Value("string"),
|
| 141 |
"question": datasets.Value("string"),
|
| 142 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 143 |
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 144 |
"solution": datasets.Value("string"),
|
| 145 |
-
}
|
| 146 |
-
)
|
| 147 |
-
elif self.config.name == "sat_math":
|
| 148 |
-
# remove solution from other
|
| 149 |
-
features = datasets.Features(
|
| 150 |
-
{"question": datasets.Value("string"),
|
| 151 |
-
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 152 |
-
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 153 |
-
"solution": datasets.Value("string"),
|
| 154 |
}
|
| 155 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
elif self.config.name == "logiqa":
|
| 157 |
# remove solution from other
|
| 158 |
features = datasets.Features(
|
| 159 |
{"passage": datasets.Value("string"),
|
| 160 |
-
|
| 161 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 162 |
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 163 |
"solution": datasets.Value("string"),
|
|
@@ -174,14 +174,14 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 174 |
)
|
| 175 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 176 |
features = datasets.Features(
|
| 177 |
-
{"
|
|
|
|
| 178 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 179 |
"label": datasets.ClassLabel(num_classes=5, names=["A", "B", "C", "D", "E"]),
|
| 180 |
"solution": datasets.Value("string"),
|
| 181 |
}
|
| 182 |
)
|
| 183 |
|
| 184 |
-
|
| 185 |
return datasets.DatasetInfo(
|
| 186 |
description=_DESCRIPTION,
|
| 187 |
features=features,
|
|
@@ -197,16 +197,13 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 197 |
"few_shot": _URLS["few_shot"]["few_shot"],
|
| 198 |
}
|
| 199 |
data_dir = dl_manager.download_and_extract(urls)
|
| 200 |
-
splits = [
|
| 201 |
-
datasets.
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
),
|
| 205 |
-
]
|
| 206 |
-
splits.append(datasets.SplitGenerator(
|
| 207 |
name="few_shot",
|
| 208 |
gen_kwargs={"filepath": data_dir["few_shot"], "split": "few_shot"},
|
| 209 |
-
)
|
| 210 |
|
| 211 |
return splits
|
| 212 |
|
|
@@ -228,13 +225,13 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 228 |
try:
|
| 229 |
data = ast.literal_eval(samples[names[self.config.name]][key])
|
| 230 |
explanation_row = explanations[names[self.config.name]][key]
|
| 231 |
-
if self.config.name
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
elif self.config.name == "logiqa":
|
| 239 |
yield key, {
|
| 240 |
"passage": data["passage"],
|
|
@@ -256,7 +253,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 256 |
"solution": str(explanation_row),
|
| 257 |
}
|
| 258 |
|
| 259 |
-
elif self.config.name
|
| 260 |
yield key, {
|
| 261 |
"passage": data["passage"],
|
| 262 |
"question": data["question"],
|
|
@@ -266,6 +263,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 266 |
}
|
| 267 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 268 |
yield key, {
|
|
|
|
| 269 |
"question": data["question"],
|
| 270 |
"options": data["options"],
|
| 271 |
"label": data["label"],
|
|
@@ -277,8 +275,8 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 277 |
with open(filepath, encoding="utf-8") as f:
|
| 278 |
for key, row in enumerate(f):
|
| 279 |
data = json.loads(row)
|
| 280 |
-
|
| 281 |
-
if self.config.name
|
| 282 |
yield key, {
|
| 283 |
"question": data["question"],
|
| 284 |
"options": data["options"],
|
|
@@ -305,8 +303,8 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 305 |
"level": data["level"],
|
| 306 |
"type": data["type"],
|
| 307 |
}
|
| 308 |
-
|
| 309 |
-
elif self.config.name
|
| 310 |
label_index = "ABCDE".index(data["label"])
|
| 311 |
if label_index > len(data["options"]) - 1:
|
| 312 |
continue
|
|
@@ -320,6 +318,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 320 |
}
|
| 321 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 322 |
yield key, {
|
|
|
|
| 323 |
"question": data["question"],
|
| 324 |
"options": data["options"],
|
| 325 |
"label": data["label"],
|
|
|
|
| 40 |
_LICENSE = (
|
| 41 |
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
|
| 42 |
)
|
| 43 |
+
HEAD = 'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/v1/'
|
| 44 |
|
| 45 |
_URLS = {
|
| 46 |
"sat_en": {
|
| 47 |
+
"test": HEAD + 'sat-en.jsonl',
|
| 48 |
},
|
| 49 |
"sat_math": {
|
| 50 |
+
"test": HEAD + 'sat-math.jsonl'
|
| 51 |
},
|
| 52 |
"lsat_ar": {
|
| 53 |
+
"test": HEAD + 'lsat-ar.jsonl'
|
| 54 |
},
|
| 55 |
"lsat_lr": {
|
| 56 |
+
"test": HEAD + 'lsat-lr.jsonl'
|
| 57 |
},
|
| 58 |
"lsat_rc": {
|
| 59 |
+
"test": HEAD + 'lsat-rc.jsonl'
|
| 60 |
},
|
| 61 |
"logiqa": {
|
| 62 |
+
"test": HEAD + 'logiqa-en.jsonl'
|
| 63 |
},
|
| 64 |
"aqua_rat": {
|
| 65 |
+
"test": HEAD + 'aqua-rat.jsonl'
|
| 66 |
},
|
| 67 |
'math_agieval': {
|
| 68 |
+
"test": HEAD + 'math.jsonl'
|
| 69 |
},
|
| 70 |
'few_shot': {
|
| 71 |
+
'few_shot': 'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/few_shot_prompts.csv'
|
| 72 |
}
|
| 73 |
+
|
| 74 |
}
|
| 75 |
|
| 76 |
|
|
|
|
| 135 |
"solution": datasets.Value("string"),
|
| 136 |
}
|
| 137 |
)
|
| 138 |
+
elif self.config.name in ("sat_en", "sat_math"):
|
| 139 |
features = datasets.Features(
|
| 140 |
{"passage": datasets.Value("string"),
|
| 141 |
"question": datasets.Value("string"),
|
| 142 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 143 |
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 144 |
"solution": datasets.Value("string"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
}
|
| 146 |
)
|
| 147 |
+
# elif self.config.name == "sat_math":
|
| 148 |
+
# # remove solution from other
|
| 149 |
+
# features = datasets.Features(
|
| 150 |
+
# {"question": datasets.Value("string"),
|
| 151 |
+
# "options": datasets.features.Sequence(datasets.Value("string")),
|
| 152 |
+
# "label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 153 |
+
# "solution": datasets.Value("string"),
|
| 154 |
+
# }
|
| 155 |
+
# )
|
| 156 |
elif self.config.name == "logiqa":
|
| 157 |
# remove solution from other
|
| 158 |
features = datasets.Features(
|
| 159 |
{"passage": datasets.Value("string"),
|
| 160 |
+
"question": datasets.Value("string"),
|
| 161 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 162 |
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
|
| 163 |
"solution": datasets.Value("string"),
|
|
|
|
| 174 |
)
|
| 175 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 176 |
features = datasets.Features(
|
| 177 |
+
{"passage": datasets.Value("string"),
|
| 178 |
+
"question": datasets.Value("string"),
|
| 179 |
"options": datasets.features.Sequence(datasets.Value("string")),
|
| 180 |
"label": datasets.ClassLabel(num_classes=5, names=["A", "B", "C", "D", "E"]),
|
| 181 |
"solution": datasets.Value("string"),
|
| 182 |
}
|
| 183 |
)
|
| 184 |
|
|
|
|
| 185 |
return datasets.DatasetInfo(
|
| 186 |
description=_DESCRIPTION,
|
| 187 |
features=features,
|
|
|
|
| 197 |
"few_shot": _URLS["few_shot"]["few_shot"],
|
| 198 |
}
|
| 199 |
data_dir = dl_manager.download_and_extract(urls)
|
| 200 |
+
splits = [datasets.SplitGenerator(
|
| 201 |
+
name=datasets.Split.TEST,
|
| 202 |
+
gen_kwargs={"filepath": data_dir["test"], "split": "test"},
|
| 203 |
+
), datasets.SplitGenerator(
|
|
|
|
|
|
|
|
|
|
| 204 |
name="few_shot",
|
| 205 |
gen_kwargs={"filepath": data_dir["few_shot"], "split": "few_shot"},
|
| 206 |
+
)]
|
| 207 |
|
| 208 |
return splits
|
| 209 |
|
|
|
|
| 225 |
try:
|
| 226 |
data = ast.literal_eval(samples[names[self.config.name]][key])
|
| 227 |
explanation_row = explanations[names[self.config.name]][key]
|
| 228 |
+
if self.config.name == "aqua_rat":
|
| 229 |
+
yield key, {
|
| 230 |
+
"question": data["question"],
|
| 231 |
+
"options": data["options"],
|
| 232 |
+
"label": data["label"],
|
| 233 |
+
"solution": str(explanation_row),
|
| 234 |
+
}
|
| 235 |
elif self.config.name == "logiqa":
|
| 236 |
yield key, {
|
| 237 |
"passage": data["passage"],
|
|
|
|
| 253 |
"solution": str(explanation_row),
|
| 254 |
}
|
| 255 |
|
| 256 |
+
elif self.config.name in ("sat_en", "sat_math"):
|
| 257 |
yield key, {
|
| 258 |
"passage": data["passage"],
|
| 259 |
"question": data["question"],
|
|
|
|
| 263 |
}
|
| 264 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 265 |
yield key, {
|
| 266 |
+
"passage": data["passage"],
|
| 267 |
"question": data["question"],
|
| 268 |
"options": data["options"],
|
| 269 |
"label": data["label"],
|
|
|
|
| 275 |
with open(filepath, encoding="utf-8") as f:
|
| 276 |
for key, row in enumerate(f):
|
| 277 |
data = json.loads(row)
|
| 278 |
+
|
| 279 |
+
if self.config.name == "aqua_rat":
|
| 280 |
yield key, {
|
| 281 |
"question": data["question"],
|
| 282 |
"options": data["options"],
|
|
|
|
| 303 |
"level": data["level"],
|
| 304 |
"type": data["type"],
|
| 305 |
}
|
| 306 |
+
|
| 307 |
+
elif self.config.name in ("sat_en", "sat_math"):
|
| 308 |
label_index = "ABCDE".index(data["label"])
|
| 309 |
if label_index > len(data["options"]) - 1:
|
| 310 |
continue
|
|
|
|
| 318 |
}
|
| 319 |
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
|
| 320 |
yield key, {
|
| 321 |
+
"passage": data["passage"],
|
| 322 |
"question": data["question"],
|
| 323 |
"options": data["options"],
|
| 324 |
"label": data["label"],
|