RECODE: Leveraging Reliable Self-generated Tests and Fine-Grained Execution Feedback to Enhance LLM-Based Code Generation
摘要
Large language models (LLMs) have demonstrated remarkable potential in automated code generation, yet their performance on complex tasks is constrained by unreliable self-generated test cases and coarse refinement feedback. To address these challenges, we propose RECODE, a novel framework that enhances LLM-based code generation through three key innovations: (1) multi-candidate cross-validation to select reliable self-generated test cases via majority voting, (2) static common pattern extraction to enhance code generation by leveraging syntactic consensus from diverse candidates, and (3) Control Flow Graph (CFG)-based in-execution debugging that decomposes code into basic blocks and tracks variable state changes during execution, providing fine-grained feedback to the LLM for iterative code refinement. We evaluate RECODE on the HumanEval and MBPP benchmarks using five LLMs: GPT-3.5-turbo, GPT-4o-mini, DeepSeek-V3, Claude-3.5-sonnet, and Qwen2.5-Coder-7B-Instruct. Experimental results show that RECODE significantly improves Pass@1 by an average of 5.82% over the baseline. The static pattern enhancement achieves up to 5.40% improvement on HumanEval, while CFG-based debugging yields gains of up to 13.9%. Additionally, RECODE reduces bias in self-generated test cases while maintaining high test coverage. Its combination of static analysis and dynamic execution insights enhances error localization and repair. By demonstrating scalability across diverse LLMs, RECODE establishes itself as a robust solution for autonomous code generation in real-world programming environments.