arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2505.08263cs.SE
收藏

基于LLM的纠缠代码变更检测,用于更高质量的方法级缺陷数据集

LLM-Based Detection of Tangled Code Changes for Higher-Quality Method-Level Bug Datasets

University of Manitoba(曼尼托巴大学)

Md Nahidul Islam Opu, Shaowei Wang, Shaiful Chowdhury

AI总结:

本研究利用LLM结合提交信息与代码差异,通过少样本和思维链提示检测方法级纠缠代码变更,F1达0.883,并验证了该方法对提升缺陷数据集质量的贡献。

摘要:

纠缠代码变更,即提交中混杂了无关修改(如缺陷修复、重构和功能增强),会给缺陷数据集引入显著噪声,并对缺陷预测模型的性能产生不利影响。在细粒度的方法级粒度上解决这一问题仍未得到探索。解决这一问题至关重要,因为近年来,受从业者需求驱动,缺陷预测模型越来越关注更细的粒度,而非传统的类级或文件级预测。本研究探讨了利用大型语言模型(LLMs)通过结合提交信息和方法级代码差异来检测纠缠代码变更的效用。我们将该问题表述为二分类任务,并使用最先进的专有LLMs(如GPT-5和Gemini-2.0-Flash)以及开源模型(如GPT-OSS-120B和CodeBERT)评估了多种提示策略,包括零样本、少样本和思维链提示。我们的结果表明,将提交信息与代码差异相结合能显著提升模型性能,其中少样本与思维链提示的组合实现了0.883的F1分数。此外,我们探索了在LLM生成的嵌入上训练的机器学习模型,其中多层感知器分类器取得了优越的性能(F1分数:0.906,MCC:0.807)。将我们的方法应用于49个开源项目,改善了缺陷方法与非缺陷方法之间代码指标的分布可分离性,展示了LLMs在方法级提交解缠方面的潜力,并可能有助于提高未来缺陷预测模型的准确性。

英文摘要:

Tangled code changes, commits that conflate unrelated modifications such as bug fixes, refactorings, and enhancements, introduce significant noise into bug datasets and adversely affect the performance of bug prediction models. Addressing this issue at a fine-grained, method-level granularity remains unexplored. This is critical to address, as recent bug prediction models, driven by practitioner demand, are increasingly focusing on finer granularity rather than traditional class- or file-level predictions. This study investigates the utility of Large Language Models (LLMs) for detecting tangled code changes by leveraging both commit messages and method-level code diffs. We formulate the problem as a binary classification task and evaluate multiple prompting strategies, including zero-shot, few-shot, and chain-of-thought prompting, using state-of-the-art proprietary LLMs such as GPT-5 and Gemini-2.0-Flash, and open-source models such as GPT-OSS-120B and CodeBERT. Our results demonstrate that combining commit messages with code diffs significantly enhances model performance, with the combined few-shot and chain-of-thought prompting achieving an F1-score of 0.883. Additionally, we explore machine learning models trained on LLM-generated embeddings, where a multi-layer perceptron classifier achieves superior performance (F1-score: 0.906, MCC: 0.807). Applying our approach to 49 open-source projects improves the distributional separability of code metrics between buggy and non-buggy methods, demonstrating the promise of LLMs for method-level commit untangling and potentially contributing to improving the accuracy of future bug prediction models.

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

↑