# Large Language Model Guided Self-Debugging Code Generation

DevFeed: [Large Language Model Guided Self-Debugging Code Generation](<https://devfeed.tech/articles/large-language-model-guided-self-debugging-code-generation-113454.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2502.02928>)

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

Published: 2026-11-03T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Large Language Model](<https://devfeed.tech/topics/llm.md>), [LLM evaluation / benchmarking](<https://devfeed.tech/topics/llm-evaluation-benchmarking.md>), [Code quality](<https://devfeed.tech/topics/code-quality.md>)

Tags: [agent](<https://devfeed.tech/tags/agent.md>), [api](<https://devfeed.tech/tags/api.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [cs-ai](<https://devfeed.tech/tags/cs-ai.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [error](<https://devfeed.tech/tags/error.md>), [error-correction](<https://devfeed.tech/tags/error-correction.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [framework](<https://devfeed.tech/tags/framework.md>), [gpt](<https://devfeed.tech/tags/gpt.md>), [gpt-4](<https://devfeed.tech/tags/gpt-4.md>), [humaneval](<https://devfeed.tech/tags/humaneval.md>), [improvement](<https://devfeed.tech/tags/improvement.md>), [inference](<https://devfeed.tech/tags/inference.md>), [large-language-model](<https://devfeed.tech/tags/large-language-model.md>), [lightweight](<https://devfeed.tech/tags/lightweight.md>), [mbpp](<https://devfeed.tech/tags/mbpp.md>), [models](<https://devfeed.tech/tags/models.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [parsing](<https://devfeed.tech/tags/parsing.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

PyCapsule uses a two-agent pipeline with prompt inference, iterative error handling, and case testing to generate and self-debug Python code. The abstract reports success-rate gains of up to 5.7% on HumanEval, 14.6% on HumanEval-ET, and 24.5% on BigCodeBench versus state-of-the-art methods. It also reports that Qwen2.5-Coder-Instruct 7B surpasses standalone GPT-4 and GPT-3.5 on HumanEval and MBPP, averaging fewer than two API calls per problem compared with up to 17 in competing frameworks. These are abstract-reported results; the supplied excerpt does not provide evaluation details.

## Source excerpt

arXiv:2502.02928v3 Announce Type: replace 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.