cs.SEFeb 5, 2025

Large Language Model Guided Self-Debugging Code Generation

Authors: Muntasir Adnan, Zhiwei Xu, Carlos C. N. Kuhn

Organizations: Open Source Institute, Faculty of Science and Technology, University of Canberra, Australia

Abstract

Automated code generation is gaining significant importance in intelligent computer programming and system deployment. However, current approaches often face challenges in computational efficiency and lack robust mechanisms for code parsing and error correction. In this work, we propose a novel framework, PyCapsule, with a simple yet effective two-agent pipeline and efficient self-debugging modules for Python code generation. PyCapsule features sophisticated prompt inference, iterative error handling, and case testing, ensuring high generation stability, safety, and correctness. Empirically, PyCapsule achieves up to 5.7% improvement in success rate on HumanEval, 14.6% on HumanEval-ET, and up to 24.5% on BigCodeBench compared to state-of-the-art methods. Notably, PyCapsule enables the open-source Qwen2.5-Coder-Instruct 7B model to surpass the standalone performance of GPT-4 and GPT-3.5 on HumanEval and MBPP while requiring an average of fewer than 2 API calls per problem compared to up to 17 in competing frameworks. PyCapsule demonstrates broader impacts on advancing lightweight and efficient code generation, making competitive automated programming attainable with cost-effective, locally deployable open-source models.

Figures & tables

Explore similar work

CardsList
  1. SEMAG: Self-Evolutionary Multi-Agent Code Generation

    Mar 16, 2026Yulin Peng, Haowen Hou, Xinxin Zhu +2Agentic Code GenerationLLM Code Generation

  2. ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning

    Mar 6, 2026Juyong Jiang, Jiasi Shen, Sunghun Kim +3LLM Code GenerationLLM Self-Correction

  3. A-ProS: Towards Reliable Autonomous Programming Through Multi-Model Feedback

    May 18, 2026Anika Tabassum, Md Sifat Hossain, Md. Fahim Arefin +2LLM Self-RefinementExecution-Guided Code Generation