ChatPaper.aiChatPaper

생성적 컴파일: 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 디코딩 중과 같은 중간 생성 단계를 안내하지는 않는다. 제약 디코딩은 샘플링 중에 유효하지 않은 토큰을 거부함으로써 더 일찍 개입하지만, 화이트박스 모델 접근과 의미적 제약에 대한 비용이 많이 드는 재구현이 필요하다. 우리는 생성 중 부분 프로그램에 대한 컴파일러 피드백을 얻는 최초의 접근 방식인 생성적 컴파일을 소개한다. 핵심 기술 장치는 실러(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.