Datasets:

License:
momentino commited on
Commit
6715114
·
verified ·
1 Parent(s): ca32fbf

Upload planbench.py

Browse files
Files changed (1) hide show
  1. planbench.py +298 -0
planbench.py ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Hugging Face's logo Hugging Face
3
+
4
+ Models
5
+ Datasets
6
+ Spaces
7
+ Posts
8
+ Docs
9
+ Enterprise
10
+ Pricing
11
+
12
+ Datasets:
13
+ clembench-playpen
14
+ /
15
+ lmentry
16
+ Tasks:
17
+ Question Answering
18
+ Languages:
19
+ English
20
+ ArXiv:
21
+ Dataset card
22
+ Files and versions
23
+ Community
24
+ Settings
25
+ lmentry
26
+ / lmentry.py
27
+ momentino's picture
28
+ momentino
29
+ fix: name of a task
30
+ 268ba84
31
+ verified
32
+ 8 days ago
33
+ raw
34
+ history
35
+ blame
36
+ edit
37
+ delete
38
+ 13.6 kB
39
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
40
+ #
41
+ # Licensed under the Apache License, Version 2.0 (the "License");
42
+ # you may not use this file except in compliance with the License.
43
+ # You may obtain a copy of the License at
44
+ #
45
+ # http://www.apache.org/licenses/LICENSE-2.0
46
+ #
47
+ # Unless required by applicable law or agreed to in writing, software
48
+ # distributed under the License is distributed on an "AS IS" BASIS,
49
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
+ # See the License for the specific language governing permissions and
51
+ # limitations under the License.
52
+
53
+
54
+ import json
55
+ import datasets
56
+
57
+
58
+ _CITATION = """\
59
+ @misc{valmeekam2023planbenchextensiblebenchmarkevaluating,
60
+ title={PlanBench: An Extensible Benchmark for Evaluating Large Language Models on Planning and Reasoning about Change},
61
+ author={Karthik Valmeekam and Matthew Marquez and Alberto Olmo and Sarath Sreedharan and Subbarao Kambhampati},
62
+ year={2023},
63
+ eprint={2206.10498},
64
+ archivePrefix={arXiv},
65
+ primaryClass={cs.CL},
66
+ url={https://arxiv.org/abs/2206.10498},
67
+ }
68
+ """
69
+
70
+ _DESCRIPTION = """\
71
+ PlanBench is a benchmark for evaluating models' capabilities of planning and reasoning by evaluating them on IPC problems"""
72
+
73
+ _HOMEPAGE = "https://github.com/karthikv792/LLMs-Planning/tree/main/plan-bench"
74
+
75
+ _LICENSE = "MIT"
76
+
77
+
78
+ _URLS_prefix = {
79
+ "blocksworld" : "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/tree/main/plan-bench/prompts/blocksworld",
80
+ "blocksworld_3": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/tree/main/plan-bench/prompts/blocksworld_3",
81
+ "mystery_blocksworld": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/tree/main/plan-bench/prompts/mystery_blocksworld",
82
+ "mystery_blocksworld_3": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/tree/main/plan-bench/prompts/mystery_blocksworld_3",
83
+ "logistics": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/tree/main/plan-bench/prompts/logistics",
84
+ }
85
+ _URLS = {
86
+ "blocksworld_plan_generation": {
87
+ "test": _URLS_prefix["blocksworld"] + "task_1_plan_generation.json"
88
+ },
89
+ "blocksworld_plan_optimality": {
90
+ "test": _URLS_prefix["blocksworld"] + "task_2_plan_optimality.json"
91
+ },
92
+ "blocksworld_plan_verification": {
93
+ "test": _URLS_prefix["blocksworld"] + "task_3_plan_verification.json"
94
+ },
95
+ "blocksworld_plan_reuse": {
96
+ "test": _URLS_prefix["blocksworld"] + "task_4_plan_reuse.json"
97
+ },
98
+ "blocksworld_plan_generalization": {
99
+ "test": _URLS_prefix["blocksworld"] + "task_5_plan_reuse.json"
100
+ },
101
+ "blocksworld_replanning": {
102
+ "test": _URLS_prefix["blocksworld"] + "task_6_replanning.json"
103
+ },
104
+ "blocksworld_plan_execution": {
105
+ "test": _URLS_prefix["blocksworld"] + "task_7_plan_execution.json"
106
+ },
107
+ "blocksworld_plan_shuffling": {
108
+ "test": _URLS_prefix["blocksworld"] + "task_8_1_goal_shuffling.json"
109
+ },
110
+ "blocksworld_plan_full_to_partial": {
111
+ "test": _URLS_prefix["blocksworld"] + "task_8_2_full_to_partial.json"
112
+ },
113
+ "blocksworld_partial_to_full": {
114
+ "test": _URLS_prefix["blocksworld"] + "task_8_3_partial_to_full.json"
115
+ },
116
+ "blocksworld_3_plan_generation": {
117
+ "test": _URLS_prefix["blocksworld_3"] + "task_1_plan_generation.json"
118
+ },
119
+ "blocksworld_3_plan_optimality": {
120
+ "test": _URLS_prefix["blocksworld_3"] + "task_2_plan_optimality.json"
121
+ },
122
+ "blocksworld_3_plan_verification": {
123
+ "test": _URLS_prefix["blocksworld_3"] + "task_3_plan_verification.json"
124
+ },
125
+ "blocksworld_3_plan_reuse": {
126
+ "test": _URLS_prefix["blocksworld_3"] + "task_4_plan_reuse.json"
127
+ },
128
+ "blocksworld_3_plan_generalization": {
129
+ "test": _URLS_prefix["blocksworld_3"] + "task_5_plan_reuse.json"
130
+ },
131
+ "blocksworld_3_replanning": {
132
+ "test": _URLS_prefix["blocksworld_3"] + "task_6_replanning.json"
133
+ },
134
+ "blocksworld_3_plan_execution": {
135
+ "test": _URLS_prefix["blocksworld_3"] + "task_7_plan_execution.json"
136
+ },
137
+ "blocksworld_3_plan_shuffling": {
138
+ "test": _URLS_prefix["blocksworld_3"] + "task_8_1_goal_shuffling.json"
139
+ },
140
+ "blocksworld_3_plan_full_to_partial": {
141
+ "test": _URLS_prefix["blocksworld_3"] + "task_8_2_full_to_partial.json"
142
+ },
143
+ "blocksworld_3_partial_to_full": {
144
+ "test": _URLS_prefix["blocksworld_3"] + "task_8_3_partial_to_full.json"
145
+ },
146
+
147
+ "mystery_blocksworld_plan_generation": {
148
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_1_plan_generation.json"
149
+ },
150
+ "mystery_blocksworld_plan_optimality": {
151
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_2_plan_optimality.json"
152
+ },
153
+ "mystery_blocksworld_plan_verification": {
154
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_3_plan_verification.json"
155
+ },
156
+ "mystery_blocksworld_plan_reuse": {
157
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_4_plan_reuse.json"
158
+ },
159
+ "mystery_blocksworld_plan_generalization": {
160
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_5_plan_reuse.json"
161
+ },
162
+ "mystery_blocksworld_replanning": {
163
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_6_replanning.json"
164
+ },
165
+ "mystery_blocksworld_plan_execution": {
166
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_7_plan_execution.json"
167
+ },
168
+ "mystery_blocksworld_plan_shuffling": {
169
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_8_1_goal_shuffling.json"
170
+ },
171
+ "mystery_blocksworld_plan_full_to_partial": {
172
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_8_2_full_to_partial.json"
173
+ },
174
+ "mystery_blocksworld_partial_to_full": {
175
+ "test": _URLS_prefix["mystery_blocksworld"] + "task_8_3_partial_to_full.json"
176
+ },
177
+
178
+ "mystery_blocksworld_3_plan_generation": {
179
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_1_plan_generation.json"
180
+ },
181
+ "mystery_blocksworld_3_plan_optimality": {
182
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_2_plan_optimality.json"
183
+ },
184
+ "mystery_blocksworld_3_plan_verification": {
185
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_3_plan_verification.json"
186
+ },
187
+ "mystery_blocksworld_3_plan_reuse": {
188
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_4_plan_reuse.json"
189
+ },
190
+ "mystery_blocksworld_3_plan_generalization": {
191
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_5_plan_reuse.json"
192
+ },
193
+ "mystery_blocksworld_3_replanning": {
194
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_6_replanning.json"
195
+ },
196
+ "mystery_blocksworld_3_plan_execution": {
197
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_7_plan_execution.json"
198
+ },
199
+ "mystery_blocksworld_3_plan_shuffling": {
200
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_8_1_goal_shuffling.json"
201
+ },
202
+ "mystery_blocksworld_3_plan_full_to_partial": {
203
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_8_2_full_to_partial.json"
204
+ },
205
+ "mystery_blocksworld_3_partial_to_full": {
206
+ "test": _URLS_prefix["mystery_blocksworld_3"] + "task_8_3_partial_to_full.json"
207
+ },
208
+
209
+ "logistics_plan_generation": {
210
+ "test": _URLS_prefix["logistics"] + "task_1_plan_generation.json"
211
+ },
212
+ "logistics_plan_optimality": {
213
+ "test": _URLS_prefix["logistics"] + "task_2_plan_optimality.json"
214
+ },
215
+ "logistics_plan_verification": {
216
+ "test": _URLS_prefix["logistics"] + "task_3_plan_verification.json"
217
+ },
218
+ "logistics_plan_reuse": {
219
+ "test": _URLS_prefix["logistics"] + "task_4_plan_reuse.json"
220
+ },
221
+ "logistics_plan_generalization": {
222
+ "test": _URLS_prefix["logistics"] + "task_5_plan_reuse.json"
223
+ },
224
+ "logistics_replanning": {
225
+ "test": _URLS_prefix["logistics"] + "task_6_replanning.json"
226
+ },
227
+ "logistics_plan_execution": {
228
+ "test": _URLS_prefix["logistics"] + "task_7_plan_execution.json"
229
+ },
230
+ "logistics_plan_shuffling": {
231
+ "test": _URLS_prefix["logistics"] + "task_8_1_goal_shuffling.json"
232
+ },
233
+ "logistics_plan_full_to_partial": {
234
+ "test": _URLS_prefix["logistics"] + "task_8_2_full_to_partial.json"
235
+ },
236
+ "logistics_partial_to_full": {
237
+ "test": _URLS_prefix["logistics"] + "task_8_3_partial_to_full.json"
238
+ }
239
+ }
240
+
241
+
242
+ class PlanBench(datasets.GeneratorBasedBuilder):
243
+ """ LMentry is a benchmark for measuring language model performance on tasks that are trivial to humans. LMentry consists of 25 tasks which humans are generally expected to perform perfectly, e.g. writing a sentence containing a specific word, identifying which words in a list belong to a specific category, choosing which of two words is longer, or identifying which of two words rhymes with a third word.
244
+ """
245
+
246
+ BUILDER_CONFIGS = [
247
+ datasets.BuilderConfig(
248
+ name=config_name,
249
+ version=datasets.Version("0.0.1"),
250
+ description=f"{config_name} task from PlanBench"
251
+ )
252
+ for config_name in _URLS.keys()
253
+ ]
254
+ def _info(self):
255
+ features = {
256
+ "instance_id": datasets.Value("int32"),
257
+ "query": datasets.Value("string"),
258
+ "ground_truth_plan": datasets.Value("string"),
259
+ }
260
+ if ("plan_generation" in self.config_name or
261
+ "plan_optimality" in self.config_name or
262
+ "plan_generalization" in self.config_name or
263
+ "replanning" in self.config_name or
264
+ "plan_execution" in self.config_name or):
265
+ features.update({"example_istance_ids": datasets.Sequence(datasets.Value("string"))})
266
+ if "plan_reuse" in self.config_name or "replanning" in self.config_name:
267
+ features.update({"new_instance": datasets.Value("string")})
268
+ if "goal_shuffling" in self.config_name:
269
+ features.update({"single_goal_instances": datasets.Value("int32")})
270
+ features = datasets.Features(features)
271
+ return datasets.DatasetInfo(
272
+ description=_DESCRIPTION,
273
+ features=features,
274
+ homepage=_HOMEPAGE,
275
+ citation=_CITATION,
276
+ license=_LICENSE,
277
+ )
278
+
279
+
280
+ def _split_generators(self, dl_manager):
281
+ urls = _URLS[self.config.name]
282
+ data_dir = dl_manager.download_and_extract(urls)
283
+ return [
284
+ datasets.SplitGenerator(
285
+ name = datasets.Split.TEST,
286
+ gen_kwargs = {
287
+ "filepath" : data_dir["test"],
288
+ "split" : "test",
289
+ }
290
+ )
291
+ ]
292
+
293
+
294
+ def _generate_examples(self, filepath, split):
295
+ with open(filepath, encoding = "utf-8") as fin :
296
+ data = json.load(fin)
297
+ for instance in data["instances"]:
298
+ yield instance["instance_id"], instance