arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.06327cs.SE
收藏

LLM生成的Python代码中低效性的分类体系

A Taxonomy of Inefficiencies in LLM-Generated Python Code

Altaf Allah Abbassi, Leuson Da Silva, Amin Nikanjam, Foutse Khomh

AI总结:

本研究实证分析了CodeLlama等模型生成的492个代码片段,构建了包含5个类别和19个子类别的LLM生成代码低效性分类体系,并通过58名从业者验证,发现逻辑与性能低效性最普遍且影响整体质量,为代码生成优化提供了结构化基础。

摘要:

大型语言模型(LLMs)被广泛用于自动化代码生成,并取得了可喜的成果。尽管先前的研究评估了LLM生成的代码并识别了各种质量问题——例如冗余、可维护性差和性能次优,但对这些低效性的系统理解和分类仍未被探索。缺乏这些知识,从业者难以针对实际应用优化LLM生成的代码,从而限制了其应用。本研究还可以指导改进代码LLM,提升代码生成的质量和效率。因此,在本研究中,我们实证调查了最先进模型(即CodeLlama、DeepSeek-Coder和CodeGemma)生成代码中的低效性。为此,我们分析了HumanEval++数据集中的492个生成代码片段。随后,我们构建了LLM生成代码低效性的分类体系,包含5个类别(通用逻辑、性能、可读性、可维护性和错误)以及19个低效性子类别。然后,我们通过对58位LLM从业者和研究人员的在线调查验证了所提出的分类体系。我们的研究表明,逻辑和性能相关的低效性最为普遍、相关且频繁共现,并影响整体代码质量的低效性。我们的分类体系为评估LLM生成代码的质量提供了结构化基础,并指导未来研究提升代码生成效率。

英文摘要:

Large Language Models (LLMs) are widely adopted for automated code generation with promising results. Although prior research has assessed LLM-generated code and identified various quality issues -- such as redundancy, poor maintainability, and sub-optimal performance a systematic understanding and categorization of these inefficiencies remain unexplored. Without such knowledge, practitioners struggle to optimize LLM-generated code for real-world applications, limiting its adoption. This study can also guide improving code LLMs, enhancing the quality and efficiency of code generation. Therefore, in this study, we empirically investigate inefficiencies in LLM-generated code by state-of-the-art models, i.e., CodeLlama, DeepSeek-Coder, and CodeGemma. To do so, we analyze 492 generated code snippets in the HumanEval++ dataset. We then construct a taxonomy of inefficiencies in LLM-generated code that includes 5 categories General Logic, Performance, Readability, Maintainability, and Errors) and 19 subcategories of inefficiencies. We then validate the proposed taxonomy through an online survey with 58 LLM practitioners and researchers. Our study indicates that logic and performance-related inefficiencies are the most popular, relevant, and frequently co-occur and impact overall code quality inefficiency. Our taxonomy provides a structured basis for evaluating the quality LLM-generated code and guiding future research to improve code generation efficiency.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