Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
n<1K
Source Datasets:
original
ArXiv:
Tags:
code-generation
License:
albertvillanova HF staff commited on
Commit
004b91a
1 Parent(s): 5388f01

Delete loading script

Browse files
Files changed (1) hide show
  1. mbpp.py +0 -139
mbpp.py DELETED
@@ -1,139 +0,0 @@
1
- import json
2
-
3
- import datasets
4
-
5
-
6
- _DESCRIPTION = """\
7
- The MBPP (Mostly Basic Python Problems) dataset consists of around 1,000 crowd-sourced Python
8
- programming problems, designed to be solvable by entry level programmers, covering programming
9
- fundamentals, standard library functionality, and so on. Each problem consists of a task
10
- description, code solution and 3 automated test cases. The sanitized subset of the data has been
11
- hand-verified by the authors.
12
- """
13
-
14
- _URLs = {
15
- "full": "https://raw.githubusercontent.com/google-research/google-research/master/mbpp/mbpp.jsonl",
16
- "sanitized": "https://raw.githubusercontent.com/google-research/google-research/master/mbpp/sanitized-mbpp.json",
17
- }
18
-
19
- _CITATION = """\
20
- @article{austin2021program,
21
- title={Program Synthesis with Large Language Models},
22
- author={Austin, Jacob and Odena, Augustus and Nye, Maxwell and Bosma, Maarten and Michalewski, Henryk and Dohan, David and Jiang, Ellen and Cai, Carrie and Terry, Michael and Le, Quoc and others},
23
- journal={arXiv preprint arXiv:2108.07732},
24
- year={2021}
25
- }"""
26
-
27
- _HOMEPAGE = "https://github.com/google-research/google-research/tree/master/mbpp"
28
-
29
- _LICENSE = "CC-BY-4.0"
30
-
31
-
32
- class MBPP(datasets.GeneratorBasedBuilder):
33
- """MBPP: Mostly Basic Python Problems Dataset"""
34
-
35
- VERSION = datasets.Version("1.0.2")
36
-
37
- BUILDER_CONFIGS = [
38
- datasets.BuilderConfig(
39
- name="full",
40
- version=datasets.Version("1.0.2"),
41
- description=_DESCRIPTION,
42
- ),
43
- datasets.BuilderConfig(name="sanitized", version=datasets.Version("1.0.2"), description=_DESCRIPTION),
44
- ]
45
-
46
- DEFAULT_CONFIG_NAME = "full"
47
-
48
- def _info(self):
49
- if self.config.name == "full":
50
- features = datasets.Features(
51
- {
52
- "task_id": datasets.Value("int32"),
53
- "text": datasets.Value("string"),
54
- "code": datasets.Value("string"),
55
- "test_list": datasets.Sequence(datasets.Value("string")),
56
- "test_setup_code": datasets.Value("string"),
57
- "challenge_test_list": datasets.Sequence(datasets.Value("string")),
58
- }
59
- )
60
- elif self.config.name == "sanitized":
61
- features = datasets.Features(
62
- {
63
- "source_file": datasets.Value("string"),
64
- "task_id": datasets.Value("int32"),
65
- "prompt": datasets.Value("string"),
66
- "code": datasets.Value("string"),
67
- "test_imports": datasets.Sequence(datasets.Value("string")),
68
- "test_list": datasets.Sequence(datasets.Value("string")),
69
- }
70
- )
71
- return datasets.DatasetInfo(
72
- description=_DESCRIPTION,
73
- features=features,
74
- supervised_keys=None,
75
- homepage=_HOMEPAGE,
76
- license=_LICENSE,
77
- citation=_CITATION,
78
- )
79
-
80
- def _split_generators(self, dl_manager):
81
- """Returns SplitGenerators."""
82
- config_urls = _URLs[self.config.name]
83
- data_dir = dl_manager.download_and_extract(config_urls)
84
- return [
85
- datasets.SplitGenerator(
86
- name=datasets.Split.TRAIN,
87
- gen_kwargs={"filepath": data_dir, "split": "train"},
88
- ),
89
- datasets.SplitGenerator(
90
- name=datasets.Split.TEST,
91
- gen_kwargs={"filepath": data_dir, "split": "test"},
92
- ),
93
- datasets.SplitGenerator(
94
- name=datasets.Split.VALIDATION,
95
- gen_kwargs={"filepath": data_dir, "split": "validation"},
96
- ),
97
- datasets.SplitGenerator(
98
- name=datasets.Split("prompt"),
99
- gen_kwargs={"filepath": data_dir, "split": "prompt"},
100
- ),
101
- ]
102
-
103
- def _generate_examples(self, filepath, split):
104
- if self.config.name == "full":
105
-
106
- def _read_lines(fn, start, end):
107
- data = []
108
- with open(fn, encoding="utf-8") as f:
109
- for line in f:
110
- sample = json.loads(line)
111
- if start <= sample["task_id"] <= end:
112
- data.append(sample)
113
- elif sample["task_id"] > end:
114
- break
115
- return data
116
-
117
- if split == "test":
118
- data = _read_lines(filepath, 11, 510)
119
- elif split == "train":
120
- data = _read_lines(filepath, 601, 974)
121
- elif split == "validation":
122
- data = _read_lines(filepath, 511, 600)
123
- elif split == "prompt":
124
- data = _read_lines(filepath, 1, 10)
125
- elif self.config.name == "sanitized":
126
- with open(filepath, encoding="utf-8") as f:
127
- data = json.load(f)
128
- if split == "test":
129
- data = [sample for sample in data if 11 <= sample["task_id"] <= 510]
130
- elif split == "train":
131
- data = [sample for sample in data if 601 <= sample["task_id"] <= 974]
132
- elif split == "validation":
133
- data = [sample for sample in data if 511 <= sample["task_id"] <= 600]
134
- elif split == "prompt":
135
- data = [sample for sample in data if 1 <= sample["task_id"] <= 10]
136
- id_ = 0
137
- for sample in data:
138
- yield id_, sample
139
- id_ += 1