Datasets:
Tasks:
Question Answering
Modalities:
Text
Languages:
English
Size:
1K - 10K
Tags:
knowledge-base-qa
License:
# 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 SciQA Scientific Question Answering Benchmark for Scholarly Knowledge""" | |
import json | |
import os | |
import datasets | |
logger = datasets.logging.get_logger(__name__) | |
_CITATION = """ | |
@Article{SciQA2023, | |
author={Auer, S{\"o}ren | |
and Barone, Dante A. C. | |
and Bartz, Cassiano | |
and Cortes, Eduardo G. | |
and Jaradeh, Mohamad Yaser | |
and Karras, Oliver | |
and Koubarakis, Manolis | |
and Mouromtsev, Dmitry | |
and Pliukhin, Dmitrii | |
and Radyush, Daniil | |
and Shilin, Ivan | |
and Stocker, Markus | |
and Tsalapati, Eleni}, | |
title={The SciQA Scientific Question Answering Benchmark for Scholarly Knowledge}, | |
journal={Scientific Reports}, | |
year={2023}, | |
month={May}, | |
day={04}, | |
volume={13}, | |
number={1}, | |
pages={7240}, | |
abstract={Knowledge graphs have gained increasing popularity in the last decade in science and technology. However, knowledge graphs are currently relatively simple to moderate semantic structures that are mainly a collection of factual statements. Question answering (QA) benchmarks and systems were so far mainly geared towards encyclopedic knowledge graphs such as DBpedia and Wikidata. We present SciQA a scientific QA benchmark for scholarly knowledge. The benchmark leverages the Open Research Knowledge Graph (ORKG) which includes almost 170,000 resources describing research contributions of almost 15,000 scholarly articles from 709 research fields. Following a bottom-up methodology, we first manually developed a set of 100 complex questions that can be answered using this knowledge graph. Furthermore, we devised eight question templates with which we automatically generated further 2465 questions, that can also be answered with the ORKG. The questions cover a range of research fields and question types and are translated into corresponding SPARQL queries over the ORKG. Based on two preliminary evaluations, we show that the resulting SciQA benchmark represents a challenging task for next-generation QA systems. This task is part of the open competitions at the 22nd International Semantic Web Conference 2023 as the Scholarly Question Answering over Linked Data (QALD) Challenge.}, | |
issn={2045-2322}, | |
doi={10.1038/s41598-023-33607-z}, | |
url={https://doi.org/10.1038/s41598-023-33607-z} | |
} | |
""" | |
_DESCRIPTION = """\ | |
SciQA contains 2,565 SPARQL query - question pairs along with answers fetched from the open research knowledge graph (ORKG) \ | |
via a Virtuoso SPARQL endpoint, it is a collection of both handcrafted and autogenerated questions and queries. \ | |
The dataset is split into 70% training, 10% validation and 20% test examples. The dataset is available as JSON files. | |
""" | |
_URL = "https://zenodo.org/record/7744048/files/SciQA-dataset.zip" | |
class SciQA(datasets.GeneratorBasedBuilder): | |
""" | |
The SciQA Scientific Question Answering Benchmark for Scholarly Knowledge. | |
""" | |
VERSION = datasets.Version("1.0.2") | |
def _info(self): | |
return datasets.DatasetInfo( | |
# This is the description that will appear on the datasets page. | |
description=_DESCRIPTION, | |
# datasets.features.FeatureConnectors | |
features=datasets.Features( | |
{ | |
"id": datasets.Value("string"), | |
"query_type": datasets.Value("string"), | |
"question": datasets.dataset_dict.DatasetDict({ | |
"string": datasets.Value("string") | |
}), | |
"paraphrased_question": datasets.features.Sequence(datasets.Value("string")), | |
"query": datasets.dataset_dict.DatasetDict({ | |
"sparql": datasets.Value("string") | |
}), | |
"template_id": datasets.Value("string"), | |
"query_shape": datasets.Value("string"), | |
"query_class": datasets.Value("string"), | |
"auto_generated": datasets.Value("bool"), | |
"number_of_patterns": datasets.Value("int32") | |
} | |
), | |
supervised_keys=None, | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
"""Returns SplitGenerators.""" | |
dl_dir = dl_manager.download_and_extract(_URL) | |
dl_dir = os.path.join(dl_dir, "SciQA-dataset") | |
return [ | |
datasets.SplitGenerator( | |
name=datasets.Split.TRAIN, | |
gen_kwargs={"filepath": os.path.join(dl_dir, "train", "questions.json")}, | |
), | |
datasets.SplitGenerator( | |
name=datasets.Split.VALIDATION, | |
gen_kwargs={"filepath": os.path.join(dl_dir, "valid", "questions.json")}, | |
), | |
datasets.SplitGenerator( | |
name=datasets.Split.TEST, | |
gen_kwargs={"filepath": os.path.join(dl_dir, "test", "questions.json")}, | |
), | |
] | |
def _generate_examples(self, filepath): | |
"""Yields examples.""" | |
with open(filepath, encoding="utf-8") as f: | |
questions_data = json.load(f)["questions"] | |
for id_, row in enumerate(questions_data): | |
yield id_, { | |
"id": row["id"], | |
"query_type": row["query_type"], | |
"question": row["question"], | |
"paraphrased_question": row["paraphrased_question"], | |
"query": row["query"], | |
"template_id": row["template_id"], | |
"query_shape": row["query_shape"], | |
"query_class": row["query_class"], | |
"auto_generated": row["auto_generated"], | |
"number_of_patterns": row["number_of_patterns"] | |
} | |