Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
crowdsourced
Annotations Creators:
crowdsourced
ArXiv:
Tags:
License:
albertvillanova HF staff commited on
Commit
f013965
1 Parent(s): 7f101e0

Convert dataset to Parquet (#2)

Browse files

- Convert dataset to Parquet (87e8984046c31494c333ce70a42fe21030c80145)
- Add v1.11 data files (247d103b79d6864fe83c12f22f835a1f9dbe3bdb)
- Delete loading script (29e6cddebca610ae13b9dda57f429698d194f662)
- Delete legacy dataset_infos.json (ffddb2648342eaa29b8bd958852a845b2ec008ed)

README.md CHANGED
@@ -1,15 +1,14 @@
1
  ---
2
  annotations_creators:
3
  - crowdsourced
4
- language:
5
- - en
6
  language_creators:
7
  - crowdsourced
 
 
8
  license:
9
  - unknown
10
  multilinguality:
11
  - monolingual
12
- pretty_name: Commonsense Explanations
13
  size_categories:
14
  - 10K<n<100K
15
  source_datasets:
@@ -19,6 +18,7 @@ task_categories:
19
  task_ids:
20
  - open-domain-qa
21
  paperswithcode_id: cos-e
 
22
  dataset_info:
23
  - config_name: v1.0
24
  features:
@@ -36,13 +36,13 @@ dataset_info:
36
  dtype: string
37
  splits:
38
  - name: train
39
- num_bytes: 2077517
40
  num_examples: 7610
41
  - name: validation
42
- num_bytes: 261887
43
  num_examples: 950
44
- download_size: 4295320
45
- dataset_size: 2339404
46
  - config_name: v1.11
47
  features:
48
  - name: id
@@ -59,13 +59,26 @@ dataset_info:
59
  dtype: string
60
  splits:
61
  - name: train
62
- num_bytes: 2717420
63
  num_examples: 9741
64
  - name: validation
65
- num_bytes: 331760
66
  num_examples: 1221
67
- download_size: 6535534
68
- dataset_size: 3049180
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  ---
70
 
71
  # Dataset Card for "cos_e"
1
  ---
2
  annotations_creators:
3
  - crowdsourced
 
 
4
  language_creators:
5
  - crowdsourced
6
+ language:
7
+ - en
8
  license:
9
  - unknown
10
  multilinguality:
11
  - monolingual
 
12
  size_categories:
13
  - 10K<n<100K
14
  source_datasets:
18
  task_ids:
19
  - open-domain-qa
20
  paperswithcode_id: cos-e
21
+ pretty_name: Commonsense Explanations
22
  dataset_info:
23
  - config_name: v1.0
24
  features:
36
  dtype: string
37
  splits:
38
  - name: train
39
+ num_bytes: 2067971
40
  num_examples: 7610
41
  - name: validation
42
+ num_bytes: 260669
43
  num_examples: 950
44
+ download_size: 1588340
45
+ dataset_size: 2328640
46
  - config_name: v1.11
47
  features:
48
  - name: id
59
  dtype: string
60
  splits:
61
  - name: train
62
+ num_bytes: 2702777
63
  num_examples: 9741
64
  - name: validation
65
+ num_bytes: 329897
66
  num_examples: 1221
67
+ download_size: 1947552
68
+ dataset_size: 3032674
69
+ configs:
70
+ - config_name: v1.0
71
+ data_files:
72
+ - split: train
73
+ path: v1.0/train-*
74
+ - split: validation
75
+ path: v1.0/validation-*
76
+ - config_name: v1.11
77
+ data_files:
78
+ - split: train
79
+ path: v1.11/train-*
80
+ - split: validation
81
+ path: v1.11/validation-*
82
  ---
83
 
84
  # Dataset Card for "cos_e"
cos_e.py DELETED
@@ -1,194 +0,0 @@
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
- """Commonsense Explanations (CoS-E) Dataset."""
18
-
19
-
20
- import json
21
-
22
- import datasets
23
-
24
-
25
- _CITATION = """
26
- @inproceedings{rajani2019explain,
27
- title = {Explain Yourself! Leveraging Language models for Commonsense Reasoning},
28
- author = {Rajani, Nazneen Fatema and
29
- McCann, Bryan and
30
- Xiong, Caiming and
31
- Socher, Richard}
32
- year={2019}
33
- booktitle = {Proceedings of the 2019 Conference of the Association for Computational Linguistics (ACL2019)}
34
- url ={https://arxiv.org/abs/1906.02361}
35
- }
36
- """
37
-
38
- _DESCRIPTION = """
39
- Common Sense Explanations (CoS-E) allows for training language models to
40
- automatically generate explanations that can be used during training and
41
- inference in a novel Commonsense Auto-Generated Explanation (CAGE) framework.
42
- """
43
-
44
- _COS_E_URL = "https://raw.githubusercontent.com/salesforce/cos-e/master/data/"
45
-
46
- # COS E has explanations for the CQA dataset, which is joined by ID.
47
- _CQA_V1_11_URL_TRAIN = "https://s3.amazonaws.com/commensenseqa/train_rand_split.jsonl"
48
- _CQA_V1_11_URL_DEV = "https://s3.amazonaws.com/commensenseqa/dev_rand_split.jsonl"
49
- _CQA_V1_11_URL_TEST = "https://s3.amazonaws.com/commensenseqa/test_rand_split_no_answers.jsonl"
50
-
51
- _CQA_V1_0_URL_TRAIN = _COS_E_URL + "v1.0/train_rand_split.jsonl"
52
- _CQA_V1_0_URL_DEV = _COS_E_URL + "v1.0/dev_rand_split.jsonl"
53
- _CQA_V1_0_URL_TEST = _COS_E_URL + "v1.0/test_rand_split_no_answers.jsonl"
54
-
55
-
56
- def _download_and_index_cqa(dl_manager, name):
57
- """Downloads CQA and returns it, indexed by id, for joining with Cos-E."""
58
-
59
- downloaded_files = dl_manager.download_and_extract(
60
- {
61
- "cqa_train": _CQA_V1_11_URL_TRAIN if name == "v1.11" else _CQA_V1_0_URL_TRAIN,
62
- "cqa_dev": _CQA_V1_11_URL_DEV if name == "v1.11" else _CQA_V1_0_URL_DEV,
63
- "cqa_test": _CQA_V1_11_URL_TEST if name == "v1.11" else _CQA_V1_0_URL_TEST,
64
- }
65
- )
66
-
67
- # NB: "cqa_test" is included in the files, but not in any of the CoS-E splits.
68
- cqa_splits = ["cqa_train", "cqa_dev"]
69
- cqa_complete = []
70
- for split in cqa_splits:
71
- with open(downloaded_files[split], encoding="utf-8") as f:
72
- for _, line in enumerate(f):
73
- d = json.loads(line)
74
- cqa_complete.append(d)
75
-
76
- # Index the CQA dataset by id for joining with Cos-E.
77
- cqa_indexed = {}
78
- for d in cqa_complete:
79
- cqa_indexed[d["id"]] = d
80
- return cqa_indexed
81
-
82
-
83
- def _get_choices_and_answer(cqa):
84
- """Returns choices and the answer from a cqa example."""
85
- choices = []
86
- answer_key = cqa["answerKey"]
87
- answer = None
88
- for choice in cqa["question"]["choices"]:
89
- choices.append(choice["text"])
90
- if answer_key == choice["label"]:
91
- answer = choice["text"]
92
- return choices, answer
93
-
94
-
95
- class CosEConfig(datasets.BuilderConfig):
96
-
97
- """BuilderConfig for CosE"""
98
-
99
- def __init__(self, **kwargs):
100
- """
101
-
102
- Args:
103
- **kwargs: keyword arguments forwarded to super.
104
- """
105
- super(CosEConfig, self).__init__(**kwargs)
106
-
107
-
108
- class CosE(datasets.GeneratorBasedBuilder):
109
- """CoS-E: Common Sense Explanations corpus."""
110
-
111
- BUILDER_CONFIGS = [
112
- CosEConfig(
113
- name="v1.0",
114
- description="cos-e version 1.0",
115
- version=datasets.Version("1.0.0", ""),
116
- ),
117
- CosEConfig(
118
- name="v1.11",
119
- description="cos-e version 1.11",
120
- version=datasets.Version("1.11.0", ""),
121
- ),
122
- ]
123
-
124
- def _info(self):
125
- return datasets.DatasetInfo(
126
- description=_DESCRIPTION,
127
- features=datasets.Features(
128
- {
129
- "id": datasets.Value("string"),
130
- "question": datasets.Value("string"),
131
- "choices": datasets.features.Sequence(datasets.Value("string")),
132
- "answer": datasets.Value("string"),
133
- "abstractive_explanation": datasets.Value("string"),
134
- "extractive_explanation": datasets.Value("string"),
135
- }
136
- ),
137
- supervised_keys=None,
138
- homepage="https://github.com/salesforce/cos-e",
139
- citation=_CITATION,
140
- )
141
-
142
- def _split_generators(self, dl_manager):
143
- """Returns SplitGenerators."""
144
-
145
- # NB: The CQA Dataset should be read only once, and only by callers who
146
- # want to _create_ the Cos-E dataset from scratch.
147
- cqa_indexed = _download_and_index_cqa(dl_manager, self.config.name)
148
-
149
- if self.config.name == "v1.11":
150
- files = dl_manager.download_and_extract(
151
- {
152
- "dev": [_COS_E_URL + "v1.11/cose_dev_v1.11_processed.jsonl"],
153
- "train": [_COS_E_URL + "v1.11/cose_train_v1.11_processed.jsonl"],
154
- }
155
- )
156
-
157
- elif self.config.name == "v1.0":
158
- files = dl_manager.download_and_extract(
159
- {
160
- "dev": [_COS_E_URL + "v1.0/cose_dev_v1.0_processed.jsonl"],
161
- "train": [_COS_E_URL + "v1.0/cose_train_v1.0_processed.jsonl"],
162
- }
163
- )
164
- else:
165
- raise ValueError("Unknown config name")
166
- # We use the CoS-E/CQA dev set as our validation set.
167
- return [
168
- datasets.SplitGenerator(
169
- name=datasets.Split.TRAIN,
170
- gen_kwargs={"files": files["train"], "cqa_indexed": cqa_indexed},
171
- ),
172
- datasets.SplitGenerator(
173
- name=datasets.Split.VALIDATION,
174
- gen_kwargs={"files": files["dev"], "cqa_indexed": cqa_indexed},
175
- ),
176
- ]
177
-
178
- def _generate_examples(self, files, **kwargs):
179
- """Yields examples."""
180
- cqa_indexed = kwargs["cqa_indexed"]
181
- for filepath in files:
182
- with open(filepath, encoding="utf-8") as f:
183
- for line in f:
184
- cos = json.loads(line)
185
- cqa = cqa_indexed[cos["id"]]
186
- choices, answer = _get_choices_and_answer(cqa)
187
- yield cos["id"], {
188
- "id": cos["id"],
189
- "question": cqa["question"]["stem"],
190
- "choices": choices,
191
- "answer": answer,
192
- "abstractive_explanation": cos["explanation"]["open-ended"],
193
- "extractive_explanation": cos["explanation"]["selected"],
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dataset_infos.json DELETED
@@ -1 +0,0 @@
1
- {"v1.0": {"description": "\nCommon Sense Explanations (CoS-E) allows for training language models to\nautomatically generate explanations that can be used during training and\ninference in a novel Commonsense Auto-Generated Explanation (CAGE) framework.\n", "citation": "\n@inproceedings{rajani2019explain,\n title = \"Explain Yourself! Leveraging Language models for Commonsense Reasoning\",\n author = \"Rajani, Nazneen Fatema and\n McCann, Bryan and\n Xiong, Caiming and\n Socher, Richard\",\n year=\"2019\",\n booktitle = \"Proceedings of the 2019 Conference of the Association for Computational Linguistics (ACL2019)\",\n url =\"https://arxiv.org/abs/1906.02361\"\n}\n", "homepage": "https://github.com/salesforce/cos-e", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "choices": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}, "abstractive_explanation": {"dtype": "string", "id": null, "_type": "Value"}, "extractive_explanation": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "cos_e", "config_name": "v1.0", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2077517, "num_examples": 7610, "dataset_name": "cos_e"}, "validation": {"name": "validation", "num_bytes": 261887, "num_examples": 950, "dataset_name": "cos_e"}}, "download_checksums": {"https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.0/train_rand_split.jsonl": {"num_bytes": 2160200, "checksum": "1989ce97e24d8572113d6a18f44e0f11ee9d206fb9bf9a1133937645583e697e"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.0/dev_rand_split.jsonl": {"num_bytes": 268531, "checksum": "790dd2a8492e7f3b51ded04116de603115b7acaded32ea84f6a7101f9d571ac1"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.0/test_rand_split_no_answers.jsonl": {"num_bytes": 250752, "checksum": "b9c3d1319667ea1569be6f7b3ed0546bd8222d2f3a759f928307343a0282e190"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.0/cose_dev_v1.0_processed.jsonl": {"num_bytes": 182444, "checksum": "ab7b8ac91bca1a6ba798816af6aca703a739f576c919360ddc376d9d3046be53"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.0/cose_train_v1.0_processed.jsonl": {"num_bytes": 1433393, "checksum": "df9f83ac4891f38e0771470858d5f1c4b5bb08fee5c53f38f9df9b3d3675ea74"}}, "download_size": 4295320, "dataset_size": 2339404, "size_in_bytes": 6634724}, "v1.11": {"description": "\nCommon Sense Explanations (CoS-E) allows for training language models to\nautomatically generate explanations that can be used during training and\ninference in a novel Commonsense Auto-Generated Explanation (CAGE) framework.\n", "citation": "\n@inproceedings{rajani2019explain,\n title = \"Explain Yourself! Leveraging Language models for Commonsense Reasoning\",\n author = \"Rajani, Nazneen Fatema and\n McCann, Bryan and\n Xiong, Caiming and\n Socher, Richard\",\n year=\"2019\",\n booktitle = \"Proceedings of the 2019 Conference of the Association for Computational Linguistics (ACL2019)\",\n url =\"https://arxiv.org/abs/1906.02361\"\n}\n", "homepage": "https://github.com/salesforce/cos-e", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "choices": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}, "abstractive_explanation": {"dtype": "string", "id": null, "_type": "Value"}, "extractive_explanation": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "cos_e", "config_name": "v1.11", "version": {"version_str": "1.11.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 11, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2717420, "num_examples": 9741, "dataset_name": "cos_e"}, "validation": {"name": "validation", "num_bytes": 331760, "num_examples": 1221, "dataset_name": "cos_e"}}, "download_checksums": {"https://s3.amazonaws.com/commensenseqa/train_rand_split.jsonl": {"num_bytes": 3785890, "checksum": "58ffa3c8472410e24b8c43f423d89c8a003d8284698a6ed7874355dedd09a2fb"}, "https://s3.amazonaws.com/commensenseqa/dev_rand_split.jsonl": {"num_bytes": 471653, "checksum": "3210497fdaae614ac085d9eb873dd7f4d49b6f965a93adadc803e1229fd8a02a"}, "https://s3.amazonaws.com/commensenseqa/test_rand_split_no_answers.jsonl": {"num_bytes": 423148, "checksum": "b426896d71a9cd064cf01cfaf6e920817c51701ef66028883ac1af2e73ad5f29"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.11/cose_dev_v1.11_processed.jsonl": {"num_bytes": 200867, "checksum": "a8367c94901ba249e48bcec76eaff9e7b91cec0f0e4d94879975d7d1b952bc41"}, "https://raw.githubusercontent.com/salesforce/cos-e/master/data/v1.11/cose_train_v1.11_processed.jsonl": {"num_bytes": 1653976, "checksum": "4c0ccfd34243cf7af62b441643437769663edcb980b991487f766b97a547e9bd"}}, "download_size": 6535534, "dataset_size": 3049180, "size_in_bytes": 9584714}}
 
v1.0/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78b636e41d4b441b70538731126de971899ae20b0b32daf8661b9f001596b3fc
3
+ size 1412087
v1.0/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c80c680e8cdc17f6b7a37064d1a6d46e3b4e5c95701ab37570129b366c523b9c
3
+ size 176253
v1.11/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a03cc8f4ae917b0939c5ad35805f407e21cd68e8c046fe90db64001b1d73f16c
3
+ size 1725248
v1.11/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:045f01f225b013341895dfabfda3f614c4a91accd9534907ce2d1a4d79d92dae
3
+ size 222304