Datasets:
tau
/

Modalities:
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
albertvillanova HF staff commited on
Commit
04646bb
1 Parent(s): 34986e8

Delete loading script

Browse files
Files changed (1) hide show
  1. commonsense_qa.py +0 -102
commonsense_qa.py DELETED
@@ -1,102 +0,0 @@
1
- """CommonsenseQA dataset."""
2
-
3
-
4
- import json
5
-
6
- import datasets
7
-
8
-
9
- _HOMEPAGE = "https://www.tau-nlp.org/commonsenseqa"
10
-
11
- _DESCRIPTION = """\
12
- CommonsenseQA is a new multiple-choice question answering dataset that requires different types of commonsense knowledge
13
- to predict the correct answers . It contains 12,102 questions with one correct answer and four distractor answers.
14
- The dataset is provided in two major training/validation/testing set splits: "Random split" which is the main evaluation
15
- split, and "Question token split", see paper for details.
16
- """
17
-
18
- _CITATION = """\
19
- @inproceedings{talmor-etal-2019-commonsenseqa,
20
- title = "{C}ommonsense{QA}: A Question Answering Challenge Targeting Commonsense Knowledge",
21
- author = "Talmor, Alon and
22
- Herzig, Jonathan and
23
- Lourie, Nicholas and
24
- Berant, Jonathan",
25
- booktitle = "Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)",
26
- month = jun,
27
- year = "2019",
28
- address = "Minneapolis, Minnesota",
29
- publisher = "Association for Computational Linguistics",
30
- url = "https://aclanthology.org/N19-1421",
31
- doi = "10.18653/v1/N19-1421",
32
- pages = "4149--4158",
33
- archivePrefix = "arXiv",
34
- eprint = "1811.00937",
35
- primaryClass = "cs",
36
- }
37
- """
38
-
39
- _URL = "https://s3.amazonaws.com/commensenseqa"
40
- _URLS = {
41
- "train": f"{_URL}/train_rand_split.jsonl",
42
- "validation": f"{_URL}/dev_rand_split.jsonl",
43
- "test": f"{_URL}/test_rand_split_no_answers.jsonl",
44
- }
45
-
46
-
47
- class CommonsenseQa(datasets.GeneratorBasedBuilder):
48
- """CommonsenseQA dataset."""
49
-
50
- VERSION = datasets.Version("1.0.0")
51
-
52
- def _info(self):
53
- features = datasets.Features(
54
- {
55
- "id": datasets.Value("string"),
56
- "question": datasets.Value("string"),
57
- "question_concept": datasets.Value("string"),
58
- "choices": datasets.features.Sequence(
59
- {
60
- "label": datasets.Value("string"),
61
- "text": datasets.Value("string"),
62
- }
63
- ),
64
- "answerKey": datasets.Value("string"),
65
- }
66
- )
67
- return datasets.DatasetInfo(
68
- description=_DESCRIPTION,
69
- features=features,
70
- homepage=_HOMEPAGE,
71
- citation=_CITATION,
72
- )
73
-
74
- def _split_generators(self, dl_manager):
75
- """Returns SplitGenerators."""
76
- filepaths = dl_manager.download_and_extract(_URLS)
77
- splits = [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]
78
- return [
79
- datasets.SplitGenerator(
80
- name=split,
81
- gen_kwargs={
82
- "filepath": filepaths[split],
83
- },
84
- )
85
- for split in splits
86
- ]
87
-
88
- def _generate_examples(self, filepath):
89
- """Yields examples."""
90
- with open(filepath, encoding="utf-8") as f:
91
- for uid, row in enumerate(f):
92
- data = json.loads(row)
93
- choices = data["question"]["choices"]
94
- labels = [label["label"] for label in choices]
95
- texts = [text["text"] for text in choices]
96
- yield uid, {
97
- "id": data["id"],
98
- "question": data["question"]["stem"],
99
- "question_concept": data["question"]["question_concept"],
100
- "choices": {"label": labels, "text": texts},
101
- "answerKey": data.get("answerKey", ""),
102
- }