Code smells are suboptimal coding practices that negatively impact the quality of software systems. Existing detection methods, relying on heuristics or Machine Learning (ML) and Deep Learning (DL) techniques, often face limitations such as unsatisfactory performance. Parameter-Efficient Fine-Tuning (PEFT) methods have emerged as a resource-efficient approach for adapting LLMs to specific tasks, but their effectiveness for method-level code smell detection remains underexplored. In this regard, this study evaluates state-of-the-art PEFT methods on both small and large Language Models (LMs) for detecting two types of method-level code smells: Complex Conditional and Complex Method. Using high-quality datasets sourced from GitHub, we fine-tuned four small LMs and six LLMs with PEFT techniques, including prompt tuning, prefix tuning, LoRA, and (IA)3. Results show that PEFT methods achieve comparable or better performance than full fine-tuning while consuming less GPU memory. Notably, LLMs did not outperform small LMs, suggesting smaller models' suitability for this task. Additionally, increasing training dataset size significantly boosted performance, while increasing trainable parameters did not. Our findings highlight PEFT methods as effective and scalable solutions, outperforming existing heuristic-based and DL-based detectors.
翻译:代码异味是影响软件系统质量的次优编码实践。现有检测方法依赖启发式规则或机器学习与深度学习技术,常面临性能不足等局限。参数高效微调方法已成为将大语言模型适配特定任务的高效资源利用方案,但其在方法级代码异味检测中的有效性尚未得到充分探索。为此,本研究评估了前沿参数高效微调方法在小型与大型语言模型上对两类方法级代码异味的检测效果:复杂条件语句与复杂方法。基于从GitHub获取的高质量数据集,我们采用提示微调、前缀微调、低秩适应及注入适配器等参数高效微调技术,对四个小型语言模型和六个大语言模型进行微调。实验结果表明,参数高效微调方法在消耗更少GPU内存的同时,取得了与全参数微调相当或更优的性能。值得注意的是,大语言模型并未超越小型语言模型,这暗示了较小模型对此任务的适用性。此外,增加训练数据集规模能显著提升性能,而增加可训练参数则无此效果。我们的研究结果凸显了参数高效微调方法作为高效可扩展解决方案的优越性,其性能超越了现有基于启发式规则和深度学习的检测器。