The capability of accurately determining code similarity is crucial in many tasks related to software development. For example, it might be essential to identify code duplicates for performing software maintenance. This research introduces a novel ensemble learning approach for code similarity assessment, combining the strengths of multiple unsupervised similarity measures. The key idea is that the strengths of a diverse set of similarity measures can complement each other and mitigate individual weaknesses, leading to improved performance. Preliminary results show that while Transformers-based CodeBERT and its variant GraphCodeBERT are undoubtedly the best option in the presence of abundant training data, in the case of specific small datasets (up to 500 samples), our ensemble achieves similar results, without prejudice to the interpretability of the resulting solution, and with a much lower associated carbon footprint due to training. The source code of this novel approach can be downloaded from https://github.com/jorge-martinez-gil/ensemble-codesim.
翻译:准确判定代码相似性的能力在软件开发相关的诸多任务中至关重要。例如,识别代码重复对执行软件维护工作可能具有关键意义。本研究提出一种用于代码相似性评估的新型集成学习方法,该方法融合了多种无监督相似度度量的优势。其核心思想在于:多样化相似度度量集合的优势能够相互补充并缓解个体缺陷,从而提升整体性能。初步结果表明,尽管基于Transformer的CodeBERT及其变体GraphCodeBERT在训练数据充足时无疑是最佳选择,但在特定小规模数据集(不超过500个样本)场景下,我们的集成方法能够取得相近的结果,同时不损害解决方案的可解释性,且因训练过程产生的碳足迹显著降低。该新方法的源代码可从https://github.com/jorge-martinez-gil/ensemble-codesim下载。