|
"""xP3x-sample""" |
|
|
|
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} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
A multilingual collection of Winograd Schemas in six languages \ |
|
that can be used for evaluation of cross-lingual commonsense reasoning capabilities. |
|
""" |
|
_DS = [ |
|
"apps.jsonl", |
|
"bisect.jsonl", |
|
"BiSECT.jsonl", |
|
"c3.jsonl", |
|
"cmrc2018.jsonl", |
|
"codecomplex.jsonl", |
|
"code_contests.jsonl", |
|
"code_docstring_corpus.jsonl", |
|
"csl.jsonl", |
|
"drcd.jsonl", |
|
"flores.jsonl", |
|
"github_jupyter_text_code_pairs.jsonl", |
|
"great_code.jsonl", |
|
"mbpp.jsonl", |
|
"mlqa.jsonl", |
|
"multi_eurlex.jsonl", |
|
"neural_code_search.jsonl", |
|
"paws_x.jsonl", |
|
"python_state_changes.jsonl", |
|
"tatoeba_mt.jsonl", |
|
"tnews.jsonl", |
|
"tydiqa_goldp.jsonl", |
|
"tydiqa_primary.jsonl", |
|
"wiki_lingua.jsonl", |
|
"xcopa.jsonl", |
|
"xlcost_text_to_code.jsonl", |
|
"xlsum.jsonl", |
|
"xlwic.jsonl", |
|
"xnli.jsonl", |
|
"xquad.jsonl", |
|
] |
|
_LICENSE = "Apache License 2.0" |
|
_URL = "https://huggingface.co/datasets/Muennighoff/xP3x-sample/raw/main/{ds}.jsonl" |
|
_VERSION = datasets.Version("1.1.0", "") |
|
|
|
|
|
class xP3x_sample(datasets.GeneratorBasedBuilder): |
|
"""xP3x-sample""" |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name=ds.replace(".jsonl", ""), |
|
description=f'xP3x-sample {ds.replace(".jsonl", "")}', |
|
version=_VERSION, |
|
) |
|
for ds in _DS |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"inputs": datasets.Value("string"), |
|
"targets": datasets.Value("string"), |
|
"language": datasets.Value("string"), |
|
"split": datasets.Value("string"), |
|
"template": datasets.Value("string"), |
|
"dataset": datasets.Value("string"), |
|
"config": datasets.Value("string"), |
|
} |
|
), |
|
supervised_keys=None, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
downloaded_files = dl_manager.download(_URL.format(ds=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_, data |
|
|