arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2412.18989cs.SEcs.AI
收藏

大型语言模型产生代码坏味的倾向性如何?一项基准测试研究

How Propense Are Large Language Models at Producing Code Smells? A Benchmarking Study

William & Mary(威廉与玛丽学院);University of Dhaka(达卡大学)

Alejandro Velasco, Daniel Rodriguez-Cardenas, Luftar Rahman Alif, David N. Palacio, Denys Poshyvanyk

AI总结:

本研究提出CodeSmellEval基准及PSC指标,评估LLMs生成代码坏味的倾向,案例研究发现CodeLlama和Mistral均易产生此类问题,为模型质量评估提供新视角。

摘要:

大型语言模型(LLMs)在自动化软件工程任务方面显示出巨大潜力,尤其是在代码生成方面。然而,当前主要关注准确性的评估基准在评估这些模型生成的代码质量方面存在不足,特别是它们产生代码坏味的倾向。为解决这一局限,我们引入了CodeSmellEval,一个旨在评估LLMs生成代码坏味倾向的基准。我们的基准包含一个新指标:倾向性坏味得分(PSC),以及一个精心策划的方法级代码坏味数据集:CodeSmellData。为展示CodeSmellEval的用途,我们使用两个最先进的LLMs(CodeLlama和Mistral)进行了一项案例研究。结果表明,这两个模型都倾向于生成代码坏味,如可简化条件和考虑合并isinstance。这些发现凸显了我们的基准在评估LLMs方面的有效性,为它们在代码生成任务中的可靠性及引入代码坏味的倾向提供了宝贵见解。

英文摘要:

Large Language Models (LLMs) have shown significant potential in automating software engineering tasks, particularly in code generation. However, current evaluation benchmarks, which primarily focus on accuracy, fall short in assessing the quality of the code generated by these models, specifically their tendency to produce code smells. To address this limitation, we introduce CodeSmellEval, a benchmark designed to evaluate the propensity of LLMs for generating code smells. Our benchmark includes a novel metric: Propensity Smelly Score (PSC), and a curated dataset of method-level code smells: CodeSmellData. To demonstrate the use of CodeSmellEval, we conducted a case study with two state-of-the-art LLMs, CodeLlama and Mistral. The results reveal that both models tend to generate code smells, such as simplifiable-condition and consider-merging-isinstance. These findings highlight the effectiveness of our benchmark in evaluating LLMs, providing valuable insights into their reliability and their propensity to introduce code smells in code generation tasks.

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

↑