piotr-rybak commited on
Commit
d6ee042
1 Parent(s): 23f40ca

add passages

Browse files
.gitattributes CHANGED
@@ -54,3 +54,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
  test.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
  test.csv filter=lfs diff=lfs merge=lfs -text
57
+ data/passages.jsonl filter=lfs diff=lfs merge=lfs -text
58
+ data/test.csv filter=lfs diff=lfs merge=lfs -text
allegro-faq.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ import csv
17
+ import json
18
+
19
+ import datasets
20
+
21
+
22
+ _CITATION = """\
23
+ """
24
+
25
+ _DESCRIPTION = """\
26
+ Allegro FAQ is a dataset for evaluating passage retrievers.
27
+ """
28
+
29
+ _HOMEPAGE = ""
30
+
31
+ _LICENSE = ""
32
+
33
+ _FEATURES_PAIRS = datasets.Features(
34
+ {
35
+ "question_id": datasets.Value("int32"),
36
+ "question": datasets.Value("string"),
37
+ "passage_id": datasets.Value("string"),
38
+ "answers": datasets.Value("string"),
39
+ "passage_title": datasets.Value("string"),
40
+ "passage_text": datasets.Value("string"),
41
+ "relevant": datasets.Value("bool"),
42
+ }
43
+ )
44
+
45
+ _FEATURES_PASSAGES = datasets.Features(
46
+ {
47
+ "id": datasets.Value("string"),
48
+ "title": datasets.Value("string"),
49
+ "text": datasets.Value("string"),
50
+ }
51
+ )
52
+
53
+ _URLS = {
54
+ "pairs": {
55
+ "test": ["data/test.csv"],
56
+ },
57
+ "passages": {
58
+ "test": ["data/passages.jsonl"],
59
+ },
60
+ }
61
+
62
+
63
+ class AllegroFAQ(datasets.GeneratorBasedBuilder):
64
+ """Allegro FAQ is a dataset for evaluating passage retrievers. """
65
+
66
+ BUILDER_CONFIGS = list(map(lambda x: datasets.BuilderConfig(name=x, version=datasets.Version("1.0.0")), _URLS.keys()))
67
+ DEFAULT_CONFIG_NAME = "pairs"
68
+
69
+ def _info(self):
70
+ if self.config.name == "pairs":
71
+ features = _FEATURES_PAIRS
72
+ else:
73
+ features = _FEATURES_PASSAGES
74
+
75
+ return datasets.DatasetInfo(
76
+ description=_DESCRIPTION,
77
+ features=features,
78
+ homepage=_HOMEPAGE,
79
+ license=_LICENSE,
80
+ citation=_CITATION,
81
+ )
82
+
83
+ def _split_generators(self, dl_manager):
84
+ urls = _URLS[self.config.name]
85
+ data_dir = dl_manager.download_and_extract(urls)
86
+ return [
87
+ datasets.SplitGenerator(
88
+ name=datasets.Split.TEST,
89
+ gen_kwargs={
90
+ "filepaths": data_dir["test"],
91
+ },
92
+ ),
93
+ ]
94
+
95
+ @staticmethod
96
+ def _parse_bool(text):
97
+ if text == 'True':
98
+ return True
99
+ elif text == 'False':
100
+ return False
101
+ else:
102
+ raise ValueError
103
+
104
+ def _generate_examples(self, filepaths):
105
+ if self.config.name == "pairs":
106
+ boolean_features = [name for name, val in _FEATURES_PAIRS.items() if val.dtype == "bool"]
107
+
108
+ for filepath in filepaths:
109
+ with open(filepath, encoding="utf-8") as f:
110
+ data = csv.DictReader(f)
111
+ for i, row in enumerate(data):
112
+ for boolean_feature in boolean_features:
113
+ row[boolean_feature] = self._parse_bool(row[boolean_feature])
114
+ yield i, row
115
+ else:
116
+ for filepath in filepaths:
117
+ with open(filepath, encoding="utf-8") as f:
118
+ for i, row in enumerate(f):
119
+ print(row)
120
+ parsed_row = json.loads(row)
121
+ yield i, parsed_row
data/passages.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0a9a4a1838a93ad9d909c5a9c6cccda98bfedb248d03d87e2937c9559ea0555
3
+ size 369789
test.csv → data/test.csv RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:86f7ebabc6d1ba6bb15de3652c4b9d9b30468476f625ceba7d2436f4ae60a24b
3
- size 423822
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fab4d963db7e57469c2f8c287695ac4995ea41165da8ff37f5b744638b93e0c
3
+ size 427561