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

使用语言模型进行代码检查

Code Linting using Language Models

Darren Holden, Nafiseh Kahani

AI总结:

本文研究使用大型语言模型开发通用代码检查器,通过训练二分类和多标签分类器,分别达到84.9%和83.6%的准确率,实现语言无关、多问题类型检测。

摘要:

代码检查器在开发高质量软件系统中发挥着关键作用,通过检测系统源代码中的潜在问题(例如内存泄漏)来保障质量。尽管有其益处,代码检查器通常针对特定语言,聚焦于某些类型的问题,并且为了速度而容易产生误报。本文研究是否可以利用大型语言模型来开发一个更加通用的代码检查器。这样的检查器预期是语言无关的,覆盖多种问题类型,并保持高速度。为了实现这一目标,我们收集了一个大型的代码片段及其相关问题数据集。然后,我们选择了一个语言模型,并基于收集的数据集训练了两个分类器。第一个是二分类器,用于检测代码是否存在问题;第二个是多标签分类器,用于识别问题的类型。通过广泛的实验研究,我们证明了所开发的基于大型语言模型的检查器在二分类器上可以达到84.9%的准确率,在多标签分类器上可以达到83.6%的准确率。

英文摘要:

Code linters play a crucial role in developing high-quality software systems by detecting potential problems (e.g., memory leaks) in the source code of systems. Despite their benefits, code linters are often language-specific, focused on certain types of issues, and prone to false positives in the interest of speed. This paper investigates whether large language models can be used to develop a more versatile code linter. Such a linter is expected to be language-independent, cover a variety of issue types, and maintain high speed. To achieve this, we collected a large dataset of code snippets and their associated issues. We then selected a language model and trained two classifiers based on the collected datasets. The first is a binary classifier that detects if the code has issues, and the second is a multi-label classifier that identifies the types of issues. Through extensive experimental studies, we demonstrated that the developed large language model-based linter can achieve an accuracy of 84.9% for the binary classifier and 83.6% for the multi-label classifier.

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

↑