File size: 2,946 Bytes
f65642d 7dcda30 5b93bcd f65642d 03996ca 18cfc02 03996ca f65642d 03996ca f65642d 03996ca f65642d 03996ca c8344ef f65642d 03996ca f65642d 03996ca |
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 |
"""XWinograd"""
import json
import datasets
logger = datasets.logging.get_logger(__name__)
_CITATION = """\
@misc{muennighoff2022crosslingual,
title={Crosslingual Generalization through Multitask Finetuning},
author={Niklas Muennighoff and Thomas Wang and Lintang Sutawika and Adam Roberts and Stella Biderman and Teven Le Scao and M Saiful Bari and Sheng Shen and Zheng-Xin Yong and Hailey Schoelkopf and Xiangru Tang and Dragomir Radev and Alham Fikri Aji and Khalid Almubarak and Samuel Albanie and Zaid Alyafeai and Albert Webson and Edward Raff and Colin Raffel},
year={2022},
eprint={2211.01786},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@misc{tikhonov2021heads,
title={It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoning},
author={Alexey Tikhonov and Max Ryabinin},
year={2021},
eprint={2106.12066},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
"""
_DESCRIPTION = """\
A multilingual collection of Winograd Schemas in six languages \
that can be used for evaluation of cross-lingual commonsense reasoning capabilities.
"""
_LANG = ["en", "fr", "jp", "pt", "ru", "zh"]
_URL = "https://huggingface.co/datasets/Muennighoff/xwinograd/raw/main/test/{lang}.jsonl"
_VERSION = datasets.Version("1.1.0", "")
class XWinograd(datasets.GeneratorBasedBuilder):
"""XWinograd"""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name=lang,
description=f"XWinograd in {lang}",
version=_VERSION,
)
for lang in _LANG
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"sentence": datasets.Value("string"),
"option1": datasets.Value("string"),
"option2": datasets.Value("string"),
"answer": datasets.Value("string")
}
),
supervised_keys=None,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download(_URL.format(lang=self.config.name))
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={'filepath': downloaded_files}
)
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
logger.info("Generating examples from = %s", filepath)
with open(filepath, encoding="utf-8") as f:
for id_, row in enumerate(f):
data = json.loads(row)
yield id_, {
"sentence": data["sentence"],
"option1": data["option1"],
"option2": data["option2"],
"answer": data["answer"],
}
|