ISoLA & AISoLA 2026

International Symposium on Leveraging Applications of Formal Methods, Verification, and Validation • Kos, Greece

Talk

Optimizing LLM-Driven Code Generation and Repair via RAG and Iterative Compiler Feedback

Time: Wednesday, 28.10

Room: Room 2

Authors: Ankit Singh, Moez Ben HajHmida, Edward Lee

Abstract: Large Language Models (LLMs) have shown considerable promise for automated code generation, yet they continue to falter when confronted with domain-specific languages and multi-language compilation requirements, commonly yielding subtle syntax errors or scope violations. To mitigate this limitation, we introduce an iterative Retrieval-Augmented Generation (RAG) pipeline enhanced by a compiler-in-the-loop feedback mechanism. Rather than relying solely on static retrieval, our approach captures compiler diagnostics from initial generation attempts and uses them to retrieve and inject targeted, error-specific context into subsequent prompts, enabling the LLM to iteratively refine and correct the generated code. We assess the effectiveness of this orchestration framework along two key dimensions: the granularity of context retrieval and scalability with respect to codebase complexity, using Lingua Franca (LF) as our target language. Experimental results demonstrate substantial gains in syntax correctness and execution success rates, underscoring the efficacy of the proposed pipeline.