Datasets:
Modalities:
Text
Formats:
parquet
Languages:
English
Size:
10K - 100K
ArXiv:
Tags:
math-word-problems
License:
Commit
·
1383163
1
Parent(s):
60b4b82
Delete loading script
Browse files
gsm8k.py
DELETED
|
@@ -1,135 +0,0 @@
|
|
| 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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|