Datasets:

Sub-tasks:
extractive-qa
Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
found
Annotations Creators:
no-annotation
Source Datasets:
original
ArXiv:
Tags:
License:
jonsaadfalcon commited on
Commit
96f0ff3
1 Parent(s): 2b4bd05

First version of the LoTTE passages dataset.

Browse files
Files changed (3) hide show
  1. .DS_Store +0 -0
  2. Generate_JSON_From_TSV.py +34 -0
  3. lotte-passages.py +187 -0
.DS_Store ADDED
Binary file (8.2 kB). View file
 
Generate_JSON_From_TSV.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import pandas as pd
3
+ import os
4
+ from tqdm import tqdm
5
+ import json
6
+
7
+ directories = ['lifestyle', 'pooled', 'recreation', 'science', 'technology', 'writing'] #os.listdir()
8
+
9
+ file_name_conversion = {"questions.search.tsv": "search", "questions.forum.tsv": "forum"}
10
+
11
+ for directory in directories:
12
+
13
+ for file_type in ["dev", "test"]:
14
+
15
+ for question_type in ["questions.forum.tsv", "questions.search.tsv"]:
16
+
17
+
18
+
19
+ current_jsonl = []
20
+ loaded_file = pd.read_csv('data/' + directory + "/" + file_type + "/" + question_type, sep='\t', header=0)
21
+
22
+ for row in tqdm(range(0, len(loaded_file))):
23
+
24
+ current_jsonl.append({
25
+ "query_id": row,
26
+ "text": loaded_file.iloc[row][1]
27
+ })
28
+
29
+ if not os.path.isdir(directory):
30
+
31
+ os.mkdir(directory)
32
+
33
+ with open(directory + "/" + file_name_conversion[question_type] + "_" + file_type + ".jsonl", 'w', encoding="utf-8") as fout:
34
+ json.dump(current_jsonl, fout)
lotte-passages.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ # TODO: Address all TODOs and remove all explanatory comments
17
+ """TODO: Add a description here."""
18
+
19
+
20
+ import csv
21
+ import json
22
+ import os
23
+
24
+ import datasets
25
+ import pandas as pd
26
+ import zipfile
27
+
28
+
29
+ # TODO: Add BibTeX citation
30
+ # Find for instance the citation on arxiv or on the dataset repo/website
31
+ _CITATION = """\
32
+ @inproceedings{santhanam-etal-2022-colbertv2,
33
+ title = "{C}ol{BERT}v2: Effective and Efficient Retrieval via Lightweight Late Interaction",
34
+ author = "Santhanam, Keshav and
35
+ Khattab, Omar and
36
+ Saad-Falcon, Jon and
37
+ Potts, Christopher and
38
+ Zaharia, Matei",
39
+ booktitle = "Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies",
40
+ month = jul,
41
+ year = "2022",
42
+ address = "Seattle, United States",
43
+ publisher = "Association for Computational Linguistics",
44
+ url = "https://aclanthology.org/2022.naacl-main.272",
45
+ pages = "3715--3734",
46
+ abstract = "Neural information retrieval (IR) has greatly advanced search and other knowledge-intensive language tasks. While many neural IR methods encode queries and documents into single-vector representations, late interaction models produce multi-vector representations at the granularity of each token and decompose relevance modeling into scalable token-level computations. This decomposition has been shown to make late interaction more effective, but it inflates the space footprint of these models by an order of magnitude. In this work, we introduce Maize, a retriever that couples an aggressive residual compression mechanism with a denoised supervision strategy to simultaneously improve the quality and space footprint of late interaction. We evaluate Maize across a wide range of benchmarks, establishing state-of-the-art quality within and outside the training domain while reducing the space footprint of late interaction models by 6{--}10x.",
47
+ }
48
+ """
49
+
50
+ # TODO: Add description of the dataset here
51
+ # You can copy an official description
52
+ _DESCRIPTION = """\
53
+ LoTTE Passages Dataset for ColBERTv2
54
+ """
55
+
56
+ # TODO: Add a link to an official homepage for the dataset here
57
+ _HOMEPAGE = "https://huggingface.co/datasets/colbertv2/LoTTe-passages"
58
+
59
+ # TODO: Add the licence for the dataset here if you can find it
60
+ _LICENSE = ""
61
+
62
+ _URL = {
63
+ "pooled": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/pooled/",
64
+ "lifestyle": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/lifestyle/",
65
+ "recreation": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/pooled/",
66
+ "science": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/lifestyle/",
67
+ "technology": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/pooled/",
68
+ "writing": "https://huggingface.co/datasets/colbertv2/LoTTe-passages/resolve/main/lifestyle/"
69
+ }
70
+
71
+
72
+
73
+
74
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
75
+ class NewDataset(datasets.GeneratorBasedBuilder):
76
+ """TODO: Short description of my dataset."""
77
+
78
+ VERSION = datasets.Version("1.1.0")
79
+
80
+ # This is an example of a dataset with multiple configurations.
81
+ # If you don't want/need to define several sub-sets in your dataset,
82
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
83
+
84
+ # If you need to make complex sub-parts in the datasets with configurable options
85
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
86
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
87
+
88
+ # You will be able to load one or the other configurations in the following list with
89
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
90
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
91
+ BUILDER_CONFIGS = [
92
+ datasets.BuilderConfig(name="pooled", version=VERSION, description=""),
93
+ datasets.BuilderConfig(name="lifestyle", version=VERSION, description=""),
94
+ datasets.BuilderConfig(name="recreation", version=VERSION, description=""),
95
+ datasets.BuilderConfig(name="science", version=VERSION, description=""),
96
+ datasets.BuilderConfig(name="technology", version=VERSION, description=""),
97
+ datasets.BuilderConfig(name="writing", version=VERSION, description=""),
98
+ #datasets.BuilderConfig(name="pooled_search_valid", version=VERSION, description=""),
99
+ #datasets.BuilderConfig(name="pooled_search_test", version=VERSION, description=""),
100
+ #datasets.BuilderConfig(name="pooled_forum_valid", version=VERSION, description=""),
101
+ #datasets.BuilderConfig(name="pooled_forum_test", version=VERSION, description=""),
102
+ #datasets.BuilderConfig(name="lifestyle_search", version=VERSION, description=""),
103
+ #datasets.BuilderConfig(name="lifestyle_forum", version=VERSION, description=""),
104
+ #datasets.BuilderConfig(name="recreation_search", version=VERSION, description=""),
105
+ #datasets.BuilderConfig(name="recreation_forum", version=VERSION, description=""),
106
+ #datasets.BuilderConfig(name="science_search", version=VERSION, description=""),
107
+ #datasets.BuilderConfig(name="science_forum", version=VERSION, description=""),
108
+ #datasets.BuilderConfig(name="technology_search", version=VERSION, description=""),
109
+ #datasets.BuilderConfig(name="technology_forum", version=VERSION, description=""),
110
+ #datasets.BuilderConfig(name="writing_search", version=VERSION, description=""),
111
+ #datasets.BuilderConfig(name="writing_forum", version=VERSION, description=""),
112
+ ]
113
+
114
+ DEFAULT_CONFIG_NAME = "pooled" # It's not mandatory to have a default configuration. Just use one if it make sense.
115
+
116
+ def _info(self):
117
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
118
+ features = datasets.Features(
119
+ {
120
+ "query_id": datasets.Value("string"),
121
+ "text": datasets.Value("string")
122
+ }
123
+ )
124
+ return datasets.DatasetInfo(
125
+ # This is the description that will appear on the datasets page.
126
+ description=_DESCRIPTION,
127
+ # This defines the different columns of the dataset and their types
128
+ features=features, # Here we define them above because they are different between the two configurations
129
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
130
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
131
+ # supervised_keys=("sentence", "label"),
132
+ # Homepage of the dataset for documentation
133
+ homepage=_HOMEPAGE,
134
+ # License for the dataset if available
135
+ license=_LICENSE,
136
+ # Citation for the dataset
137
+ citation=_CITATION,
138
+ )
139
+
140
+ def _split_generators(self, dl_manager):
141
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
142
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
143
+
144
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
145
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
146
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
147
+
148
+ _URLS = {
149
+ "forum_dev": _URL[self.config.name] + "forum_dev.jsonl",
150
+ "forum_test": _URL[self.config.name] + "forum_test.jsonl",
151
+ "search_dev": _URL[self.config.name] + "search_dev.jsonl",
152
+ "search_test": _URL[self.config.name] + "search_test.jsonl",
153
+ }
154
+
155
+ downloaded_files = dl_manager.download_and_extract(_URLS)
156
+
157
+ return [
158
+ datasets.SplitGenerator(name="forum_dev", gen_kwargs={"filepath": downloaded_files["forum_dev"]}),
159
+ datasets.SplitGenerator(name="forum_test", gen_kwargs={"filepath": downloaded_files["forum_test"]}),
160
+ datasets.SplitGenerator(name="search_dev", gen_kwargs={"filepath": downloaded_files["search_dev"]}),
161
+ datasets.SplitGenerator(name="search_test", gen_kwargs={"filepath": downloaded_files["search_test"]}),
162
+ ]
163
+
164
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
165
+ def _generate_examples(self, filepath):
166
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
167
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
168
+
169
+ print("Generating examples")
170
+
171
+ with open(filepath, encoding="utf-8") as f:
172
+
173
+ for key, row in enumerate(f):
174
+
175
+ data = json.loads(row)
176
+
177
+ print("Data type and length")
178
+ print(type(data))
179
+ print(len(data))
180
+
181
+ for i in range(0, len(data)):
182
+
183
+ current_query = data[i]
184
+ yield i, {
185
+ "query_id": current_query["query_id"],
186
+ "text": current_query["text"]
187
+ }