Xueguang Ma
commited on
Commit
•
a3896e5
1
Parent(s):
3b1bd5c
add data
Browse files- .gitattributes +3 -0
- trivia-dev.jsonl.gz +3 -0
- trivia-test.jsonl.gz +3 -0
- trivia-train.jsonl.gz +3 -0
- wikipedia-trivia.py +120 -0
.gitattributes
CHANGED
@@ -25,3 +25,6 @@ saved_model/**/* 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
|
|
|
|
|
|
|
|
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
|
28 |
+
trivia-dev.jsonl.gz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
trivia-test.jsonl.gz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
trivia-train.jsonl.gz filter=lfs diff=lfs merge=lfs -text
|
trivia-dev.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e6bcd57616db351ef1b3827acb2ece97bf8c84bbf4aad30eac1070b1debf36ee
|
3 |
+
size 148334995
|
trivia-test.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7684273b0bffb844cd756375ea026d2d6055bac8fa006568f6eec443771b4db8
|
3 |
+
size 1449634
|
trivia-train.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f5f311c9ab9cb5ba73d70ed24c601437e4a3fdd6c89387abe89ad7f37df0e2b
|
3 |
+
size 1326297948
|
wikipedia-trivia.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
+
"""Wikipedia TriviaQA dataset."""
|
18 |
+
|
19 |
+
import json
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
|
23 |
+
_CITATION = """
|
24 |
+
@inproceedings{karpukhin-etal-2020-dense,
|
25 |
+
title = "Dense Passage Retrieval for Open-Domain Question Answering",
|
26 |
+
author = "Karpukhin, Vladimir and Oguz, Barlas and Min, Sewon and Lewis, Patrick and Wu, Ledell and Edunov,
|
27 |
+
Sergey and Chen, Danqi and Yih, Wen-tau",
|
28 |
+
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
|
29 |
+
month = nov,
|
30 |
+
year = "2020",
|
31 |
+
address = "Online",
|
32 |
+
publisher = "Association for Computational Linguistics",
|
33 |
+
url = "https://www.aclweb.org/anthology/2020.emnlp-main.550",
|
34 |
+
doi = "10.18653/v1/2020.emnlp-main.550",
|
35 |
+
pages = "6769--6781",
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
_DESCRIPTION = "dataset load script for Wikipedia Trivia"
|
40 |
+
|
41 |
+
_DATASET_URLS = {
|
42 |
+
'train': "https://huggingface.co/datasets/tevatron/wikipedia-trivia/resolve/main/trivia-train.jsonl.gz",
|
43 |
+
'dev': "https://huggingface.co/datasets/tevatron/wikipedia-trivia/resolve/main/trivia-dev.jsonl.gz",
|
44 |
+
'test': "https://huggingface.co/datasets/tevatron/wikipedia-trivia/resolve/main/trivia-test.jsonl.gz",
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
class WikipediaTrivia(datasets.GeneratorBasedBuilder):
|
49 |
+
VERSION = datasets.Version("0.0.1")
|
50 |
+
|
51 |
+
BUILDER_CONFIGS = [
|
52 |
+
datasets.BuilderConfig(version=VERSION,
|
53 |
+
description="Wikipedia Trivia train/dev/test datasets"),
|
54 |
+
]
|
55 |
+
|
56 |
+
def _info(self):
|
57 |
+
features = datasets.Features({
|
58 |
+
'query_id': datasets.Value('string'),
|
59 |
+
'query': datasets.Value('string'),
|
60 |
+
'answers': [datasets.Value('string')],
|
61 |
+
'positive_passages': [
|
62 |
+
{'docid': datasets.Value('string'), 'text': datasets.Value('string'),
|
63 |
+
'title': datasets.Value('string')}
|
64 |
+
],
|
65 |
+
'negative_passages': [
|
66 |
+
{'docid': datasets.Value('string'), 'text': datasets.Value('string'),
|
67 |
+
'title': datasets.Value('string')}
|
68 |
+
],
|
69 |
+
})
|
70 |
+
|
71 |
+
return datasets.DatasetInfo(
|
72 |
+
# This is the description that will appear on the datasets page.
|
73 |
+
description=_DESCRIPTION,
|
74 |
+
# This defines the different columns of the dataset and their types
|
75 |
+
features=features, # Here we define them above because they are different between the two configurations
|
76 |
+
supervised_keys=None,
|
77 |
+
# Homepage of the dataset for documentation
|
78 |
+
homepage="",
|
79 |
+
# License for the dataset if available
|
80 |
+
license="",
|
81 |
+
# Citation for the dataset
|
82 |
+
citation=_CITATION,
|
83 |
+
)
|
84 |
+
|
85 |
+
def _split_generators(self, dl_manager):
|
86 |
+
downloaded_files = dl_manager.download_and_extract(_DATASET_URLS)
|
87 |
+
splits = [
|
88 |
+
datasets.SplitGenerator(
|
89 |
+
name="train",
|
90 |
+
gen_kwargs={
|
91 |
+
"filepath": downloaded_files["train"],
|
92 |
+
},
|
93 |
+
),
|
94 |
+
datasets.SplitGenerator(
|
95 |
+
name='dev',
|
96 |
+
gen_kwargs={
|
97 |
+
"filepath": downloaded_files["dev"],
|
98 |
+
},
|
99 |
+
),
|
100 |
+
datasets.SplitGenerator(
|
101 |
+
name='test',
|
102 |
+
gen_kwargs={
|
103 |
+
"filepath": downloaded_files["test"],
|
104 |
+
},
|
105 |
+
),
|
106 |
+
]
|
107 |
+
return splits
|
108 |
+
|
109 |
+
def _generate_examples(self, filepath):
|
110 |
+
"""Yields examples."""
|
111 |
+
with open(filepath, encoding="utf-8") as f:
|
112 |
+
for line in f:
|
113 |
+
data = json.loads(line)
|
114 |
+
if data.get('negative_passages') is None:
|
115 |
+
data['negative_passages'] = []
|
116 |
+
if data.get('positive_passages') is None:
|
117 |
+
data['positive_passages'] = []
|
118 |
+
if data.get('answers') is None:
|
119 |
+
data['answers'] = []
|
120 |
+
yield data['query_id'], data
|