生成的コンパイル: AIがコード生成時に提供するオンザフライコンパイラフィードバック
Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code
July 15, 2026
著者: Niels Mündler-Sasahara, Hristo Venev, Dawn Song, Martin Vechev, Jingxuan He
cs.AI
要旨
豊かな静的セマンティクスを持つ言語(例えばRust)は、AI生成コードに対してより強力な保証を提供するが、その厳密さゆえに生成はより困難になる。既存のコンパイラは生成後の有用なフィードバックを提供できるが、自己回帰型LLMデコーディングの途中段階など、生成の中間ステップを導くことはできない。制約付きデコーディングは、サンプリング中に無効なトークンを拒否することでより早い段階で介入するが、ホワイトボックスモデルへのアクセスと、意味的制約に対するコストのかかる再実装を必要とする。我々は、生成コンパイル(generative compilation)を導入する。これは、生成中に部分プログラムに対してコンパイラフィードバックを得る初めてのアプローチである。中核となる技術はシーラー(sealor)である。これは軽量で、主に構文に基づく変換であり、部分プログラムを標準的なコンパイラが診断可能な完全なプログラムに変換する。これは、完了可能な部分プログラムが決して拒否されず、かつ、早期に真の行き詰まりを検出するために十分なコードコンテキストを保持するように設計されている。我々は、Rustに類似したコア計算体系上にそのようなシーラーを構築し、それがこれらの特性を満たすことをLeanで形式化・証明する。さらに、現実のRust向け初の部分プログラムチェッカーへと拡張する。我々は、最先端のブラックボックスモデルとオープンウェイトモデルの両方を用いて、挑戦的なリポジトリレベルのRustコーディングタスクで本手法を評価する。生成コンパイルが、標準的な生成後フィードバックと比較して、非コンパイル出力を減少させ、機能的正当性を向上させることを示す。これは、エラーの発生源に近い場所で、かつ生成の早い段階で広範囲のエラーを検出することで、エラーの連鎖を減らし、焦点を絞った診断を可能にする。より広く言えば、生成コンパイルは、コンパイラを、生成後の別個のチェックではなく、生成中に能動的に関与するAI支援プログラミングの第一級市民とするための一歩である。
English
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.