一句话:提出 MRT-OAST,通过优化 AST 多表示与孪生网络,实现高效且准确的代码克隆检测。
现有基于深度学习的代码克隆检测存在两个问题:AST 等代码表示信息利用率低、冗余严重,导致性能下降;评估时克隆检测效率低,实际使用时间成本过高。为此,本文提出 MRT-OAST,一种多表示 Transformer 与优化抽象语法树方法。该方法对 AST 进行策略性剪枝和增强,并利用前序与后序遍历构造两种表示,以保留结构信息;同时采用纯 Siamese 网络和余弦相似度比较代码相似性,加速评估。实验表明,该方法在 Java 和 C/C++ 中将 AST 序列分别压缩至原长度的 40% 和 39%;在 OJClone 与 Google Code Jam 上超越现有最优方法;在 BigCloneBench 上相比最优轻量模型提速 5 倍、相比 BERT 模型提速 563 倍,F1 值仅分别下降 0.3% 和 0.9%。
Over the past decade, the application of deep learning in code clone detection has produced remarkable results. However, the current approaches have two limitations: (a) code representation approaches with low information utilization, such as vanilla Abstract Syntax Tree (AST), leading to information redundancy which results in performance degradation; (b) low efficiency of clone detection on evaluation, resulting in excessive time costs during practical use. In this paper, we propose a Multiple Representation Transformer with an Optimized Abstract Syntax Tree (MRT-OAST) to introduce an efficient code representation method while achieving competitive performance. Specifically, MRT-OAST strategically prunes and enhances the AST, utilizing both pre-order and post-order traversals to represent two different representations. To speed up the evaluation process, MRT-OAST utilizes a pure Siamese Network and employs cosine similarity to compare the similarity between codes. Our approach effectively reduces AST sequences to 40 % and 39 % of their original length in Java and C/C++ while preserving structural information. In code clone detection tasks, our model surpasses state-of-the-art approaches on OJClone and Google Code Jam. During the evaluation of BigCloneBench, our model has a 5x speed improvement compared to the state-of-the-art lightweight model and a 563x speed improvement compared to the BERT-based model, with only a 0.3 % and 0.9 % decrease in$F_{1}$-score.
DOI 原文 ·
@inproceedings{paperbot8918,
title = {A Multiple Representation Transformer with Optimized Abstract Syntax Tree for Efficient Code Clone Detection},
author = {Tianchen Yu and Li Yuan and Liannan Lin and Hongkui He},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00050}
}