Datasets:

License:
File size: 10,953 Bytes
6715114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8317c88
6715114
 
 
 
 
8317c88
 
 
 
 
6715114
 
 
e63790f
6715114
 
e63790f
6715114
 
e63790f
6715114
 
e63790f
6715114
 
863d7d3
6715114
 
e63790f
6715114
 
e63790f
6715114
dc978ab
e63790f
6715114
868dffa
e63790f
6715114
 
e63790f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863d7d3
e63790f
 
 
 
 
 
 
dc978ab
e63790f
 
868dffa
e63790f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863d7d3
e63790f
 
 
 
 
 
 
dc978ab
e63790f
 
868dffa
e63790f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863d7d3
e63790f
 
 
 
 
 
 
dc978ab
e63790f
 
868dffa
e63790f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863d7d3
e63790f
 
 
 
 
 
 
dc978ab
e63790f
 
868dffa
e63790f
 
 
 
 
6715114
 
 
e63790f
6715114
 
 
 
 
 
76e8fac
6715114
 
 
 
 
 
 
 
 
 
 
76e8fac
 
1b33c68
76e8fac
 
863d7d3
76e8fac
6715114
76e8fac
6715114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c11e19
6715114
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import json
import datasets


_CITATION = """\
@misc{valmeekam2023planbenchextensiblebenchmarkevaluating,
      title={PlanBench: An Extensible Benchmark for Evaluating Large Language Models on Planning and Reasoning about Change}, 
      author={Karthik Valmeekam and Matthew Marquez and Alberto Olmo and Sarath Sreedharan and Subbarao Kambhampati},
      year={2023},
      eprint={2206.10498},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2206.10498}, 
}
"""

_DESCRIPTION = """\
PlanBench is a benchmark for evaluating models' capabilities of planning and reasoning by evaluating them on IPC problems"""

_HOMEPAGE = "https://github.com/karthikv792/LLMs-Planning/tree/main/plan-bench"

_LICENSE = "MIT"


