| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| 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 |
|
|