Upload 4 files
Browse files- nq-dev.jsonl.gz +3 -0
- nq-test.jsonl.gz +3 -0
- nq-train.jsonl.gz +3 -0
- wikipedia-nq.py +105 -0
nq-dev.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:797a16addaf389bda60171a060428c212420341d643247725e8df4813cf5a9e3
|
3 |
+
size 3072087
|
nq-test.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5be3607ff80c6d131ad88690eb8dcaf5c651af04068f0e17044e38d2828202d
|
3 |
+
size 139424
|
nq-train.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f920cd4afd7b029b867bf0efb465402ad43dde9725a98160771a778e0e8c816
|
3 |
+
size 27760889
|
wikipedia-nq.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 NQ 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 NQ"
|
40 |
+
|
41 |
+
_DATASET_URLS = {
|
42 |
+
'train': "https://huggingface.co/datasets/xxazz/wikipedia-nq/resolve/main/nq-train.jsonl.gz",
|
43 |
+
'dev': "https://huggingface.co/datasets/xxazz/wikipedia-nq/resolve/main/nq-dev.jsonl.gz",
|
44 |
+
'test': "https://huggingface.co/datasets/xxazz/wikipedia-nq/resolve/main/nq-test.jsonl.gz",
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
class WikipediaNq(datasets.GeneratorBasedBuilder):
|
49 |
+
VERSION = datasets.Version("0.0.1")
|
50 |
+
|
51 |
+
BUILDER_CONFIGS = [
|
52 |
+
datasets.BuilderConfig(version=VERSION,
|
53 |
+
description="Wikipedia NQ 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 |
+
'pos_doc_ids': [datasets.Value('string')],
|
62 |
+
'neg_doc_ids': [datasets.Value('string')],
|
63 |
+
})
|
64 |
+
return datasets.DatasetInfo(
|
65 |
+
# This is the description that will appear on the datasets page.
|
66 |
+
description=_DESCRIPTION,
|
67 |
+
# This defines the different columns of the dataset and their types
|
68 |
+
features=features, # Here we define them above because they are different between the two configurations
|
69 |
+
supervised_keys=None,
|
70 |
+
# Homepage of the dataset for documentation
|
71 |
+
homepage="",
|
72 |
+
# License for the dataset if available
|
73 |
+
license="",
|
74 |
+
# Citation for the dataset
|
75 |
+
citation=_CITATION,
|
76 |
+
)
|
77 |
+
|
78 |
+
def _split_generators(self, dl_manager):
|
79 |
+
if self.config.data_files:
|
80 |
+
downloaded_files = self.config.data_files
|
81 |
+
else:
|
82 |
+
downloaded_files = dl_manager.download_and_extract(_DATASET_URLS)
|
83 |
+
splits = [
|
84 |
+
datasets.SplitGenerator(
|
85 |
+
name=split,
|
86 |
+
gen_kwargs={
|
87 |
+
"files": [downloaded_files[split]] if isinstance(downloaded_files[split], str) else downloaded_files[split],
|
88 |
+
},
|
89 |
+
) for split in downloaded_files
|
90 |
+
]
|
91 |
+
return splits
|
92 |
+
|
93 |
+
def _generate_examples(self, files):
|
94 |
+
"""Yields examples."""
|
95 |
+
for filepath in files:
|
96 |
+
with open(filepath, encoding="utf-8") as f:
|
97 |
+
for line in f:
|
98 |
+
data = json.loads(line)
|
99 |
+
if data.get('neg_doc_ids') is None:
|
100 |
+
data['neg_doc_ids'] = []
|
101 |
+
if data.get('pos_doc_ids') is None:
|
102 |
+
data['pos_doc_ids'] = []
|
103 |
+
if data.get('answers') is None:
|
104 |
+
data['answers'] = []
|
105 |
+
yield data['query_id'], data
|