File size: 7,650 Bytes
6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 6f26501 1ea8b02 |
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
_DESCRIPTION = """\
The dataset is an amendment and re-annotation of LogiQA in 2020, a large-scale logical reasoning reading comprehension dataset adapted from the Chinese Civil Service Examination. We increase the data size, refine the texts with manual translation by professionals, and improve the quality by removing items with distinctive cultural features like Chinese idioms. Furthermore, we conduct a fine-grained annotation on the dataset and turn it into a two-way natural language inference (NLI) task, resulting in 35k premise-hypothesis pairs with gold labels, making it the first large-scale NLI dataset for complex logical reasoning
"""
_HOMEPAGE = "https://github.com/csitfun/LogiQA2.0/tree/main"
_LICENSE = (
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
)
HEAD= 'https://raw.githubusercontent.com/microsoft/AGIEval/main/data/v1/'
_URLS = {
"sat_en": {
"test": HEAD+'sat-en.jsonl',
},
"sat_math": {
"test": HEAD+'sat-math.jsonl'
},
"lsat_ar": {
"test": HEAD+'lsat-ar.jsonl'
},
"lsat_lr": {
"test": HEAD+'lsat-lr.jsonl'
},
"lsat_rc": {
"test": HEAD+'lsat-rc.jsonl'
},
"logiqa": {
"test": HEAD+'logiqa-en.jsonl'
},
"aqua_rat": {
"test": HEAD+'aqua_rat.jsonl'
},
'math_agieval': {
"test": HEAD+'math.jsonl'
},
}
class LogiQA2(datasets.GeneratorBasedBuilder):
"""TODO: Short description of my dataset."""
VERSION = datasets.Version("2.0.0")
# This is an example of a dataset with multiple configurations.
# If you don't want/need to define several sub-sets in your dataset,
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
# If you need to make complex sub-parts in the datasets with configurable options
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
# BUILDER_CONFIG_CLASS = MyBuilderConfig
# You will be able to load one or the other configurations in the following list with
# data = datasets.load_dataset('my_dataset', 'first_domain')
# data = datasets.load_dataset('my_dataset', 'second_domain')
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="aqua_rat",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="sat_en",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="sat_math",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="lsat_ar",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="lsat_lr",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="lsat_rc",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="logiqa",
version=VERSION,
description="",
),
datasets.BuilderConfig(
name="math_agieval",
version=VERSION,
description="",
),
]
DEFAULT_CONFIG_NAME = "aqua_rat"
def _info(self):
if self.config.name == "aqua_rat":
features = datasets.Features(
{
"question": datasets.Value("string"),
"options": datasets.features.Sequence(datasets.Value("string")),
"label": datasets.ClassLabel(num_classes=5, names=["A", "B", "C", "D", "E"]),
"solution": datasets.Value("string"),
}
)
elif self.config.name == "sat_en":
features = datasets.Features(
{"passage": datasets.Value("string"),
"question": datasets.Value("string"),
"options": datasets.features.Sequence(datasets.Value("string")),
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
"solution": datasets.Value("string"),
}
)
elif self.config.name in ["sat_math", "logiqa"]:
# remove solution from other
features = datasets.Features(
{"question": datasets.Value("string"),
"options": datasets.features.Sequence(datasets.Value("string")),
"label": datasets.ClassLabel(num_classes=4, names=["A", "B", "C", "D"]),
"solution": datasets.Value("string"),
}
)
elif self.config.name == "math_agieval":
features = datasets.Features(
{"question": datasets.Value("string"),
"answer": datasets.features.Sequence(datasets.Value("string")),
"solution": datasets.Value("string"),
"level": datasets.Value("int32"),
"type": datasets.Value("string"),
}
)
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
features = datasets.Features(
{"question": datasets.Value("string"),
"options": datasets.features.Sequence(datasets.Value("string")),
"label": datasets.ClassLabel(num_classes=5, names=["A", "B", "C", "D", "E"]),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
_urls = _URLS[self.config.name]
urls = {
"test": _urls["test"],
}
data_dir = dl_manager.download_and_extract(urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"filepath": data_dir["test"], "split": "test"},
),
]
def _generate_examples(self, filepath, split):
with open(filepath, encoding="utf-8") as f:
for key, row in enumerate(f):
data = json.loads(row)
if self.config.name in ["aqua_rat","sat_math", "logiqa"]:
yield key, {
"question": data["question"],
"options": data["options"],
"label": data["label"],
"solution": data["other"]["solution"],
}
elif self.config.name == "math_agieval":
yield key, {
"question": data["question"],
"answer": data["answer"],
"solution": data["solution"],
"level": data["level"],
"type": data["type"]
}
elif self.config.name == "sat_en":
yield key, {
"passage": data["passage"],
"question": data["question"],
"options": data["options"],
"label": data["label"],
"solution": data["other"]["solution"],
}
elif self.config.name in ['lsat_lr', 'lsat_rc', 'lsat_ar']:
yield key, {
"question": data["question"],
"options": data["options"],
"label": data["label"],
} |