Datasets:
Tasks:
Text2Text Generation
Modalities:
Text
Formats:
parquet
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Commit
•
a538510
1
Parent(s):
e5adc1c
Adding dataset generation files
Browse files- Model_finetuning_scores.png +3 -0
- Squad_V1_Question_Generation.ipynb +0 -0
- squad_modified_for_t5_qg.py +120 -0
Model_finetuning_scores.png
ADDED
Git LFS Details
|
Squad_V1_Question_Generation.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
squad_modified_for_t5_qg.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""SQUAD: The Stanford Question Answering Dataset."""
|
18 |
+
"""Modified version for fine tuning T5 on Question Generation """
|
19 |
+
|
20 |
+
import json
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
# from datasets.tasks import QuestionAnsweringExtractive
|
25 |
+
|
26 |
+
logger = datasets.logging.get_logger(__name__)
|
27 |
+
|
28 |
+
_CITATION = """\
|
29 |
+
@article{2016arXiv160605250R,
|
30 |
+
author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
|
31 |
+
Konstantin and {Liang}, Percy},
|
32 |
+
title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
|
33 |
+
journal = {arXiv e-prints},
|
34 |
+
year = 2016,
|
35 |
+
eid = {arXiv:1606.05250},
|
36 |
+
pages = {arXiv:1606.05250},
|
37 |
+
archivePrefix = {arXiv},
|
38 |
+
eprint = {1606.05250},
|
39 |
+
}
|
40 |
+
"""
|
41 |
+
|
42 |
+
_DESCRIPTION = """\
|
43 |
+
Stanford Question Answering Dataset (SQuAD) is a reading comprehension \
|
44 |
+
dataset, consisting of questions posed by crowdworkers on a set of Wikipedia \
|
45 |
+
articles, where the answer to every question is a segment of text, or span, \
|
46 |
+
from the corresponding reading passage, or the question might be unanswerable.
|
47 |
+
"""
|
48 |
+
|
49 |
+
_URL = "https://rajpurkar.github.io/SQuAD-explorer/dataset/"
|
50 |
+
_URLS = {
|
51 |
+
"train": _URL + "train-v1.1.json",
|
52 |
+
"dev": _URL + "dev-v1.1.json",
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
class SquadConfig(datasets.BuilderConfig):
|
57 |
+
"""BuilderConfig for SQUAD."""
|
58 |
+
|
59 |
+
def __init__(self, **kwargs):
|
60 |
+
"""BuilderConfig for SQUAD.
|
61 |
+
Args:
|
62 |
+
**kwargs: keyword arguments forwarded to super.
|
63 |
+
"""
|
64 |
+
super(SquadConfig, self).__init__(**kwargs)
|
65 |
+
|
66 |
+
|
67 |
+
class Squad(datasets.GeneratorBasedBuilder):
|
68 |
+
"""SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
|
69 |
+
|
70 |
+
BUILDER_CONFIGS = [
|
71 |
+
SquadConfig(
|
72 |
+
name="plain_text",
|
73 |
+
version=datasets.Version("2.9.0", ""),
|
74 |
+
description="Plain text",
|
75 |
+
),
|
76 |
+
]
|
77 |
+
|
78 |
+
def _info(self):
|
79 |
+
return datasets.DatasetInfo(
|
80 |
+
description=_DESCRIPTION,
|
81 |
+
features=datasets.Features(
|
82 |
+
{
|
83 |
+
"context": datasets.Value("string"),
|
84 |
+
"questions": datasets.Value("string"),
|
85 |
+
}
|
86 |
+
),
|
87 |
+
# No default supervised_keys (as we have to pass both question
|
88 |
+
# and context as input).
|
89 |
+
supervised_keys=None,
|
90 |
+
homepage="https://rajpurkar.github.io/SQuAD-explorer/",
|
91 |
+
citation=_CITATION,
|
92 |
+
task_templates=[
|
93 |
+
|
94 |
+
],
|
95 |
+
)
|
96 |
+
|
97 |
+
def _split_generators(self, dl_manager):
|
98 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
99 |
+
|
100 |
+
return [
|
101 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
102 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
103 |
+
]
|
104 |
+
|
105 |
+
def _generate_examples(self, filepath):
|
106 |
+
"""This function returns the examples in the raw (text) form."""
|
107 |
+
logger.info("generating examples from = %s", filepath)
|
108 |
+
key = 0
|
109 |
+
with open(filepath, encoding="utf-8") as f:
|
110 |
+
squad = json.load(f)
|
111 |
+
for article in squad["data"]:
|
112 |
+
for paragraph in article["paragraphs"]:
|
113 |
+
source_text = f"generate questions: {paragraph['context'].strip()}"
|
114 |
+
questions = [qas['question'].strip() for qas in paragraph['qas']]
|
115 |
+
target_text = " {sep_token} ".join(questions)
|
116 |
+
target_text = f"{target_text} {{sep_token}}"
|
117 |
+
yield key, {
|
118 |
+
"context": source_text,
|
119 |
+
"questions": target_text}
|
120 |
+
key += 1
|