Commit
·
97d2c88
0
Parent(s):
Update files from the datasets library (from 1.0.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.0.0
- .gitattributes +27 -0
- dataset_infos.json +1 -0
- dummy/0.1.0/dummy_data.zip +3 -0
- qasc.py +115 -0
.gitattributes
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"default": {"description": "\nQASC is a question-answering dataset with a focus on sentence composition. It consists of 9,980 8-way multiple-choice \nquestions about grade school science (8,134 train, 926 dev, 920 test), and comes with a corpus of 17M sentences.\n", "citation": "@article{allenai:qasc,\n author = {Tushar Khot and Peter Clark and Michal Guerquin and Peter Jansen and Ashish Sabharwal},\n title = {QASC: A Dataset for Question Answering via Sentence Composition},\n journal = {arXiv:1910.11473v2},\n year = {2020},\n}\n", "homepage": "https://allenai.org/data/qasc", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "choices": {"feature": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "answerKey": {"dtype": "string", "id": null, "_type": "Value"}, "fact1": {"dtype": "string", "id": null, "_type": "Value"}, "fact2": {"dtype": "string", "id": null, "_type": "Value"}, "combinedfact": {"dtype": "string", "id": null, "_type": "Value"}, "formatted_question": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "qasc", "config_name": "default", "version": {"version_str": "0.1.0", "description": null, "datasets_version_to_prepare": null, "major": 0, "minor": 1, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 393683, "num_examples": 920, "dataset_name": "qasc"}, "train": {"name": "train", "num_bytes": 4919377, "num_examples": 8134, "dataset_name": "qasc"}, "validation": {"name": "validation", "num_bytes": 562352, "num_examples": 926, "dataset_name": "qasc"}}, "download_checksums": {"http://data.allenai.org/downloads/qasc/qasc_dataset.tar.gz": {"num_bytes": 1616514, "checksum": "a7b3f2244f768974c609fd621346c931a72715609f171cb5544fc1da2a2ad55c"}}, "download_size": 1616514, "dataset_size": 5875412, "size_in_bytes": 7491926}}
|
dummy/0.1.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19282b8004914c942e33e4da11227b3010552cc931b383c5bc59751c262db1d7
|
| 3 |
+
size 2427
|
qasc.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""TODO(qasc): Add a description here."""
|
| 2 |
+
|
| 3 |
+
from __future__ import absolute_import, division, print_function
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
import datasets
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# TODO(qasc): BibTeX citation
|
| 12 |
+
_CITATION = """\
|
| 13 |
+
@article{allenai:qasc,
|
| 14 |
+
author = {Tushar Khot and Peter Clark and Michal Guerquin and Peter Jansen and Ashish Sabharwal},
|
| 15 |
+
title = {QASC: A Dataset for Question Answering via Sentence Composition},
|
| 16 |
+
journal = {arXiv:1910.11473v2},
|
| 17 |
+
year = {2020},
|
| 18 |
+
}
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
# TODO(qasc):
|
| 22 |
+
_DESCRIPTION = """
|
| 23 |
+
QASC is a question-answering dataset with a focus on sentence composition. It consists of 9,980 8-way multiple-choice
|
| 24 |
+
questions about grade school science (8,134 train, 926 dev, 920 test), and comes with a corpus of 17M sentences.
|
| 25 |
+
"""
|
| 26 |
+
_URl = "http://data.allenai.org/downloads/qasc/qasc_dataset.tar.gz"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class Qasc(datasets.GeneratorBasedBuilder):
|
| 30 |
+
"""TODO(qasc): Short description of my dataset."""
|
| 31 |
+
|
| 32 |
+
# TODO(qasc): Set up version.
|
| 33 |
+
VERSION = datasets.Version("0.1.0")
|
| 34 |
+
|
| 35 |
+
def _info(self):
|
| 36 |
+
# TODO(qasc): Specifies the datasets.DatasetInfo object
|
| 37 |
+
return datasets.DatasetInfo(
|
| 38 |
+
# This is the description that will appear on the datasets page.
|
| 39 |
+
description=_DESCRIPTION,
|
| 40 |
+
# datasets.features.FeatureConnectors
|
| 41 |
+
features=datasets.Features(
|
| 42 |
+
{
|
| 43 |
+
"id": datasets.Value("string"),
|
| 44 |
+
"question": datasets.Value("string"),
|
| 45 |
+
"choices": datasets.features.Sequence(
|
| 46 |
+
{"text": datasets.Value("string"), "label": datasets.Value("string")}
|
| 47 |
+
),
|
| 48 |
+
"answerKey": datasets.Value("string"),
|
| 49 |
+
"fact1": datasets.Value("string"),
|
| 50 |
+
"fact2": datasets.Value("string"),
|
| 51 |
+
"combinedfact": datasets.Value("string"),
|
| 52 |
+
"formatted_question": datasets.Value("string"),
|
| 53 |
+
# These are the features of your dataset like images, labels ...
|
| 54 |
+
}
|
| 55 |
+
),
|
| 56 |
+
# If there's a common (input, target) tuple from the features,
|
| 57 |
+
# specify them here. They'll be used if as_supervised=True in
|
| 58 |
+
# builder.as_dataset.
|
| 59 |
+
supervised_keys=None,
|
| 60 |
+
# Homepage of the dataset for documentation
|
| 61 |
+
homepage="https://allenai.org/data/qasc",
|
| 62 |
+
citation=_CITATION,
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
def _split_generators(self, dl_manager):
|
| 66 |
+
"""Returns SplitGenerators."""
|
| 67 |
+
# TODO(qasc): Downloads the data and defines the splits
|
| 68 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to
|
| 69 |
+
# download and extract URLs
|
| 70 |
+
dl_dir = dl_manager.download_and_extract(_URl)
|
| 71 |
+
data_dir = os.path.join(dl_dir, "QASC_Dataset")
|
| 72 |
+
return [
|
| 73 |
+
datasets.SplitGenerator(
|
| 74 |
+
name=datasets.Split.TRAIN,
|
| 75 |
+
# These kwargs will be passed to _generate_examples
|
| 76 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "train.jsonl")},
|
| 77 |
+
),
|
| 78 |
+
datasets.SplitGenerator(
|
| 79 |
+
name=datasets.Split.TEST,
|
| 80 |
+
# These kwargs will be passed to _generate_examples
|
| 81 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl")},
|
| 82 |
+
),
|
| 83 |
+
datasets.SplitGenerator(
|
| 84 |
+
name=datasets.Split.VALIDATION,
|
| 85 |
+
# These kwargs will be passed to _generate_examples
|
| 86 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "dev.jsonl")},
|
| 87 |
+
),
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
def _generate_examples(self, filepath):
|
| 91 |
+
"""Yields examples."""
|
| 92 |
+
# TODO(qasc): Yields (key, example) tuples from the dataset
|
| 93 |
+
with open(filepath, encoding="utf-8") as f:
|
| 94 |
+
for row in f:
|
| 95 |
+
data = json.loads(row)
|
| 96 |
+
answerkey = data.get("answerKey", "")
|
| 97 |
+
id_ = data["id"]
|
| 98 |
+
question = data["question"]["stem"]
|
| 99 |
+
choices = data["question"]["choices"]
|
| 100 |
+
text_choices = [choice["text"] for choice in choices]
|
| 101 |
+
label_choices = [choice["label"] for choice in choices]
|
| 102 |
+
fact1 = data.get("fact1", "")
|
| 103 |
+
fact2 = data.get("fact2", "")
|
| 104 |
+
combined_fact = data.get("combinedfact", "")
|
| 105 |
+
formatted_question = data.get("formatted_question", "")
|
| 106 |
+
yield id_, {
|
| 107 |
+
"id": id_,
|
| 108 |
+
"answerKey": answerkey,
|
| 109 |
+
"question": question,
|
| 110 |
+
"choices": {"text": text_choices, "label": label_choices},
|
| 111 |
+
"fact1": fact1,
|
| 112 |
+
"fact2": fact2,
|
| 113 |
+
"combinedfact": combined_fact,
|
| 114 |
+
"formatted_question": formatted_question,
|
| 115 |
+
}
|