arXiv:2605.15334cs.LGcs.AI2026-05被引 1

用AI从输入输出推程序,让代码生成更智能可靠。

From I/O to Code with Discovery Agent

论文配图:From I/O to Code with Discovery Agent
图 1 · 摘自论文原文
  • 把代码生成当进化搜索,用大模型试错并靠执行反馈修正。
  • 在多个难度级别上超越现有方法,简单逻辑优先避免复杂错误。
  • 适合需要自动写代码的开发者和研究者,尤其处理模糊需求时。

从任意规格自动生成程序是计算机科学的终极目标。尽管自然语言转代码(NL2Code)因大模型取得显著进展,但从输入输出行为生成代码(即IO2Code)这一更难的任务仍基本未解。与依赖预训练语义对齐的NL2Code不同,IO2Code需从具体计算行为中还原底层规律,在庞大且不明确的假设空间中探索。为此,我们提出DIO-Agent,一种面向IO2Code的发现代理。该方法将IO2Code建模为离散程序空间上的演化搜索,以大模型作为变异算子,利用执行产生的具体错误信号指导每次变异。为防止搜索陷入结构复杂但错误的死胡同,引入变换优先原则作为变异先验,引导大模型优先尝试最简单的符合当前证据的假设,仅在简单构造不足时才逐步引入常量、条件、循环等复杂结构。为促进系统性研究,我们构建了涵盖多难度层级的IO2CodeBench。大量实验表明,DIO-Agent在所有难度层级和多种大模型上均持续优于传统程序示例法及当前最优演化代理基线,且在同等采样预算下显著超越测试时扩展策略。

原文摘要 · Abstract (English)

The automatic synthesis of a program from any form of specification is regarded as a holy grail of computer science. Fueled by LLMs, NL2Code has achieved tremendous success, yet the fundamentally more challenging task of synthesizing programs from input-output behavior, which we refer to as IO2Code, remains largely unsolved. Whereas NL2Code can exploit the semantic alignment between natural language and code acquired during pretraining, IO2Code requires recovering underlying principles from concrete computational behavior, navigating a vast and underspecified hypothesis space. To address this, we propose DIO-Agent, a discovery agent for IO2Code. Our method frames IO2Code as an evolutionary search over discrete program space, in which an LLM serves as the mutation operator and concrete error signals from execution guide each mutation. To prevent the search from wandering into structurally complex yet incorrect dead ends, we introduce the Transformation Priority Premise as a mutation prior that biases the LLM toward the simplest hypothesis consistent with current evidence, progressively escalating from constants to conditionals to iteration only when simpler constructs are insufficient. To facilitate systematic study, we further construct an IO2CodeBench spanning multiple difficulty levels. Extensive experiments show that DIO-Agent consistently outperforms both traditional program-by-example method and SOTA evolution-agent baselines across all difficulty levels and various LLMs, while substantially surpassing test-time scaling strategies with equivalent sampling budgets.

代码生成大模型智能搜索

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