生成式编译:人工智能生成代码时的即时编译器反馈
Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code
浏览论文内容
中文总结 AI 辅助
研究针对人工智能生成代码时的问题,提出生成式编译方法,核心是sealor技术,能在生成中获取编译器反馈,在Rust编码任务中评估,减少非编译输出、提高功能正确性,使编译器在生成阶段发挥更重要作用。
中文摘要 AI 辅助
具有丰富静态语义的语言(如Rust)能为人工智能生成的代码提供更强保障,但严格性增加了生成难度。现成编译器能在生成后提供反馈,但无法指导中间生成步骤。约束解码虽能提前干预,但需要白盒模型访问且重新实现成本高。本文引入生成式编译,这是一种在生成过程中获取编译器对部分程序反馈的方法。核心技术是sealor,它将部分程序转换为标准编译器可诊断的完整程序。在核心类Rust演算上构建并证明其满足相关属性,扩展到真实Rust的首个部分程序检查器。在具有挑战性的仓库级Rust编码任务上评估,结果表明生成式编译相对于标准生成后反馈减少了非编译输出并提高了功能正确性,能在生成早期检测多种错误,减少错误级联并实现聚焦诊断,朝着使编译器成为人工智能辅助编程中生成阶段的一等公民迈进。
英文摘要
Languages with rich static semantics, such as Rust, provide stronger guarantees for AI-generated code, but their strictness makes generation more difficult. Off-the-shelf compilers can provide useful feedback post-generation, but does not guide intermediate generation steps, such as those during autoregressive LLM decoding. Constrained decoding intervenes earlier by rejecting invalid tokens during sampling, but requires white-box model access and costly reimplementation for semantic constraints. We introduce generative compilation, the first approach to obtaining compiler feedback on partial programs during generation. The core technical device is a sealor: a lightweight, mostly syntax-guided transformation that converts partial programs into complete ones that standard compilers can diagnose. It is designed such that possible-to-complete partial programs are never rejected, while preserving enough code context to catch genuine dead ends early. We construct such a sealor on a core Rust-like calculus and prove that it satisfies these properties, all mechanized in Lean. We extend it to the first partial-program checker for real Rust. We evaluate our method on challenging repository-level Rust coding tasks, across both frontier black-box and open-weight models. We show that generative compilation reduces non-compiling outputs and improves functional correctness, relative to standard post-generation feedback. It does so by detecting a broad range of errors close to their source and early during generation, thereby reducing errors cascades and enabling focused diagnostics. More broadly, generative compilation is a step toward making compilers a first-class citizen of AI-assisted programming active during generation, rather than a separate post-generation check.
发表机构
- ETH Zurich(苏黎世联邦理工学院)
- Sofia University ``St. Kliment Ohridski''(索菲亚大学)
- University of California, Berkeley(加州大学伯克利分校)
机构由 AI 辅助整理,请以论文原文为准。