arXiv:2505.10749cs.AI2025-05被引 3

用大模型生成可执行代码来规划网格世界中的智能体行为

Code-Driven Planning in Grid Worlds with Large Language Models

  • 通过代码生成构建可解释的智能体策略,替代传统搜索或强化学习
  • 在GRASP和MiniGrid上比直接生成代码提升10%至10倍,刷新GRASP纪录
  • 代码可复用,长期成本降低400倍,适合需要高效部署的场景

我们提出一种迭代式程序化规划(IPP)框架,利用大语言模型(LLMs)生成可执行代码来表达网格任务中的智能体策略。该方法不依赖传统搜索或强化学习,而是将环境状态映射为动作序列的可执行程序。框架结合了直接代码生成、伪代码引导优化及课程式提示等策略,并引入基于任务表现反馈的迭代优化机制。我们在六个主流LLM和两个具有挑战性的网格基准(GRASP与MiniGrid)上进行评估。结果显示,相较于直接代码生成,IPP在六种模型中的五种上性能提升10%至10倍,在GRASP上达到新基准。相比GPT-o3-mini直接获取解决方案,其性能提升达63%(MiniGrid)至116%(GRASP)。所有代码生成方法的计算成本相近;尽管初始提示成本较高($0.08/任务,对比$0.002/实例),但代码可无限复用,使在完整GRASP基准上的摊销成本降低400倍。

原文摘要 · Abstract (English)

We propose an iterative programmatic planning (IPP) framework for solving grid-based tasks by synthesizing interpretable agent policies expressed in code using large language models (LLMs). Instead of relying on traditional search or reinforcement learning, our approach uses code generation as policy synthesis, where the LLM outputs executable programs that map environment states to action sequences. Our proposed architecture incorporates several prompting strategies, including direct code generation, pseudocode-conditioned refinement, and curriculum-based prompting, but also includes an iterative refinement mechanism that updates code based on task performance feedback. We evaluate our approach using six leading LLMs and two challenging grid-based benchmarks (GRASP and MiniGrid). Our IPP framework demonstrates improvements over direct code generation ranging from 10\% to as much as 10x across five of the six models and establishes a new state-of-the-art result for GRASP. IPP is found to significantly outperform direct elicitation of a solution from GPT-o3-mini (by 63\% on MiniGrid to 116\% on GRASP), demonstrating the viability of the overall approach. Computational costs of all code generation approaches are similar. While code generation has a higher initial prompting cost compared to direct solution elicitation (\$0.08 per task vs. \$0.002 per instance for GPT-o3-mini), the code can be reused for any number of instances, making the amortized cost significantly lower (by 400x on GPT-o3-mini across the complete GRASP benchmark).

大模型代码生成规划网格世界

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。