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