Update agieval.py
Browse files- agieval.py +43 -73
agieval.py
CHANGED
|
@@ -41,29 +41,9 @@ _LICENSE = (
|
|
| 41 |
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
|
| 42 |
)
|
| 43 |
HEAD= 'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/v1/'
|
| 44 |
-
english_qa_datasets = ["lsat-ar", "lsat-lr", "lsat-rc", "logiqa-en", "sat-math", "sat-en", "aqua-rat",
|
| 45 |
-
"sat-en-without-passage", "gaokao-english"]
|
| 46 |
-
chinese_qa_datasets = ["logiqa-zh", "jec-qa-kd", "jec-qa-ca", "gaokao-chinese", "gaokao-geography", "gaokao-history",
|
| 47 |
-
"gaokao-biology", "gaokao-chemistry", "gaokao-physics", "gaokao-mathqa"]
|
| 48 |
-
english_cloze_datasets = ["math"]
|
| 49 |
-
chinese_cloze_datasets = ["gaokao-mathcloze"]
|
| 50 |
-
all_lst = english_qa_datasets + chinese_qa_datasets + english_cloze_datasets + chinese_cloze_datasets
|
| 51 |
-
t = ['sat-en', 'aqua-rat']
|
| 52 |
-
|
| 53 |
-
# _URLS = {
|
| 54 |
-
# "sat-en": {
|
| 55 |
-
# "test": HEAD+'sat-en.jsonl',
|
| 56 |
-
# },
|
| 57 |
-
# "aqua-rat": {"test": HEAD+'aqua-rat.jsonl'},
|
| 58 |
-
# 'few_shot': {
|
| 59 |
-
# 'few_shot':'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/few_shot_prompts.csv'
|
| 60 |
-
# }
|
| 61 |
-
|
| 62 |
-
# }
|
| 63 |
-
|
| 64 |
|
| 65 |
_URLS = {
|
| 66 |
-
"
|
| 67 |
"test": HEAD+'sat-en.jsonl',
|
| 68 |
},
|
| 69 |
"sat_math": {
|
|
@@ -81,7 +61,7 @@ _URLS = {
|
|
| 81 |
"logiqa": {
|
| 82 |
"test": HEAD+'logiqa-en.jsonl'
|
| 83 |
},
|
| 84 |
-
"
|
| 85 |
"test": HEAD+'aqua-rat.jsonl'
|
| 86 |
},
|
| 87 |
'math_agieval': {
|
|
@@ -92,23 +72,7 @@ _URLS = {
|
|
| 92 |
}
|
| 93 |
|
| 94 |
}
|
| 95 |
-
|
| 96 |
-
# e: {
|
| 97 |
-
# "test": HEAD+e+'.jsonl',
|
| 98 |
-
# } for e in all_lst
|
| 99 |
-
|
| 100 |
-
# }
|
| 101 |
-
# _URLS['few_shot'] ={'few_shot':'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/few_shot_prompts.csv'}
|
| 102 |
-
# _URLS = {
|
| 103 |
-
# "sat-en": {
|
| 104 |
-
# "test": HEAD+'sat-en.jsonl',
|
| 105 |
-
# },
|
| 106 |
-
# "aqua-rat": {"test": HEAD+'aqua-rat.jsonl'},
|
| 107 |
-
# 'few_shot': {
|
| 108 |
-
# 'few_shot':'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/few_shot_prompts.csv'
|
| 109 |
-
# }
|
| 110 |
-
|
| 111 |
-
# }
|
| 112 |
|
| 113 |
class AgiEval(datasets.GeneratorBasedBuilder):
|
| 114 |
"""TODO: Short description of my dataset."""
|
|
@@ -118,46 +82,51 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 118 |
|
| 119 |
BUILDER_CONFIGS = [
|
| 120 |
datasets.BuilderConfig(
|
| 121 |
-
name="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
version=VERSION,
|
| 123 |
description="",
|
| 124 |
),
|
| 125 |
datasets.BuilderConfig(
|
| 126 |
-
name="
|
| 127 |
version=VERSION,
|
| 128 |
description="",
|
| 129 |
),
|
| 130 |
-
# datasets.BuilderConfig(
|
| 131 |
-
# name="sat_math",
|
| 132 |
-
# version=VERSION,
|
| 133 |
-
# description="",
|
| 134 |
-
# ),
|
| 135 |
-
# datasets.BuilderConfig(
|
| 136 |
-
# name="lsat_ar",
|
| 137 |
-
# version=VERSION,
|
| 138 |
-
# description="",
|
| 139 |
-
# ),
|
| 140 |
-
# datasets.BuilderConfig(
|
| 141 |
-
# name="lsat_lr",
|
| 142 |
-
# version=VERSION,
|
| 143 |
-
# description="",
|
| 144 |
-
# ),
|
| 145 |
-
# datasets.BuilderConfig(
|
| 146 |
-
# name="lsat_rc",
|
| 147 |
-
# version=VERSION,
|
| 148 |
-
# description="",
|
| 149 |
-
# ),
|
| 150 |
-
# datasets.BuilderConfig(
|
| 151 |
-
# name="math",
|
| 152 |
-
# version=VERSION,
|
| 153 |
-
# description="",
|
| 154 |
-
# ),
|
| 155 |
]
|
| 156 |
-
DEFAULT_CONFIG_NAME = "
|
| 157 |
|
| 158 |
def _info(self):
|
| 159 |
|
| 160 |
-
if self.config.name == "
|
| 161 |
features = datasets.Features(
|
| 162 |
{
|
| 163 |
"question": datasets.Value("string"),
|
|
@@ -166,7 +135,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 166 |
"solution": datasets.Value("string"),
|
| 167 |
}
|
| 168 |
)
|
| 169 |
-
elif self.config.name == "
|
| 170 |
features = datasets.Features(
|
| 171 |
{"passage": datasets.Value("string"),
|
| 172 |
"question": datasets.Value("string"),
|
|
@@ -243,7 +212,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 243 |
|
| 244 |
def _generate_examples(self, filepath, split):
|
| 245 |
# Mapping for column names in CSV to dataset names
|
| 246 |
-
names = {'
|
| 247 |
'lsat_ar': 'lsat-ar', 'lsat_lr': 'lsat-lr', 'lsat_rc': 'lsat-rc',
|
| 248 |
'logiqa': 'logiqa-en', 'math_agieval': 'math'}
|
| 249 |
|
|
@@ -259,7 +228,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 259 |
try:
|
| 260 |
data = ast.literal_eval(samples[names[self.config.name]][key])
|
| 261 |
explanation_row = explanations[names[self.config.name]][key]
|
| 262 |
-
if self.config.name in ["
|
| 263 |
yield key, {
|
| 264 |
"question": data["question"],
|
| 265 |
"options": data["options"],
|
|
@@ -287,7 +256,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 287 |
"solution": str(explanation_row),
|
| 288 |
}
|
| 289 |
|
| 290 |
-
elif self.config.name == "
|
| 291 |
yield key, {
|
| 292 |
"passage": data["passage"],
|
| 293 |
"question": data["question"],
|
|
@@ -309,7 +278,7 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 309 |
for key, row in enumerate(f):
|
| 310 |
data = json.loads(row)
|
| 311 |
|
| 312 |
-
if self.config.name in ["
|
| 313 |
yield key, {
|
| 314 |
"question": data["question"],
|
| 315 |
"options": data["options"],
|
|
@@ -356,3 +325,4 @@ class AgiEval(datasets.GeneratorBasedBuilder):
|
|
| 356 |
"label": data["label"],
|
| 357 |
"solution": data["label"],
|
| 358 |
}
|
|
|
|
|
|
| 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": {
|
|
|
|
| 61 |
"logiqa": {
|
| 62 |
"test": HEAD+'logiqa-en.jsonl'
|
| 63 |
},
|
| 64 |
+
"aqua_rat": {
|
| 65 |
"test": HEAD+'aqua-rat.jsonl'
|
| 66 |
},
|
| 67 |
'math_agieval': {
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
}
|
| 75 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
class AgiEval(datasets.GeneratorBasedBuilder):
|
| 78 |
"""TODO: Short description of my dataset."""
|
|
|
|
| 82 |
|
| 83 |
BUILDER_CONFIGS = [
|
| 84 |
datasets.BuilderConfig(
|
| 85 |
+
name="aqua_rat",
|
| 86 |
+
version=VERSION,
|
| 87 |
+
description="",
|
| 88 |
+
),
|
| 89 |
+
datasets.BuilderConfig(
|
| 90 |
+
name="sat_en",
|
| 91 |
+
version=VERSION,
|
| 92 |
+
description="",
|
| 93 |
+
),
|
| 94 |
+
datasets.BuilderConfig(
|
| 95 |
+
name="sat_math",
|
| 96 |
+
version=VERSION,
|
| 97 |
+
description="",
|
| 98 |
+
),
|
| 99 |
+
datasets.BuilderConfig(
|
| 100 |
+
name="lsat_ar",
|
| 101 |
+
version=VERSION,
|
| 102 |
+
description="",
|
| 103 |
+
),
|
| 104 |
+
datasets.BuilderConfig(
|
| 105 |
+
name="lsat_lr",
|
| 106 |
+
version=VERSION,
|
| 107 |
+
description="",
|
| 108 |
+
),
|
| 109 |
+
datasets.BuilderConfig(
|
| 110 |
+
name="lsat_rc",
|
| 111 |
+
version=VERSION,
|
| 112 |
+
description="",
|
| 113 |
+
),
|
| 114 |
+
datasets.BuilderConfig(
|
| 115 |
+
name="logiqa",
|
| 116 |
version=VERSION,
|
| 117 |
description="",
|
| 118 |
),
|
| 119 |
datasets.BuilderConfig(
|
| 120 |
+
name="math_agieval",
|
| 121 |
version=VERSION,
|
| 122 |
description="",
|
| 123 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
]
|
| 125 |
+
DEFAULT_CONFIG_NAME = "aqua_rat"
|
| 126 |
|
| 127 |
def _info(self):
|
| 128 |
|
| 129 |
+
if self.config.name == "aqua_rat":
|
| 130 |
features = datasets.Features(
|
| 131 |
{
|
| 132 |
"question": datasets.Value("string"),
|
|
|
|
| 135 |
"solution": datasets.Value("string"),
|
| 136 |
}
|
| 137 |
)
|
| 138 |
+
elif self.config.name == "sat_en":
|
| 139 |
features = datasets.Features(
|
| 140 |
{"passage": datasets.Value("string"),
|
| 141 |
"question": datasets.Value("string"),
|
|
|
|
| 212 |
|
| 213 |
def _generate_examples(self, filepath, split):
|
| 214 |
# Mapping for column names in CSV to dataset names
|
| 215 |
+
names = {'aqua_rat': 'aqua-rat', 'sat_en': 'sat-en', 'sat_math': 'sat-math',
|
| 216 |
'lsat_ar': 'lsat-ar', 'lsat_lr': 'lsat-lr', 'lsat_rc': 'lsat-rc',
|
| 217 |
'logiqa': 'logiqa-en', 'math_agieval': 'math'}
|
| 218 |
|
|
|
|
| 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 in ["aqua_rat", "sat_math"]:
|
| 232 |
yield key, {
|
| 233 |
"question": data["question"],
|
| 234 |
"options": data["options"],
|
|
|
|
| 256 |
"solution": str(explanation_row),
|
| 257 |
}
|
| 258 |
|
| 259 |
+
elif self.config.name == "sat_en":
|
| 260 |
yield key, {
|
| 261 |
"passage": data["passage"],
|
| 262 |
"question": data["question"],
|
|
|
|
| 278 |
for key, row in enumerate(f):
|
| 279 |
data = json.loads(row)
|
| 280 |
|
| 281 |
+
if self.config.name in ["aqua_rat","sat_math"]:
|
| 282 |
yield key, {
|
| 283 |
"question": data["question"],
|
| 284 |
"options": data["options"],
|
|
|
|
| 325 |
"label": data["label"],
|
| 326 |
"solution": data["label"],
|
| 327 |
}
|
| 328 |
+
|