arXiv:2510.15480cs.SEcs.AI2025-10

筛选并组合大模型提升代码克隆检测精度,效果超单模型一倍。

Selecting and Combining Large Language Models for Scalable Code Clone Detection

  • 从76个大模型中筛选出适合克隆检测的候选模型。
  • 最佳组合模型在商用数据集上达46.91%准确率,是CodeBERT的两倍。
  • 小嵌入尺寸和定制数据集更有利于模型表现,适合工业级应用。

源代码克隆可能引发知识产权侵权和潜在漏洞风险。针对多样化克隆的有效且可扩展的检测仍具挑战性。近期大语言模型(LLMs)被应用于克隆检测任务。面对快速涌现的模型,本文首先评估了76个大模型,并基于BigCloneBench及一个商业大规模数据集筛选出适合的候选模型。结果显示无统一最优模型,但CodeT5+110M、CuBERT与SPTCode表现领先。分析表明,较小的嵌入维度、更小的分词器词汇量以及定制训练数据具有优势。在商业数据集上,表现最优的CodeT5+110M达到39.71%精确率,是此前CodeBERT的两倍。其次,本文探索所选模型的集成策略:通过有效方法提升检测性能。结果表明,分数归一化至关重要,采用最大值或求和集成优于平均法。在更大规模数据集上,集成方法显著有效,最佳集成模型达到46.91%精确率,超越单个模型表现。

原文摘要 · Abstract (English)

Source code clones pose risks ranging from intellectual property violations to unintended vulnerabilities. Effective and efficient scalable clone detection, especially for diverged clones, remains challenging. Large language models (LLMs) have recently been applied to clone detection tasks. However, the rapid emergence of LLMs raises questions about optimal model selection and potential LLM-ensemble efficacy. This paper addresses the first question by identifying 76 LLMs and filtering them down to suitable candidates for large-scale clone detection. The candidates were evaluated on two public industrial datasets, BigCloneBench, and a commercial large-scale dataset. No uniformly 'best-LLM' emerged, though CodeT5+110M, CuBERT and SPTCode were top-performers. Analysis of LLM-candidates suggested that smaller embedding sizes, smaller tokenizer vocabularies and tailored datasets are advantageous. On commercial large-scale dataset a top-performing CodeT5+110M achieved 39.71\% precision: twice the precision of previously used CodeBERT. To address the second question, this paper explores ensembling of the selected LLMs: effort-effective approach to improving effectiveness. Results suggest the importance of score normalization and favoring ensembling methods like maximum or sum over averaging. Also, findings indicate that ensembling approach can be statistically significant and effective on larger datasets: the best-performing ensemble achieved even higher precision of 46.91\% over individual LLM on the commercial large-scale code.

代码检测大模型集成学习工业应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。