Lode

Stand on the shoulders of giants.

Open the curator →
Source
arXiv
Published
Runtime
0:00
Snippets
4

A conversation between

Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code

Waveform of the source interview with highlighted segments per snippet.
0:00 0:00

§02

Snippets

  1. Generative compilation obtains compiler feedback on partial, incomplete programs during autoregressive generation via a sealor—a transformation that completes them for standard compilers to diagnose.

    Early error detection during generation reduces cascading mistakes and improves code correctness without requiring white-box model access.

  2. A sealor is a lightweight syntax-guided transformation that converts partial programs into semantically checkable complete ones while preserving the original code context.

    This design ensures valid partial programs are never false-positively rejected, catching real errors without noise.

  3. The sealor design is formally verified in Lean, proving that completable partial programs are never rejected and genuine dead ends are caught early.

    Mechanized verification gives strong guarantees that the feedback won't mislead the model during generation.

  4. Generative compilation makes compilers active participants during generation, detecting errors close to their source rather than as post-hoc penalties.

    Integrating compiler feedback into the generation loop itself, not after, shifts AI-assisted programming toward real-time correctness.

§03

Synthesis

The Problem: Compiler Feedback Comes Too Late

When large language models (LLMs) generate code in strict languages like Rust, they often produce non-compiling outputs. Current workflows wait until generation finishes, then run the compiler and show errors—but by then, the model has already locked in problematic choices through its autoregressive token-by-token sampling. Constrained decoding tries to prevent bad tokens earlier by rejecting them during sampling, but it requires direct access to the model's internals and custom implementations for each semantic constraint. There's a gap: what if compilers could give real-time feedback while the model is still generating?

How Generative Compilation Works

The authors' core innovation is a sealor—a transformation that converts incomplete (partial) code into complete programs that standard compilers can actually check. Think of it as a program sketcher: when an LLM has generated only half a function, the sealor fills in the missing parts minimally and syntactically, then passes the sealed program to an off-the-shelf compiler.

The trick is making this sound. A sealor must satisfy two properties: (1) any partial program that could be completed into valid code must never be sealed in a way that causes a compilation error, and (2) the sealed code preserves enough context that genuine dead ends—partial programs that truly cannot continue—are caught early rather than allowing cascading errors later.

The authors construct a sealor for a core Rust-like calculus and mechanically prove these properties in Lean, a proof assistant. They then extend it to real Rust, creating the first partial-program checker for the full language.

Results and Impact

On challenging repository-level Rust coding tasks, generative compilation reduces non-compiling outputs and improves functional correctness compared to standard post-generation feedback. The method works with both black-box frontier models (like GPT-4) and open-weight models, requiring no internal model access—making it broadly applicable.

The key win: by catching errors during generation rather than after, the approach prevents error cascades. A type mismatch detected early prevents the model from generating 20 more tokens that depend on the wrong type. Diagnostics become more focused and actionable.

More fundamentally, generative compilation shifts the compiler from a post-hoc validator into an active collaborator during the generation process. This is a step toward tighter integration of formal language semantics into AI code generation workflows, especially for languages where correctness guarantees matter.

Mine your own.

Lode is a workbench, not a feed. Paste a YouTube URL. The model proposes a transcript, a set of quote-grounded snippets, a synthesis essay, and the fan-out. You decide what stays.

Open the curator