Datasets:

Modalities:
Text
Formats:
parquet
Sub-tasks:
extractive-qa
Libraries:
Datasets
Dask
License:
system HF staff commited on
Commit
529211c
0 Parent(s):

Update files from the datasets library (from 1.0.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.0.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"primary_task": {"description": "TyDi QA is a question answering dataset covering 11 typologically diverse languages with 204K question-answer pairs. \nThe languages of TyDi QA are diverse with regard to their typology -- the set of linguistic features that each language \nexpresses -- such that we expect models performing well on this set to generalize across a large number of the languages \nin the world. It contains language phenomena that would not be found in English-only corpora. To provide a realistic \ninformation-seeking task and avoid priming effects, questions are written by people who want to know the answer, but \ndon\u2019t know the answer yet, (unlike SQuAD and its descendents) and the data is collected directly in each language without\nthe use of translation (unlike MLQA and XQuAD).\n", "citation": "@article{tydiqa,\ntitle = {TyDi QA: A Benchmark for Information-Seeking Question Answering in Typologically Diverse Languages},\nauthor = {Jonathan H. Clark and Eunsol Choi and Michael Collins and Dan Garrette and Tom Kwiatkowski and Vitaly Nikolaev and Jennimaria Palomaki}\nyear = {2020},\njournal = {Transactions of the Association for Computational Linguistics}\n}\n", "homepage": "https://github.com/google-research-datasets/tydiqa", "license": "", "features": {"passage_answer_candidates": {"feature": {"plaintext_start_byte": {"dtype": "int32", "id": null, "_type": "Value"}, "plaintext_end_byte": {"dtype": "int32", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "question_text": {"dtype": "string", "id": null, "_type": "Value"}, "document_title": {"dtype": "string", "id": null, "_type": "Value"}, "language": {"dtype": "string", "id": null, "_type": "Value"}, "annotations": {"feature": {"passage_answer_candidate_index": {"dtype": "int32", "id": null, "_type": "Value"}, "minimal_answers_start_byte": {"dtype": "int32", "id": null, "_type": "Value"}, "minimal_answers_end_byte": {"dtype": "int32", "id": null, "_type": "Value"}, "yes_no_answer": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "document_plaintext": {"dtype": "string", "id": null, "_type": "Value"}, "document_url": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "tydiqa", "config_name": "primary_task", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5552662653, "num_examples": 166916, "dataset_name": "tydiqa"}, "validation": {"name": "validation", "num_bytes": 484604737, "num_examples": 18670, "dataset_name": "tydiqa"}}, "download_checksums": {"https://storage.googleapis.com/tydiqa/v1.0/tydiqa-v1.0-train.jsonl.gz": {"num_bytes": 1729651634, "checksum": "8eeedfee7593db7c3637d65a3d5c67b82486137ac6ac3ea7d08be9a64d71b629"}, "https://storage.googleapis.com/tydiqa/v1.0/tydiqa-v1.0-dev.jsonl.gz": {"num_bytes": 160614310, "checksum": "b52b8d4db1850b1549e960219e6056d8139986f8caf1b5e8b4eecadabed24413"}, "https://storage.googleapis.com/tydiqa/v1.1/tydiqa-goldp-v1.1-train.json": {"num_bytes": 58004076, "checksum": "cefc8e09ff2548d9b10a678d3a6bbbe5bc036be543f92418819ea676c97be23b"}, "https://storage.googleapis.com/tydiqa/v1.1/tydiqa-goldp-v1.1-dev.json": {"num_bytes": 5617409, "checksum": "b286e0f34bc7f52259359989716f369b160565bd12ad8f3a3e311f9b0dbad1c0"}}, "download_size": 1953887429, "dataset_size": 6037267390, "size_in_bytes": 7991154819}, "secondary_task": {"description": "TyDi QA is a question answering dataset covering 11 typologically diverse languages with 204K question-answer pairs. \nThe languages of TyDi QA are diverse with regard to their typology -- the set of linguistic features that each language \nexpresses -- such that we expect models performing well on this set to generalize across a large number of the languages \nin the world. It contains language phenomena that would not be found in English-only corpora. To provide a realistic \ninformation-seeking task and avoid priming effects, questions are written by people who want to know the answer, but \ndon\u2019t know the answer yet, (unlike SQuAD and its descendents) and the data is collected directly in each language without\nthe use of translation (unlike MLQA and XQuAD).\n", "citation": "@article{tydiqa,\ntitle = {TyDi QA: A Benchmark for Information-Seeking Question Answering in Typologically Diverse Languages},\nauthor = {Jonathan H. Clark and Eunsol Choi and Michael Collins and Dan Garrette and Tom Kwiatkowski and Vitaly Nikolaev and Jennimaria Palomaki}\nyear = {2020},\njournal = {Transactions of the Association for Computational Linguistics}\n}\n", "homepage": "https://github.com/google-research-datasets/tydiqa", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "context": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answers": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "answer_start": {"dtype": "int32", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "supervised_keys": null, "builder_name": "tydiqa", "config_name": "secondary_task", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 53010855, "num_examples": 49881, "dataset_name": "tydiqa"}, "validation": {"name": "validation", "num_bytes": 5013731, "num_examples": 5077, "dataset_name": "tydiqa"}}, "download_checksums": {"https://storage.googleapis.com/tydiqa/v1.0/tydiqa-v1.0-train.jsonl.gz": {"num_bytes": 1729651634, "checksum": "8eeedfee7593db7c3637d65a3d5c67b82486137ac6ac3ea7d08be9a64d71b629"}, "https://storage.googleapis.com/tydiqa/v1.0/tydiqa-v1.0-dev.jsonl.gz": {"num_bytes": 160614310, "checksum": "b52b8d4db1850b1549e960219e6056d8139986f8caf1b5e8b4eecadabed24413"}, "https://storage.googleapis.com/tydiqa/v1.1/tydiqa-goldp-v1.1-train.json": {"num_bytes": 58004076, "checksum": "cefc8e09ff2548d9b10a678d3a6bbbe5bc036be543f92418819ea676c97be23b"}, "https://storage.googleapis.com/tydiqa/v1.1/tydiqa-goldp-v1.1-dev.json": {"num_bytes": 5617409, "checksum": "b286e0f34bc7f52259359989716f369b160565bd12ad8f3a3e311f9b0dbad1c0"}}, "download_size": 1953887429, "dataset_size": 58024586, "size_in_bytes": 2011912015}}
dummy/primary_task/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca8d8b3ad9772cb130cb8a7661d945275a2e1ab8394d05028cfd4c87a5e9fe4f
3
+ size 47382
dummy/secondary_task/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13f6e1d20be807743833a5ec5507f152eed8fdbfeae63d66e56386580874b783
3
+ size 3022
tydiqa.py ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """TODO(tydiqa): Add a description here."""
2
+
3
+ from __future__ import absolute_import, division, print_function
4
+
5
+ import json
6
+ import os
7
+ import textwrap
8
+
9
+ import datasets
10
+
11
+
12
+ # TODO(tydiqa): BibTeX citation
13
+ _CITATION = """\
14
+ @article{tydiqa,
15
+ title = {TyDi QA: A Benchmark for Information-Seeking Question Answering in Typologically Diverse Languages},
16
+ author = {Jonathan H. Clark and Eunsol Choi and Michael Collins and Dan Garrette and Tom Kwiatkowski and Vitaly Nikolaev and Jennimaria Palomaki}
17
+ year = {2020},
18
+ journal = {Transactions of the Association for Computational Linguistics}
19
+ }
20
+ """
21
+
22
+ # TODO(tydiqa):
23
+ _DESCRIPTION = """\
24
+ TyDi QA is a question answering dataset covering 11 typologically diverse languages with 204K question-answer pairs.
25
+ The languages of TyDi QA are diverse with regard to their typology -- the set of linguistic features that each language
26
+ expresses -- such that we expect models performing well on this set to generalize across a large number of the languages
27
+ in the world. It contains language phenomena that would not be found in English-only corpora. To provide a realistic
28
+ information-seeking task and avoid priming effects, questions are written by people who want to know the answer, but
29
+ don’t know the answer yet, (unlike SQuAD and its descendents) and the data is collected directly in each language without
30
+ the use of translation (unlike MLQA and XQuAD).
31
+ """
32
+ _URL = "https://storage.googleapis.com/tydiqa/"
33
+ _PRIMARY_TASK_TRAIN = "v1.0/tydiqa-v1.0-train.jsonl.gz"
34
+ _PRIMARY_TASK_DEV = "v1.0/tydiqa-v1.0-dev.jsonl.gz"
35
+ _SECONDARY_TASK_TRAIN = "v1.1/tydiqa-goldp-v1.1-train.json"
36
+ _SECONDARY_TASK_DEV = "v1.1/tydiqa-goldp-v1.1-dev.json"
37
+
38
+
39
+ class TydiqaConfig(datasets.BuilderConfig):
40
+
41
+ """ BuilderConfig for Tydiqa"""
42
+
43
+ def __init__(self, **kwargs):
44
+ """
45
+
46
+ Args:
47
+ **kwargs: keyword arguments forwarded to super.
48
+ """
49
+ super(TydiqaConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
50
+
51
+
52
+ class Tydiqa(datasets.GeneratorBasedBuilder):
53
+ """TODO(tydiqa): Short description of my dataset."""
54
+
55
+ # TODO(tydiqa): Set up version.
56
+ VERSION = datasets.Version("0.1.0")
57
+ BUILDER_CONFIGS = [
58
+ TydiqaConfig(
59
+ name="primary_task",
60
+ description=textwrap.dedent(
61
+ """\
62
+ Passage selection task (SelectP): Given a list of the passages in the article, return either (a) the index of
63
+ the passage that answers the question or (b) NULL if no such passage exists.
64
+ Minimal answer span task (MinSpan): Given the full text of an article, return one of (a) the start and end
65
+ byte indices of the minimal span that completely answers the question; (b) YES or NO if the question requires
66
+ a yes/no answer and we can draw a conclusion from the passage; (c) NULL if it is not possible to produce a
67
+ minimal answer for this question."""
68
+ ),
69
+ ),
70
+ TydiqaConfig(
71
+ name="secondary_task",
72
+ description=textwrap.dedent(
73
+ """Gold passage task (GoldP): Given a passage that is guaranteed to contain the
74
+ answer, predict the single contiguous span of characters that answers the question. This is more similar to
75
+ existing reading comprehension datasets (as opposed to the information-seeking task outlined above).
76
+ This task is constructed with two goals in mind: (1) more directly comparing with prior work and (2) providing
77
+ a simplified way for researchers to use TyDi QA by providing compatibility with existing code for SQuAD 1.1,
78
+ XQuAD, and MLQA. Toward these goals, the gold passage task differs from the primary task in several ways:
79
+ only the gold answer passage is provided rather than the entire Wikipedia article;
80
+ unanswerable questions have been discarded, similar to MLQA and XQuAD;
81
+ we evaluate with the SQuAD 1.1 metrics like XQuAD; and
82
+ Thai and Japanese are removed since the lack of whitespace breaks some tools.
83
+ """
84
+ ),
85
+ ),
86
+ ]
87
+
88
+ def _info(self):
89
+ # TODO(tydiqa): Specifies the datasets.DatasetInfo object
90
+ if self.config.name == "primary_task":
91
+ return datasets.DatasetInfo(
92
+ # This is the description that will appear on the datasets page.
93
+ description=_DESCRIPTION,
94
+ # datasets.features.FeatureConnectors
95
+ features=datasets.Features(
96
+ {
97
+ "passage_answer_candidates": datasets.features.Sequence(
98
+ {
99
+ "plaintext_start_byte": datasets.Value("int32"),
100
+ "plaintext_end_byte": datasets.Value("int32"),
101
+ }
102
+ ),
103
+ "question_text": datasets.Value("string"),
104
+ "document_title": datasets.Value("string"),
105
+ "language": datasets.Value("string"),
106
+ "annotations": datasets.features.Sequence(
107
+ {
108
+ # 'annotation_id': datasets.Value('variant'),
109
+ "passage_answer_candidate_index": datasets.Value("int32"),
110
+ "minimal_answers_start_byte": datasets.Value("int32"),
111
+ "minimal_answers_end_byte": datasets.Value("int32"),
112
+ "yes_no_answer": datasets.Value("string"),
113
+ }
114
+ ),
115
+ "document_plaintext": datasets.Value("string"),
116
+ # 'example_id': datasets.Value('variant'),
117
+ "document_url": datasets.Value("string")
118
+ # These are the features of your dataset like images, labels ...
119
+ }
120
+ ),
121
+ # If there's a common (input, target) tuple from the features,
122
+ # specify them here. They'll be used if as_supervised=True in
123
+ # builder.as_dataset.
124
+ supervised_keys=None,
125
+ # Homepage of the dataset for documentation
126
+ homepage="https://github.com/google-research-datasets/tydiqa",
127
+ citation=_CITATION,
128
+ )
129
+ elif self.config.name == "secondary_task":
130
+ return datasets.DatasetInfo(
131
+ description=_DESCRIPTION,
132
+ features=datasets.Features(
133
+ {
134
+ "id": datasets.Value("string"),
135
+ "title": datasets.Value("string"),
136
+ "context": datasets.Value("string"),
137
+ "question": datasets.Value("string"),
138
+ "answers": datasets.features.Sequence(
139
+ {
140
+ "text": datasets.Value("string"),
141
+ "answer_start": datasets.Value("int32"),
142
+ }
143
+ ),
144
+ }
145
+ ),
146
+ # No default supervised_keys (as we have to pass both question
147
+ # and context as input).
148
+ supervised_keys=None,
149
+ homepage="https://github.com/google-research-datasets/tydiqa",
150
+ citation=_CITATION,
151
+ )
152
+
153
+ def _split_generators(self, dl_manager):
154
+ """Returns SplitGenerators."""
155
+ # TODO(tydiqa): Downloads the data and defines the splits
156
+ # dl_manager is a datasets.download.DownloadManager that can be used to
157
+ # download and extract URLs
158
+ primary_urls_to_download = {
159
+ "train": os.path.join(_URL, _PRIMARY_TASK_TRAIN),
160
+ "dev": os.path.join(_URL, _PRIMARY_TASK_DEV),
161
+ }
162
+ secondary_urls_to_download = {
163
+ "train": os.path.join(_URL, _SECONDARY_TASK_TRAIN),
164
+ "dev": os.path.join(_URL, _SECONDARY_TASK_DEV),
165
+ }
166
+ primary_downloaded = dl_manager.download_and_extract(primary_urls_to_download)
167
+ secondary_downloaded = dl_manager.download_and_extract(secondary_urls_to_download)
168
+ if self.config.name == "primary_task":
169
+ return [
170
+ datasets.SplitGenerator(
171
+ name=datasets.Split.TRAIN,
172
+ # These kwargs will be passed to _generate_examples
173
+ gen_kwargs={"filepath": primary_downloaded["train"]},
174
+ ),
175
+ datasets.SplitGenerator(
176
+ name=datasets.Split.VALIDATION,
177
+ # These kwargs will be passed to _generate_examples
178
+ gen_kwargs={"filepath": primary_downloaded["dev"]},
179
+ ),
180
+ ]
181
+ elif self.config.name == "secondary_task":
182
+ return [
183
+ datasets.SplitGenerator(
184
+ name=datasets.Split.TRAIN,
185
+ # These kwargs will be passed to _generate_examples
186
+ gen_kwargs={"filepath": secondary_downloaded["train"]},
187
+ ),
188
+ datasets.SplitGenerator(
189
+ name=datasets.Split.VALIDATION,
190
+ # These kwargs will be passed to _generate_examples
191
+ gen_kwargs={"filepath": secondary_downloaded["dev"]},
192
+ ),
193
+ ]
194
+
195
+ def _generate_examples(self, filepath):
196
+ """Yields examples."""
197
+ # TODO(tydiqa): Yields (key, example) tuples from the dataset
198
+ if self.config.name == "primary_task":
199
+ with open(filepath, encoding="utf-8") as f:
200
+ for id_, row in enumerate(f):
201
+ data = json.loads(row)
202
+ passages = data["passage_answer_candidates"]
203
+ end_byte = [passage["plaintext_end_byte"] for passage in passages]
204
+ start_byte = [passage["plaintext_start_byte"] for passage in passages]
205
+ title = data["document_title"]
206
+ lang = data["language"]
207
+ question = data["question_text"]
208
+ annotations = data["annotations"]
209
+ # annot_ids = [annotation["annotation_id"] for annotation in annotations]
210
+ yes_no_answers = [annotation["yes_no_answer"] for annotation in annotations]
211
+ min_answers_end_byte = [
212
+ annotation["minimal_answer"]["plaintext_end_byte"] for annotation in annotations
213
+ ]
214
+ min_answers_start_byte = [
215
+ annotation["minimal_answer"]["plaintext_start_byte"] for annotation in annotations
216
+ ]
217
+ passage_cand_answers = [
218
+ annotation["passage_answer"]["candidate_index"] for annotation in annotations
219
+ ]
220
+ doc = data["document_plaintext"]
221
+ # example_id = data["example_id"]
222
+ url = data["document_url"]
223
+ yield id_, {
224
+ "passage_answer_candidates": {
225
+ "plaintext_start_byte": start_byte,
226
+ "plaintext_end_byte": end_byte,
227
+ },
228
+ "question_text": question,
229
+ "document_title": title,
230
+ "language": lang,
231
+ "annotations": {
232
+ # 'annotation_id': annot_ids,
233
+ "passage_answer_candidate_index": passage_cand_answers,
234
+ "minimal_answers_start_byte": min_answers_start_byte,
235
+ "minimal_answers_end_byte": min_answers_end_byte,
236
+ "yes_no_answer": yes_no_answers,
237
+ },
238
+ "document_plaintext": doc,
239
+ # 'example_id': example_id,
240
+ "document_url": url,
241
+ }
242
+ elif self.config.name == "secondary_task":
243
+ with open(filepath, encoding="utf-8") as f:
244
+ data = json.load(f)
245
+ for article in data["data"]:
246
+ title = article.get("title", "").strip()
247
+ for paragraph in article["paragraphs"]:
248
+ context = paragraph["context"].strip()
249
+ for qa in paragraph["qas"]:
250
+ question = qa["question"].strip()
251
+ id_ = qa["id"]
252
+
253
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
254
+ answers = [answer["text"].strip() for answer in qa["answers"]]
255
+
256
+ # Features currently used are "context", "question", and "answers".
257
+ # Others are extracted here for the ease of future expansions.
258
+ yield id_, {
259
+ "title": title,
260
+ "context": context,
261
+ "question": question,
262
+ "id": id_,
263
+ "answers": {
264
+ "answer_start": answer_starts,
265
+ "text": answers,
266
+ },
267
+ }