_URLS_prefix = {
    "blocksworld" : "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/main/plan-bench/prompts/blocksworld",
    "blocksworld_3": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/main/plan-bench/prompts/blocksworld_3",
    "mystery_blocksworld": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/main/plan-bench/prompts/mystery_blocksworld",
    "mystery_blocksworld_3": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/main/plan-bench/prompts/mystery_blocksworld_3",
    "logistics": "https://raw.githubusercontent.com/karthikv792/LLMs-Planning/main/plan-bench/prompts/logistics",
}
_URLS = {
    "blocksworld_plan_generation": {
        "test": _URLS_prefix["blocksworld"] + "/task_1_plan_generation.json"
    },
    "blocksworld_plan_optimality": {
        "test": _URLS_prefix["blocksworld"] + "/task_2_plan_optimality.json"
    },
    "blocksworld_plan_verification": {
        "test": _URLS_prefix["blocksworld"] + "/task_3_plan_verification.json"
    },
    "blocksworld_plan_reuse": {
        "test": _URLS_prefix["blocksworld"] + "/task_4_plan_reuse.json"
    },
    "blocksworld_plan_generalization": {
        "test": _URLS_prefix["blocksworld"] + "/task_5_plan_generalization.json"
    },
    "blocksworld_replanning": {
        "test": _URLS_prefix["blocksworld"] + "/task_6_replanning.json"
    },
    "blocksworld_plan_execution": {
        "test": _URLS_prefix["blocksworld"] + "/task_7_plan_execution.json"
    },
    "blocksworld_goal_shuffling": {
        "test": _URLS_prefix["blocksworld"] + "/task_8_1_goal_shuffling.json"
    },
    "blocksworld_full_to_partial": {
        "test": _URLS_prefix["blocksworld"] + "/task_8_2_full_to_partial.json"
    },
    "blocksworld_partial_to_full": {
        "test": _URLS_prefix["blocksworld"] + "/task_8_3_partial_to_full.json"
    },
    "blocksworld_3_plan_generation": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_1_plan_generation.json"
    },
    "blocksworld_3_plan_optimality": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_2_plan_optimality.json"
    },
    "blocksworld_3_plan_verification": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_3_plan_verification.json"
    },
    "blocksworld_3_plan_reuse": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_4_plan_reuse.json"
    },
    "blocksworld_3_plan_generalization": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_5_plan_generalization.json"
    },
    "blocksworld_3_replanning": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_6_replanning.json"
    },
    "blocksworld_3_plan_execution": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_7_plan_execution.json"
    },
    "blocksworld_3_goal_shuffling": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_8_1_goal_shuffling.json"
    },
    "blocksworld_3_full_to_partial": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_8_2_full_to_partial.json"
    },
    "blocksworld_3_partial_to_full": {
        "test": _URLS_prefix["blocksworld_3"] + "/task_8_3_partial_to_full.json"
    },
    "mystery_blocksworld_plan_generation": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_1_plan_generation.json"
    },
    "mystery_blocksworld_plan_optimality": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_2_plan_optimality.json"
    },
    "mystery_blocksworld_plan_verification": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_3_plan_verification.json"
    },
    "mystery_blocksworld_plan_reuse": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_4_plan_reuse.json"
    },
    "mystery_blocksworld_plan_generalization": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_5_plan_generalization.json"
    },
    "mystery_blocksworld_replanning": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_6_replanning.json"
    },
    "mystery_blocksworld_plan_execution": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_7_plan_execution.json"
    },
    "mystery_blocksworld_goal_shuffling": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_8_1_goal_shuffling.json"
    },
    "mystery_blocksworld_full_to_partial": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_8_2_full_to_partial.json"
    },
    "mystery_blocksworld_partial_to_full": {
        "test": _URLS_prefix["mystery_blocksworld"] + "/task_8_3_partial_to_full.json"
    },
    "mystery_blocksworld_3_plan_generation": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_1_plan_generation.json"
    },
    "mystery_blocksworld_3_plan_optimality": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_2_plan_optimality.json"
    },
    "mystery_blocksworld_3_plan_verification": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_3_plan_verification.json"
    },
    "mystery_blocksworld_3_plan_reuse": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_4_plan_reuse.json"
    },
    "mystery_blocksworld_3_plan_generalization": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_5_plan_generalization.json"
    },
    "mystery_blocksworld_3_replanning": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_6_replanning.json"
    },
    "mystery_blocksworld_3_plan_execution": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_7_plan_execution.json"
    },
    "mystery_blocksworld_3_goal_shuffling": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_8_1_goal_shuffling.json"
    },
    "mystery_blocksworld_3_full_to_partial": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_8_2_full_to_partial.json"
    },
    "mystery_blocksworld_3_partial_to_full": {
        "test": _URLS_prefix["mystery_blocksworld_3"] + "/task_8_3_partial_to_full.json"
    },
    "logistics_plan_generation": {
        "test": _URLS_prefix["logistics"] + "/task_1_plan_generation.json"
    },
    "logistics_plan_optimality": {
        "test": _URLS_prefix["logistics"] + "/task_2_plan_optimality.json"
    },
    "logistics_plan_verification": {
        "test": _URLS_prefix["logistics"] + "/task_3_plan_verification.json"
    },
    "logistics_plan_reuse": {
        "test": _URLS_prefix["logistics"] + "/task_4_plan_reuse.json"
    },
    "logistics_plan_generalization": {
        "test": _URLS_prefix["logistics"] + "/task_5_plan_generalization.json"
    },
    "logistics_replanning": {
        "test": _URLS_prefix["logistics"] + "/task_6_replanning.json"
    },
    "logistics_plan_execution": {
        "test": _URLS_prefix["logistics"] + "/task_7_plan_execution.json"
    },
    "logistics_goal_shuffling": {
        "test": _URLS_prefix["logistics"] + "/task_8_1_goal_shuffling.json"
    },
    "logistics_full_to_partial": {
        "test": _URLS_prefix["logistics"] + "/task_8_2_full_to_partial.json"
    },
    "logistics_partial_to_full": {
        "test": _URLS_prefix["logistics"] + "/task_8_3_partial_to_full.json"
    }
}



class PlanBench(datasets.GeneratorBasedBuilder):
    """ 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.
"""

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name=config_name,
            version=datasets.Version("0.0.1"),
            description=f"{config_name} task from PlanBench"
        )
        for config_name in _URLS.keys()
    ]
    def _info(self):
        features = {
            "instance_id": datasets.Value("int32"),
            "query": datasets.Value("string"),
            "ground_truth_plan": datasets.Value("string"),
        }
        if ("plan_generation" in self.config.name or
                "plan_optimality" in self.config.name or
                "plan_generalization" in self.config.name or
                "replanning" in self.config.name or
                "plan_execution" in self.config.name):
            features.update({"example_instance_ids": datasets.Sequence(datasets.Value("string"))})
        if "plan_reuse" in self.config.name or "replanning" in self.config.name:
            features.update({"new_instance": datasets.Value("string")})
        if "goal_shuffling" in self.config.name:
            features.update({"single_goal_instances": datasets.Value("int32")})
        features = datasets.Features(features)
        return datasets.DatasetInfo(
                description=_DESCRIPTION,
                features=features,
                homepage=_HOMEPAGE,
                citation=_CITATION,
                license=_LICENSE,
            )


    def _split_generators(self, dl_manager):
        urls = _URLS[self.config.name]
        data_dir = dl_manager.download_and_extract(urls)
        return [
            datasets.SplitGenerator(
                name = datasets.Split.TEST,
                gen_kwargs = {
                    "filepath" : data_dir["test"],
                    "split" : "test",
                }
            )
        ]


    def _generate_examples(self, filepath, split):
        with open(filepath, encoding = "utf-8") as fin :
            data = json.load(fin)
            for instance in data["instances"]:
                yield instance["instance_id"], instance