arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.12714cs.SEcs.AI
收藏

评估大型语言模型在代码可维护性评估中的应用

Evaluation of large language models for assessing code maintainability

Marc Dillmann, Julien Siebert, Adam Trendowicz

AI总结:

本文评估了基于GPT2和Llama2的十个大型语言模型,发现控制逻辑代码行数时,代码交叉熵可预测类级别可维护性,但单独使用该指标仍不足以进行实际预测。

摘要:

开源软件仓库的日益普及以及利用大型语言模型(LLMs)进行代码分析的最新进展,引发了一波自动化软件工程任务的新研究浪潮,这些任务此前极难实现自动化。在本文中,我们研究了近期的一项工作,该工作假设:将大型语言模型生成代码的概率与当前代码原本应具有的概率进行比较,可以指示潜在的质量问题。我们研究了由十个不同模型(基于GPT2和Llama2)生成的代码交叉熵与以下质量方面之间的关联:可读性、可理解性、复杂性、模块化程度以及由专家评估并在基准数据集中提供的整体可维护性。我们的结果表明,在控制逻辑代码行数(LLOC)的情况下,由大型语言模型计算的交叉熵确实是类级别可维护性的预测指标(交叉熵越高,可维护性越低)。然而,当不控制LLOC时(例如,将较小的类与较长的类进行比较),这种关系会发生反转。此外,虽然大型语言模型的复杂性会影响交叉熵的范围(较小的模型往往具有更宽的交叉熵范围),但这一点在预测可维护性方面起着重要作用。我们的研究仅限于十个不同的预训练模型(基于GPT2和Llama2)以及Schnappinger等人收集的可维护性方面。在控制逻辑代码行数(LLOC)的情况下,交叉熵是可维护性的预测指标。然而,尽管相关工作已经表明交叉熵在令牌或短序列级别上具有潜在用途,但在类级别上,仅凭这一标准可能不足以预测可维护性,还需要进一步研究以在实践中充分利用这一信息。

英文摘要:

Increased availability of open-source software repositories and recent advances in code analysis using large language models (LLMs) has triggered a wave of new work to automate software engineering tasks that were previously very difficult to automate. In this paper, we investigate a recent line of work that hypothesises that comparing the probability of code generated by LLMs with the probability the current code would have had can indicate potential quality problems. We investigate the association between the cross-entropy of code generated by ten different models (based on GPT2 and Llama2) and the following quality aspects: readability, understandability, complexity, modularisation, and overall maintainability assessed by experts and available in an benchmark dataset. Our results show that, controlling for the number of logical lines of codes (LLOC), cross-entropy computed by LLMs is indeed a predictor of maintainability on a class level (the higher the cross-entropy the lower the maintainability). However, this relation is reversed when one does not control for LLOC (e.g., comparing small classes with longer ones). Furthermore, while the complexity of LLMs affects the range of cross-entropy (smaller models tend to have a wider range of cross-entropy), this plays a significant role in predicting maintainability aspects. Our study limits itself on ten different pretrained models (based on GPT2 and Llama2) and on maintainability aspects collected by Schnappinger et al. When controlling for logical lines of code (LLOC), cross-entropy is a predictor of maintainability. However, while related work has shown the potential usefulness of cross-entropy at the level of tokens or short sequences, at the class level this criterion alone may prove insufficient to predict maintainability and further research is needed to make best use of this information in practice.

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

↑