title: Classical Planning with LLM-Generated Heuristics: Challenging the State
    of the Art with Python Code
summary: In recent years, large language models (LLMs) have shown remarkable
  capabilities in various artificial intelligence problems. However, they fail to
  plan reliably, even when prompted with a detailed definition of the planning
  task. Attempts to improve their planning capabilities, such as chain-of-thought
  prompting, fine-tuning, and explicit "reasoning" still yield incorrect plans
  and usually fail to generalize to larger tasks. In this paper, we show how to
  use LLMs to generate correct plans, even for out-of-distribution tasks of
  increasing size. For a given planning domain, we ask an LLM to generate several
  domain-dependent heuristic functions in the form of Python code, evaluate them
  on a set of training tasks within a greedy best-first search, and choose the
  strongest one. The resulting LLM-generated heuristics solve many more unseen
  test tasks than state-of-the-art domain-independent heuristics for classical
  planning. They are even competitive with the strongest learning algorithm for
  domain-dependent planning. These findings are especially remarkable given that
  our proof-of-concept implementation is based on an unoptimized Python planner
  and the baselines all build upon highly optimized C++ code. In some domains,
  the LLM-generated heuristics expand fewer states than the baselines, revealing
  that they are not only efficiently computable, but sometimes even more
  informative than the state-of-the-art heuristics. Overall, our results show
  that sampling a set of planning heuristic function programs can significantly
  improve the planning capabilities of LLMs.
paper_authors._id: 67eaa0f83ace6eb46745a9fe
paper_authors.name: Augusto B. Corrêa
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2025-03-31T15:15:12.565Z
paper_authors._id: 674f43d6df6fa102409f6d1a
paper_authors.avatarUrl: https://cdn-avatars.huggingface.co/v1/production/uploads/no-auth/KT_-dmXWshUKvbhtn-LSs.png
paper_authors.fullname: Augusto B. Corrêa
paper_authors.type: user
paper_authors.user: abcorrea
paper_authors._id: 67eaa0f83ace6eb46745a9ff
paper_authors.name: André G. Pereira
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2025-03-31T15:15:13.942Z
paper_authors._id: 662fb9c891587703a677856e
paper_authors.avatarUrl: /avatars/9cb7f035a513279532fc205ce9c5902c.svg
paper_authors.fullname: Andre Grahl Pereira
paper_authors.type: user
paper_authors.user: andregrahl
paper_authors._id: 67eaa0f83ace6eb46745aa00
paper_authors.name: Jendrik Seipp
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2025-04-01T07:47:39.862Z
paper_authors._id: 66f3dfd4b8703dde248f6d26
paper_authors.avatarUrl: /avatars/c199c91d422500cc7c7556569291644d.svg
paper_authors.fullname: Jendrik Seipp
paper_authors.type: user
paper_authors.user: jendrikseipp
paper_title: Classical Planning with LLM-Generated Heuristics: Challenging the State
    of the Art with Python Code
paper_summary: In recent years, large language models (LLMs) have shown remarkable
  capabilities in various artificial intelligence problems. However, they fail to
  plan reliably, even when prompted with a detailed definition of the planning
  task. Attempts to improve their planning capabilities, such as chain-of-thought
  prompting, fine-tuning, and explicit "reasoning" still yield incorrect plans
  and usually fail to generalize to larger tasks. In this paper, we show how to
  use LLMs to generate correct plans, even for out-of-distribution tasks of
  increasing size. For a given planning domain, we ask an LLM to generate several
  domain-dependent heuristic functions in the form of Python code, evaluate them
  on a set of training tasks within a greedy best-first search, and choose the
  strongest one. The resulting LLM-generated heuristics solve many more unseen
  test tasks than state-of-the-art domain-independent heuristics for classical
  planning. They are even competitive with the strongest learning algorithm for
  domain-dependent planning. These findings are especially remarkable given that
  our proof-of-concept implementation is based on an unoptimized Python planner
  and the baselines all build upon highly optimized C++ code. In some domains,
  the LLM-generated heuristics expand fewer states than the baselines, revealing
  that they are not only efficiently computable, but sometimes even more
  informative than the state-of-the-art heuristics. Overall, our results show
  that sampling a set of planning heuristic function programs can significantly
  improve the planning capabilities of LLMs.
paper_ai_summary: LLMs can generate effective heuristics for classical planning tasks, outperforming domain-independent heuristics and competing with specialized learning algorithms.
paper_ai_keywords: large language models LLMs chain-of-thought prompting fine-tuning heuristic functions greedy best-first search unseen test tasks domain-independent heuristics efficient computable domain-dependent planning