用大模型引导自调试生成更稳定可靠的Python代码
Large Language Model Guided Self-Debugging Code Generation
- 双代理架构+迭代纠错,自动修复生成代码错误
- 在HumanEval等数据集上成功率提升最高达24.4%
- 适合需要高效可靠代码生成的AI系统开发人员
自动化代码生成在智能编程与系统部署中日益重要。然而,现有方法普遍存在计算效率低、代码解析与错误修正机制不完善的问题。本文提出一种新框架PyCapsule,采用简洁高效的双代理流水线和自调试模块,支持精细化提示推理、迭代式错误处理与案例测试,显著提升代码生成的稳定性、安全性与正确性。实验表明,PyCapsule在HumanEval上成功率达5.7%的提升,在HumanEval-ET上提升10.3%,在BigCodeBench上更是达到24.4%的改进。我们还观察到,随着自调试尝试次数增加,标准化成功率反而下降,可能受制于保留反馈中的有限且噪声较大的错误信息。PyCapsule为人工智能系统中的轻量级高效代码生成提供了更广阔的应用前景。
原文摘要 · Abstract (English)
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 of success rate on HumanEval, 10.3% on HumanEval-ET, and 24.4% on BigCodeBench compared to the state-of-art methods. We also observe a decrease in normalized success rate given more self-debugging attempts, potentially affected by limited and noisy error feedback in retention. PyCapsule demonstrates broader impacts on advancing lightweight and efficient code generation for artificial intelligence systems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。