Datasets:
Modalities:
Text
Sub-tasks:
masked-language-modeling
Languages:
English
Size:
1M - 10M
ArXiv:
License:
File size: 5,978 Bytes
25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 6c3f9fe 25109f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""The FTRACE benchmark."""
import json
import os
import textwrap
import datasets
_FTRACE_CITATION = """\
"""
_FTRACE_DESCRIPTION = """\
Factual Tracing Dataset that contains queries and abstracts, and their corresponding ground truth.
"""
_FTRACE_ABSTRACTS_DESCRIPTION = """\
Abstracts based on TREx dataset.
"""
_FTRACE_ABSTRACTS_LICENSE = """\
Creative Commons Attribution-ShareAlike 4.0 International License.
see https://creativecommons.org/licenses/by-sa/4.0/"""
_FTRACE_ABSTRACTS_CITATION = """\
@inproceedings{elsahar2018t,
title={T-rex: A large scale alignment of natural language with knowledge base triples},
author={Elsahar, Hady and Vougiouklis, Pavlos and Remaci, Arslen and Gravier, Christophe and Hare, Jonathon and Laforest, Frederique and Simperl, Elena},
booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018)},
year={2018}
}"""
_FTRACE_QUERIES_DESCRIPTION = """\
Queries based on LAMA dataset.
"""
_FTRACE_QUERIES_CITATION = """\
@inproceedings{petroni2019language,
title={Language Models as Knowledge Bases?},
author={F. Petroni, T. Rockt{\"{a}}schel, A. H. Miller, P. Lewis, A. Bakhtin, Y. Wu and S. Riedel},
booktitle={In: Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2019},
year={2019}
}"""
FTRACE_QUERIES_LICENSE = """\
The Creative Commons Attribution-Noncommercial 4.0 International License.
see https://github.com/facebookresearch/LAMA/blob/master/LICENSE"""
class FTRACEConfig(datasets.BuilderConfig):
"""BuilderConfig for FTRACE."""
def __init__(
self,
features,
data_url,
citation,
license,
url,
**kwargs,
):
"""BuilderConfig for FTRACE.
Args:
features: `list[string]`, list of the features that will appear in the
feature dict. Should not include "label".
data_url: `string`, url to download the zip file from.
citation: `string`, citation for the data set.
url: `string`, url for information about the data set.
**kwargs: keyword arguments forwarded to super.
"""
# Version history:
# 0.0.2: Initial version.
super(FTRACEConfig, self).__init__(
version=datasets.Version("0.0.2"), **kwargs
)
self.features = features
self.data_url = data_url
self.citation = citation
self.license = license
self.url = url
class FTRACE(datasets.GeneratorBasedBuilder):
"""The SuperFTRACE benchmark."""
BUILDER_CONFIGS = [
FTRACEConfig(
name="abstracts",
description=_FTRACE_ABSTRACTS_DESCRIPTION,
features=[
"inputs_pretokenized",
"targets_pretokenized",
"masked_uri",
"masked_type",
"facts",
"id",
"example_uris",
"page_uri",
],
data_url="https://people.csail.mit.edu/akyurek/ftrace/abstracts.zip",
citation=textwrap.dedent(_FTRACE_ABSTRACTS_CITATION),
license=_FTRACE_ABSTRACTS_LICENSE,
url="https://hadyelsahar.github.io/t-rex/",
),
FTRACEConfig(
name="queries",
description=_FTRACE_QUERIES_DESCRIPTION,
features=[
"inputs_pretokenized",
"targets_pretokenized",
"uuid",
"obj_uri",
"sub_uri",
"predicate_id",
"sub_surface",
"obj_surface",
],
data_url="https://people.csail.mit.edu/akyurek/ftrace/queries.zip",
citation=textwrap.dedent(_FTRACE_QUERIES_CITATION),
license=FTRACE_QUERIES_LICENSE,
url="https://github.com/facebookresearch/LAMA",
),
]
def _info(self):
features = {
feature: datasets.Value("string")
for feature in self.config.features
}
return datasets.DatasetInfo(
description=_FTRACE_DESCRIPTION + self.config.description,
features=datasets.Features(features),
homepage=self.config.url,
citation=self.config.citation + "\n" + _FTRACE_CITATION,
)
def _split_generators(self, dl_manager):
dl_dir = dl_manager.download_and_extract(self.config.data_url) or ""
task_name = _get_task_name_from_data_url(self.config.data_url)
dl_dir = os.path.join(dl_dir, task_name)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"data_file": os.path.join(dl_dir, "train.jsonl"),
"split": "train",
},
),
]
def _generate_examples(self, data_file, split):
with open(data_file, encoding="utf-8") as f:
for idx, line in enumerate(f):
row = json.loads(line)
yield idx, row
def _get_task_name_from_data_url(data_url):
if "queries" in data_url:
return "queries"
elif "abstracts" in data_url:
return "abstracts"
return "queries"
|