Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
found
Annotations Creators:
crowdsourced
Source Datasets:
original
ArXiv:
Tags:
License:
albertvillanova HF staff commited on
Commit
6fd7081
1 Parent(s): 8520f9e

Delete loading script

Browse files
Files changed (1) hide show
  1. adversarial_qa.py +0 -200
adversarial_qa.py DELETED
@@ -1,200 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- # Lint as: python3
17
- """AdversarialQA"""
18
-
19
-
20
- import json
21
- import os
22
-
23
- import datasets
24
-
25
-
26
- logger = datasets.logging.get_logger(__name__)
27
-
28
-
29
- _CITATION = """\
30
- @article{bartolo2020beat,
31
- author = {Bartolo, Max and Roberts, Alastair and Welbl, Johannes and Riedel, Sebastian and Stenetorp, Pontus},
32
- title = {Beat the AI: Investigating Adversarial Human Annotation for Reading Comprehension},
33
- journal = {Transactions of the Association for Computational Linguistics},
34
- volume = {8},
35
- number = {},
36
- pages = {662-678},
37
- year = {2020},
38
- doi = {10.1162/tacl_a_00338},
39
- URL = { https://doi.org/10.1162/tacl_a_00338 },
40
- eprint = { https://doi.org/10.1162/tacl_a_00338 },
41
- abstract = { Innovations in annotation methodology have been a catalyst for Reading Comprehension (RC) datasets and models. One recent trend to challenge current RC models is to involve a model in the annotation process: Humans create questions adversarially, such that the model fails to answer them correctly. In this work we investigate this annotation methodology and apply it in three different settings, collecting a total of 36,000 samples with progressively stronger models in the annotation loop. This allows us to explore questions such as the reproducibility of the adversarial effect, transfer from data collected with varying model-in-the-loop strengths, and generalization to data collected without a model. We find that training on adversarially collected samples leads to strong generalization to non-adversarially collected datasets, yet with progressive performance deterioration with increasingly stronger models-in-the-loop. Furthermore, we find that stronger models can still learn from datasets collected with substantially weaker models-in-the-loop. When trained on data collected with a BiDAF model in the loop, RoBERTa achieves 39.9F1 on questions that it cannot answer when trained on SQuAD—only marginally lower than when trained on data collected using RoBERTa itself (41.0F1). }
42
- }
43
- """
44
-
45
- _DESCRIPTION = """\
46
- AdversarialQA is a Reading Comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles using an adversarial model-in-the-loop.
47
- We use three different models; BiDAF (Seo et al., 2016), BERT-Large (Devlin et al., 2018), and RoBERTa-Large (Liu et al., 2019) in the annotation loop and construct three datasets; D(BiDAF), D(BERT), and D(RoBERTa), each with 10,000 training examples, 1,000 validation, and 1,000 test examples.
48
- The adversarial human annotation paradigm ensures that these datasets consist of questions that current state-of-the-art models (at least the ones used as adversaries in the annotation loop) find challenging.
49
- """
50
-
51
- _HOMEPAGE = "https://adversarialqa.github.io/"
52
- _LICENSE = "CC BY-SA 3.0"
53
- _URL = "https://adversarialqa.github.io/data/aqa_v1.0.zip"
54
-
55
- _CONFIG_NAME_MAP = {
56
- "adversarialQA": {
57
- "dir": "combined",
58
- "model": "Combined",
59
- },
60
- "dbidaf": {
61
- "dir": "1_dbidaf",
62
- "model": "BiDAF",
63
- },
64
- "dbert": {
65
- "dir": "2_dbert",
66
- "model": "BERT-Large",
67
- },
68
- "droberta": {
69
- "dir": "3_droberta",
70
- "model": "RoBERTa-Large",
71
- },
72
- }
73
-
74
-
75
- class AdversarialQA(datasets.GeneratorBasedBuilder):
76
- """AdversarialQA. Version 1.0.0."""
77
-
78
- VERSION = datasets.Version("1.0.0")
79
- BUILDER_CONFIGS = [
80
- datasets.BuilderConfig(
81
- name="adversarialQA",
82
- version=VERSION,
83
- description="This is the combined AdversarialQA data. " + _DESCRIPTION,
84
- ),
85
- datasets.BuilderConfig(
86
- name="dbidaf",
87
- version=VERSION,
88
- description="This is the subset of the data collected using BiDAF (Seo et al., 2016) as a model in the loop. "
89
- + _DESCRIPTION,
90
- ),
91
- datasets.BuilderConfig(
92
- name="dbert",
93
- version=VERSION,
94
- description="This is the subset of the data collected using BERT-Large (Devlin et al., 2018) as a model in the loop. "
95
- + _DESCRIPTION,
96
- ),
97
- datasets.BuilderConfig(
98
- name="droberta",
99
- version=VERSION,
100
- description="This is the subset of the data collected using RoBERTa-Large (Liu et al., 2019) as a model in the loop. "
101
- + _DESCRIPTION,
102
- ),
103
- ]
104
-
105
- def _info(self):
106
- return datasets.DatasetInfo(
107
- description=_DESCRIPTION,
108
- features=datasets.Features(
109
- {
110
- "id": datasets.Value("string"),
111
- "title": datasets.Value("string"),
112
- "context": datasets.Value("string"),
113
- "question": datasets.Value("string"),
114
- "answers": datasets.features.Sequence(
115
- {
116
- "text": datasets.Value("string"),
117
- "answer_start": datasets.Value("int32"),
118
- }
119
- ),
120
- "metadata": {
121
- "split": datasets.Value("string"),
122
- "model_in_the_loop": datasets.Value("string"),
123
- },
124
- }
125
- ),
126
- # No default supervised_keys (as we have to pass both question
127
- # and context as input).
128
- supervised_keys=None,
129
- homepage=_HOMEPAGE,
130
- citation=_CITATION,
131
- )
132
-
133
- @staticmethod
134
- def _get_filepath(dl_dir, config_name, split):
135
- return os.path.join(dl_dir, _CONFIG_NAME_MAP[config_name]["dir"], split + ".json")
136
-
137
- def _split_generators(self, dl_manager):
138
- dl_dir = dl_manager.download_and_extract(_URL)
139
-
140
- return [
141
- datasets.SplitGenerator(
142
- name=datasets.Split.TRAIN,
143
- gen_kwargs={
144
- "filepath": self._get_filepath(dl_dir, self.config.name, "train"),
145
- "split": "train",
146
- "model_in_the_loop": _CONFIG_NAME_MAP[self.config.name]["model"],
147
- },
148
- ),
149
- datasets.SplitGenerator(
150
- name=datasets.Split.VALIDATION,
151
- gen_kwargs={
152
- "filepath": self._get_filepath(dl_dir, self.config.name, "dev"),
153
- "split": "validation",
154
- "model_in_the_loop": _CONFIG_NAME_MAP[self.config.name]["model"],
155
- },
156
- ),
157
- datasets.SplitGenerator(
158
- name=datasets.Split.TEST,
159
- gen_kwargs={
160
- "filepath": self._get_filepath(dl_dir, self.config.name, "test"),
161
- "split": "test",
162
- "model_in_the_loop": _CONFIG_NAME_MAP[self.config.name]["model"],
163
- },
164
- ),
165
- ]
166
-
167
- def _generate_examples(self, filepath, split, model_in_the_loop):
168
- """This function returns the examples in the raw (text) form."""
169
- logger.info("generating examples from = %s", filepath)
170
- with open(filepath, encoding="utf-8") as f:
171
- squad = json.load(f)
172
- id_ = 0
173
- for article in squad["data"]:
174
- title = article.get("title", "").strip()
175
- for paragraph in article["paragraphs"]:
176
- context = paragraph["context"].strip()
177
- for qa in paragraph["qas"]:
178
- question = qa["question"].strip()
179
- qid = qa["id"]
180
-
181
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
182
- answers = [answer["text"].strip() for answer in qa["answers"]]
183
-
184
- # raise BaseException(split, model_in_the_loop)
185
-
186
- # Features currently used are "context", "question", and "answers".
187
- # Others are extracted here for the ease of future expansions.
188
- yield id_, {
189
- "title": title,
190
- "context": context,
191
- "question": question,
192
- "id": qid,
193
- "answers": {
194
- "answer_start": answer_starts,
195
- "text": answers,
196
- },
197
- "metadata": {"split": split, "model_in_the_loop": model_in_the_loop},
198
- }
199
-
200
- id_ += 1