jon-tow commited on
Commit
a5b192f
1 Parent(s): 3ed0002

Add the `GSM8K` dataset (#4103)

Browse files

* Add the `GSM8K` dataset

* Fix yaml block

* Fix remote url for WIN

* Remove unused `os` import

* Apply suggestions from code review

Co-authored-by: jon-tow <jon-tow@Jons-MacBook-Pro.local>
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>

Commit from https://github.com/huggingface/datasets/commit/11a50bb0b18a17103b936610b05d0cf646cab950

README.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - crowdsourced
4
+ language_creators:
5
+ - crowdsourced
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - mit
10
+ multilinguality:
11
+ - monolingual
12
+ size_categories:
13
+ - 1K<n<10K
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - text2text-generation
18
+ task_ids:
19
+ - text2text-generation-other-math-word-problems
20
+ paperswithcode_id: gsm8k
21
+ pretty_name: Grade School Math 8K
22
+ ---
23
+
24
+ # Dataset Card for GSM8K
25
+
26
+ ## Table of Contents
27
+ - [Dataset Description](#dataset-description)
28
+ - [Dataset Summary](#dataset-summary)
29
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
30
+ - [Languages](#languages)
31
+ - [Dataset Structure](#dataset-structure)
32
+ - [Data Instances](#data-instances)
33
+ - [Data Fields](#data-instances)
34
+ - [Data Splits](#data-instances)
35
+ - [Dataset Creation](#dataset-creation)
36
+ - [Curation Rationale](#curation-rationale)
37
+ - [Source Data](#source-data)
38
+ - [Annotations](#annotations)
39
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
40
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
41
+ - [Social Impact of Dataset](#social-impact-of-dataset)
42
+ - [Discussion of Biases](#discussion-of-biases)
43
+ - [Other Known Limitations](#other-known-limitations)
44
+ - [Additional Information](#additional-information)
45
+ - [Dataset Curators](#dataset-curators)
46
+ - [Licensing Information](#licensing-information)
47
+ - [Citation Information](#citation-information)
48
+
49
+ ## Dataset Description
50
+
51
+ - **Homepage:** https://openai.com/blog/grade-school-math/
52
+ - **Repository:** https://github.com/openai/grade-school-math
53
+ - **Paper:** https://arxiv.org/abs/2110.14168
54
+ - **Leaderboard:** [Needs More Information]
55
+ - **Point of Contact:** [Needs More Information]
56
+
57
+ ### Dataset Summary
58
+
59
+ GSM8K (Grade School Math 8K) is a dataset of 8.5K high quality linguistically diverse grade school math word problems. The dataset was created to support the task of question answering on basic mathematical problems that require multi-step reasoning.
60
+
61
+ ### Supported Tasks and Leaderboards
62
+
63
+ [Needs More Information]
64
+
65
+ ### Languages
66
+
67
+ The text in the dataset is in English. The associated BCP-47 code is `en`.
68
+
69
+ ## Dataset Structure
70
+
71
+ ### Data Instances
72
+
73
+ For the `main` configuration, each instance contains a string for the grade-school level math question and a string for the corresponding answer with multiple steps of reasoning and calculator annotations (explained [here](https://github.com/openai/grade-school-math#calculation-annotations)).
74
+
75
+
76
+ ```python
77
+ {
78
+ 'question': 'Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?',
79
+ 'answer': 'Natalia sold 48/2 = <<48/2=24>>24 clips in May.\nNatalia sold 48+24 = <<48+24=72>>72 clips altogether in April and May.\n#### 72',
80
+ }
81
+ ```
82
+
83
+ For the `socratic` configuration, each instance contains a string for a grade-school level math question, a string for the corresponding answer with multiple steps of reasoning, calculator annotations (explained [here](https://github.com/openai/grade-school-math#calculation-annotations)), and *Socratic sub-questions*.
84
+
85
+ ```python
86
+ {
87
+ 'question': 'Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?',
88
+ 'answer': 'How many clips did Natalia sell in May? ** Natalia sold 48/2 = <<48/2=24>>24 clips in May.\nHow many clips did Natalia sell altogether in April and May? ** Natalia sold 48+24 = <<48+24=72>>72 clips altogether in April and May.\n#### 72',
89
+ }
90
+ ```
91
+
92
+ ### Data Fields
93
+
94
+ The data fields are the same among `main` and `socratic` configurations and their individual splits.
95
+
96
+ - question: The question string to a grade school math problem.
97
+
98
+ - answer: The full solution string to the `question`. It contains multiple steps of reasoning with calculator annotations and the final numeric solution.
99
+
100
+ ### Data Splits
101
+
102
+ | name |train|validation|
103
+ |--------|----:|---------:|
104
+ |main | 7473| 1319|
105
+ |socratic| 7473| 1319|
106
+
107
+ ## Dataset Creation
108
+
109
+ ### Curation Rationale
110
+
111
+ [Needs More Information]
112
+
113
+ ### Source Data
114
+
115
+ #### Initial Data Collection and Normalization
116
+
117
+ From the paper:
118
+
119
+ > We initially collected a starting set of a thousand problems and natural language solutions by hiring freelance contractors on Upwork (upwork.com). We then worked with Surge AI (surgehq.ai), an NLP data labeling platform, to scale up our data collection. After collecting the full dataset, we asked workers to re-solve all problems, with no workers re-solving problems they originally wrote. We checked whether their final answers agreed with the original solu- tions, and any problems that produced disagreements were either repaired or discarded. We then performed another round of agreement checks on a smaller subset of problems, finding that 1.7% of problems still produce disagreements among contractors. We estimate this to be the fraction of problems that con- tain breaking errors or ambiguities. It is possible that a larger percentage of problems contain subtle errors.
120
+
121
+ #### Who are the source language producers?
122
+
123
+ [Needs More Information]
124
+
125
+ ### Annotations
126
+
127
+ #### Annotation process
128
+
129
+ [Needs More Information]
130
+
131
+ #### Who are the annotators?
132
+
133
+ Surge AI (surgehq.ai)
134
+
135
+ ### Personal and Sensitive Information
136
+
137
+ [Needs More Information]
138
+
139
+ ## Considerations for Using the Data
140
+
141
+ ### Social Impact of Dataset
142
+
143
+ [Needs More Information]
144
+
145
+ ### Discussion of Biases
146
+
147
+ [Needs More Information]
148
+
149
+ ### Other Known Limitations
150
+
151
+ [Needs More Information]
152
+
153
+ ## Additional Information
154
+
155
+ ### Dataset Curators
156
+
157
+ [Needs More Information]
158
+
159
+ ### Licensing Information
160
+
161
+ The GSM8K dataset is licensed under the [MIT License](https://opensource.org/licenses/MIT).
162
+
163
+ ### Citation Information
164
+
165
+ ```bibtex
166
+ @article{cobbe2021gsm8k,
167
+ title={Training Verifiers to Solve Math Word Problems},
168
+ author={Cobbe, Karl and Kosaraju, Vineet and Bavarian, Mohammad and Chen, Mark and Jun, Heewoo and Kaiser, Lukasz and Plappert, Matthias and Tworek, Jerry and Hilton, Jacob and Nakano, Reiichiro and Hesse, Christopher and Schulman, John},
169
+ journal={arXiv preprint arXiv:2110.14168},
170
+ year={2021}
171
+ }
172
+ ```
173
+
174
+ ### Contributions
175
+
176
+ Thanks to [@jon-tow](https://github.com/jon-tow) for adding this dataset.
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"main": {"description": "GSM8K (Grade School Math 8K) is a dataset of 8.5K high quality\nlinguistically diverse grade school math word problems. The\ndataset was created to support the task of question answering\non basic mathematical problems that require multi-step reasoning.\n", "citation": "@misc{cobbe2021training,\n title={Training Verifiers to Solve Math Word Problems},\n author={Karl Cobbe and Vineet Kosaraju and Mohammad Bavarian and Jacob Hilton and Reiichiro Nakano and Christopher Hesse and John Schulman},\n year={2021},\n eprint={2110.14168},\n archivePrefix={arXiv},\n primaryClass={cs.LG}\n}\n", "homepage": "https://openai.com/blog/grade-school-math", "license": "MIT", "features": {"question": {"dtype": "string", "id": null, "_type": "Value"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "gsm8k", "config_name": "main", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3963202, "num_examples": 7473, "dataset_name": "gsm8k"}, "test": {"name": "test", "num_bytes": 713732, "num_examples": 1319, "dataset_name": "gsm8k"}}, "download_checksums": {"https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/train.jsonl": {"num_bytes": 4166206, "checksum": "17f347dc51477c50d4efb83959dbb7c56297aba886e5544ee2aaed3024813465"}, "https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/test.jsonl": {"num_bytes": 749738, "checksum": "3730d312f6e3440559ace48831e51066acaca737f6eabec99bccb9e4b3c39d14"}}, "download_size": 4915944, "post_processing_size": null, "dataset_size": 4676934, "size_in_bytes": 9592878}, "socratic": {"description": "GSM8K (Grade School Math 8K) is a dataset of 8.5K high quality\nlinguistically diverse grade school math word problems. The\ndataset was created to support the task of question answering\non basic mathematical problems that require multi-step reasoning.\n", "citation": "@misc{cobbe2021training,\n title={Training Verifiers to Solve Math Word Problems},\n author={Karl Cobbe and Vineet Kosaraju and Mohammad Bavarian and Jacob Hilton and Reiichiro Nakano and Christopher Hesse and John Schulman},\n year={2021},\n eprint={2110.14168},\n archivePrefix={arXiv},\n primaryClass={cs.LG}\n}\n", "homepage": "https://openai.com/blog/grade-school-math", "license": "MIT", "features": {"question": {"dtype": "string", "id": null, "_type": "Value"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "gsm8k", "config_name": "socratic", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5198108, "num_examples": 7473, "dataset_name": "gsm8k"}, "test": {"name": "test", "num_bytes": 936859, "num_examples": 1319, "dataset_name": "gsm8k"}}, "download_checksums": {"https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/train_socratic.jsonl": {"num_bytes": 5401739, "checksum": "153d86551187cfd64ef7afb59bfd0ef75cea3ae9388e7ad31e43920b6dd77872"}, "https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/test_socratic.jsonl": {"num_bytes": 972978, "checksum": "c96673362fa7a699f4836a9b6474a067448f95fe58064727501ee63ba4c3fdb6"}}, "download_size": 6374717, "post_processing_size": null, "dataset_size": 6134967, "size_in_bytes": 12509684}}
dummy/main/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b625de4a46e7a8c50f44f659572726aecfa4993e2e655205fb2fbbeb71a9b24
3
+ size 2224
dummy/socratic/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c0a52b53adf31fb1306a989a99b707feda9f72391f4c2801cb5ecf245582f24
3
+ size 2475
gsm8k.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """Grade School Math 8k dataset."""
15
+
16
+ import json
17
+ import textwrap
18
+
19
+ import datasets
20
+
21
+
22
+ _CITATION = """\
23
+ @misc{cobbe2021training,
24
+ title={Training Verifiers to Solve Math Word Problems},
25
+ author={Karl Cobbe and Vineet Kosaraju and Mohammad Bavarian and Jacob Hilton and Reiichiro Nakano and Christopher Hesse and John Schulman},
26
+ year={2021},
27
+ eprint={2110.14168},
28
+ archivePrefix={arXiv},
29
+ primaryClass={cs.LG}
30
+ }
31
+ """
32
+
33
+ _DESCRIPTION = """\
34
+ GSM8K (Grade School Math 8K) is a dataset of 8.5K high quality
35
+ linguistically diverse grade school math word problems. The
36
+ dataset was created to support the task of question answering
37
+ on basic mathematical problems that require multi-step reasoning.
38
+ """
39
+
40
+ _HOMEPAGE = "https://openai.com/blog/grade-school-math"
41
+
42
+ _LICENSE = "MIT"
43
+
44
+ _BASE_URL = "https://raw.githubusercontent.com/openai/grade-school-math/master/grade_school_math/data/"
45
+
46
+
47
+ class Gsm8kConfig(datasets.BuilderConfig):
48
+ """BuilderConfig for GSM8K."""
49
+
50
+ def __init__(self, urls, **kwargs):
51
+ """BuilderConfig for GSM8K.
52
+
53
+ Args:
54
+ urls: *dict[string]*, the urls for each split of the GSM8k set.
55
+ """
56
+ super().__init__(version=datasets.Version("1.1.0"), **kwargs)
57
+ self.urls = urls
58
+
59
+
60
+ class Gsm8k(datasets.GeneratorBasedBuilder):
61
+ """Grade School Math 8k (GSM8K)"""
62
+
63
+ BUILDER_CONFIGS = [
64
+ Gsm8kConfig(
65
+ name="main",
66
+ description=textwrap.dedent(
67
+ """
68
+ It is segmented into 7.5K training problems and 1K test problems.
69
+ These problems take between 2 and 8 steps to solve, and solutions
70
+ primarily involve performing a sequence of elementary calculations
71
+ using basic arithmetic operations (+ - / *) to reach the final
72
+ answer. A bright middle school student should be able to solve
73
+ every problem.
74
+ """,
75
+ ),
76
+ urls={
77
+ "train": _BASE_URL + "train.jsonl",
78
+ "test": _BASE_URL + "test.jsonl",
79
+ },
80
+ ),
81
+ Gsm8kConfig(
82
+ name="socratic",
83
+ description=textwrap.dedent(
84
+ """
85
+ Additionally, there is a modified solution format that injects
86
+ automatically generated "Socratic subquestions" before each step.
87
+ """
88
+ ),
89
+ urls={
90
+ "train": _BASE_URL + "train_socratic.jsonl",
91
+ "test": _BASE_URL + "test_socratic.jsonl",
92
+ },
93
+ ),
94
+ ]
95
+
96
+ def _info(self):
97
+ features = datasets.Features(
98
+ {
99
+ "question": datasets.Value("string"),
100
+ "answer": datasets.Value("string"),
101
+ }
102
+ )
103
+ return datasets.DatasetInfo(
104
+ description=_DESCRIPTION,
105
+ features=features,
106
+ homepage=_HOMEPAGE,
107
+ license=_LICENSE,
108
+ citation=_CITATION,
109
+ )
110
+
111
+ def _split_generators(self, dl_manager):
112
+ data_dir = dl_manager.download_and_extract(self.config.urls)
113
+ return [
114
+ datasets.SplitGenerator(
115
+ name=datasets.Split.TRAIN,
116
+ gen_kwargs={
117
+ "filepath": data_dir["train"],
118
+ },
119
+ ),
120
+ datasets.SplitGenerator(
121
+ name=datasets.Split.TEST,
122
+ gen_kwargs={
123
+ "filepath": data_dir["test"],
124
+ },
125
+ ),
126
+ ]
127
+
128
+ def _generate_examples(self, filepath):
129
+ with open(filepath, encoding="utf-8") as f:
130
+ for key, row in enumerate(f):
131
+ data = json.loads(row)
132
+ yield key, {
133
+ "question": data["question"],
134
+ "answer": data["answer"],
135
+ }