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

评估小型语言模型在检测重构缺陷中的有效性

Evaluating the Effectiveness of Small Language Models in Detecting Refactoring Bugs

Rohit Gheyi, Marcio Ribeiro, Jonhnanthan Oliveira

AI总结:

本研究评估小型语言模型在检测Java和Python重构缺陷中的有效性,发现o3-mini-high和Phi-4 14B表现最佳,SLMs能高效检测行为变化缺陷并跨类型泛化。

摘要:

流行的集成开发环境(IDE)在其重构实现中经常包含缺陷。确保转换保持程序行为是一项复杂的任务。传统的检测方法依赖于为每种重构类型预定义的前置条件,这限制了它们的可扩展性和对新转换的适应性。这些方法通常需要大量的静态和动态分析,这些分析计算成本高、耗时,并且可能仍然无法检测到某些重构缺陷。本研究评估了小型语言模型(SLMs)在检测Java和Python中两类重构缺陷的有效性:(i)引入错误或行为变化的转换(类型I)和(ii)尽管有效但被IDE不必要阻止的转换(类型II)。我们评估了Llama 3.2 3B、Mistral 7B、Gemma 2 9B、Gemma 3 12B、DeepSeek-R1 14B、Phi-4 14B、o1-mini和o3-mini-high是否能准确检测在广泛使用的Java和Python IDE(如Eclipse和NetBeans)中报告的100个重构缺陷。该研究涵盖16种重构类型,并在消费级硬件上采用零样本提示来评估模型在没有显式先前训练的情况下推理重构正确性的能力。专有的o3-mini-high模型达到了最高的检测率,识别了84.3%的类型I缺陷。开源Phi-4 14B表现同样出色,在两类缺陷上都显示出强大的有效性。然而,o3-mini-high在类型II缺陷上表现不佳,仅在40%的情况下正确识别并应用了有效但被阻止的转换。研究结果突显了SLMs在高效检测重构缺陷方面的潜力,特别是在验证行为变化方面。此外,SLMs提供了一种更适应性的解决方案,能够跨不同重构类型和编程语言进行泛化,解决了传统方法的关键局限性。

英文摘要:

Popular IDEs frequently contain bugs in their refactoring implementations. Ensuring that a transformation preserves a program's behavior is a complex task. Traditional detection methods rely on predefined preconditions for each refactoring type, limiting their scalability and adaptability to new transformations. These methods often require extensive static and dynamic analyses, which are computationally expensive, time-consuming, and may still fail to detect certain refactoring bugs. This study evaluates the effectiveness of Small Language Models (SLMs) in detecting two types of refactoring bugs in Java and Python: (i) transformations that introduce errors or behavioral changes (Type I) and (ii) transformations unnecessarily blocked by IDEs despite being valid (Type II). We assess whether Llama 3.2 3B, Mistral 7B, Gemma 2 9B, Gemma 3 12B, DeepSeek-R1 14B, Phi-4 14B, o1-mini, and o3-mini-high can accurately detect 100 refactoring bugs reported in widely used Java and Python IDEs, such as Eclipse and NetBeans. The study covers 16 refactoring types and employs zero-shot prompting on consumer-grade hardware to evaluate the models' ability to reason about refactoring correctness without explicit prior training. The proprietary o3-mini-high model achieved the highest detection rate, identifying 84.3% of Type I bugs. The open-source Phi-4 14B performed comparably well, demonstrating strong effectiveness across both bug types. However, o3-mini-high struggled with Type II bugs, correctly identifying and applying valid but blocked transformations in only 40% of cases. The findings highlight the potential of SLMs for efficiently detecting refactoring bugs, particularly in verifying behavioral changes. Additionally, SLMs offer a more adaptable solution capable of generalizing across different refactoring types and programming languages, addressing key limitations of traditional approaches.

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

↑