Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
1M<n<10M
Source Datasets:
TRex
Lama
ArXiv:
Tags:
License:
Ekin Akyürek commited on
Commit
25109f8
1 Parent(s): 574436c
Files changed (2) hide show
  1. dataset_infos.json +52 -0
  2. ftrace.py +162 -0
dataset_infos.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "abstracts": {
3
+ "description": "Abstracts from TREx dataset",
4
+ "citation": "",
5
+ "homepage": "",
6
+ "license": "",
7
+ "supervised_keys": null,
8
+ "builder_name": "ftrace",
9
+ "config_name": "abstracts",
10
+ "version": {
11
+ "version_str": "0.0.2",
12
+ "description": null,
13
+ "datasets_version_to_prepare": null,
14
+ "major": 0,
15
+ "minor": 0,
16
+ "patch": 2
17
+ },
18
+ "splits": {
19
+ "train": {
20
+ "name": "train",
21
+ "num_bytes": 473823085,
22
+ "num_examples": 1560453,
23
+ "dataset_name": "abstracts"
24
+ }
25
+ }
26
+ },
27
+ "queries": {
28
+ "description": "Queries from TREx dataset",
29
+ "citation": "",
30
+ "homepage": "",
31
+ "license": "",
32
+ "supervised_keys": null,
33
+ "builder_name": "ftrace",
34
+ "config_name": "queries",
35
+ "version": {
36
+ "version_str": "0.0.2",
37
+ "description": null,
38
+ "datasets_version_to_prepare": null,
39
+ "major": 0,
40
+ "minor": 0,
41
+ "patch": 2
42
+ },
43
+ "splits": {
44
+ "train": {
45
+ "name": "train",
46
+ "num_bytes": 5426318,
47
+ "num_examples": 31479,
48
+ "dataset_name": "abstracts"
49
+ }
50
+ }
51
+ }
52
+ }
ftrace.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
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
+ """The FTRACE benchmark."""
18
+
19
+
20
+ import json
21
+ import os
22
+ from multiprocessing.sharedctypes import Value
23
+ import datasets
24
+
25
+
26
+ _FTRACE_CITATION = """\
27
+ """
28
+
29
+ _FTRACE_DESCRIPTION = """\
30
+ Factual Tracing Dataset
31
+ """
32
+
33
+ _FTRACE_ABSTRACTS_DESCRIPTION = """\
34
+ Abstracts based on TREx dataset.
35
+ """
36
+
37
+
38
+ _FTRACE_ABSTRACTS_CITATION = """\
39
+ """
40
+
41
+ _FTRACE_QUERIES_DESCRIPTION = """\
42
+ Queries based on LAMA dataset.
43
+ """
44
+
45
+ _FTRACE_QUERIES_CITATION = """\
46
+ """
47
+
48
+
49
+ class FTRACEConfig(datasets.BuilderConfig):
50
+ """BuilderConfig for FTRACE."""
51
+
52
+ def __init__(
53
+ self,
54
+ features,
55
+ data_url,
56
+ citation,
57
+ url,
58
+ **kwargs,
59
+ ):
60
+ """BuilderConfig for FTRACE.
61
+ Args:
62
+ features: `list[string]`, list of the features that will appear in the
63
+ feature dict. Should not include "label".
64
+ data_url: `string`, url to download the zip file from.
65
+ citation: `string`, citation for the data set.
66
+ url: `string`, url for information about the data set.
67
+ **kwargs: keyword arguments forwarded to super.
68
+ """
69
+ # Version history:
70
+ # 0.0.2: Initial version.
71
+ super(FTRACEConfig, self).__init__(
72
+ version=datasets.Version("0.0.2"), **kwargs
73
+ )
74
+ self.features = features
75
+ self.data_url = data_url
76
+ self.citation = citation
77
+ self.url = url
78
+
79
+
80
+ class FTRACE(datasets.GeneratorBasedBuilder):
81
+ """The SuperFTRACE benchmark."""
82
+
83
+ BUILDER_CONFIGS = [
84
+ FTRACEConfig(
85
+ name="abstracts",
86
+ description=_FTRACE_ABSTRACTS_DESCRIPTION,
87
+ features=[
88
+ "inputs_pretokenized",
89
+ "targets_pretokenized",
90
+ "masked_uri",
91
+ "masked_type",
92
+ "facts",
93
+ "id",
94
+ "example_uris",
95
+ "page_uri",
96
+ ],
97
+ data_url=(
98
+ "https://people.csail.mit.edu/akyurek/ftrace/abstracts.zip"
99
+ ),
100
+ citation=_FTRACE_ABSTRACTS_CITATION,
101
+ url="",
102
+ ),
103
+ FTRACEConfig(
104
+ name="queries",
105
+ description=_FTRACE_QUERIES_DESCRIPTION,
106
+ features=[
107
+ "inputs_pretokenized",
108
+ "targets_pretokenized",
109
+ "uuid",
110
+ "obj_uri",
111
+ "sub_uri",
112
+ "predicate_id",
113
+ "sub_surface",
114
+ "obj_surface",
115
+ ],
116
+ data_url="https://people.csail.mit.edu/akyurek/ftrace/queries.zip",
117
+ citation=_FTRACE_QUERIES_CITATION,
118
+ url="",
119
+ ),
120
+ ]
121
+
122
+ def _info(self):
123
+ features = {
124
+ feature: datasets.Value("string")
125
+ for feature in self.config.features
126
+ }
127
+
128
+ return datasets.DatasetInfo(
129
+ description=_FTRACE_DESCRIPTION + self.config.description,
130
+ features=datasets.Features(features),
131
+ homepage=self.config.url,
132
+ citation=self.config.citation + "\n" + _FTRACE_CITATION,
133
+ )
134
+
135
+ def _split_generators(self, dl_manager):
136
+ dl_dir = dl_manager.download_and_extract(self.config.data_url) or ""
137
+ task_name = _get_task_name_from_data_url(self.config.data_url)
138
+ dl_dir = os.path.join(dl_dir, task_name)
139
+ return [
140
+ datasets.SplitGenerator(
141
+ name=datasets.Split.TRAIN,
142
+ gen_kwargs={
143
+ "data_file": os.path.join(dl_dir, "train.jsonl"),
144
+ "split": "train",
145
+ },
146
+ ),
147
+ ]
148
+
149
+ def _generate_examples(self, data_file, split):
150
+ with open(data_file, encoding="utf-8") as f:
151
+ for idx, line in enumerate(f):
152
+ row = json.loads(line)
153
+ yield idx, row
154
+
155
+
156
+ def _get_task_name_from_data_url(data_url):
157
+ if "queries" in data_url:
158
+ return "queries"
159
+ elif "abstracts" in data_url:
160
+ return "abstracts"
161
+
162
+ return "queries"