arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2308.13754cs.SEcs.CLcs.IR
收藏

ZC3:零样本跨语言代码克隆检测

ZC3: Zero-Shot Cross-Language Code Clone Detection

Peking University(北京大学);Beihang University(北京航空航天大学)

Jia Li, Chongyang Tao, Zhi Jin, Fang Liu, Jia Li, Ge Li

AI总结:

提出零样本跨语言代码克隆检测方法ZC3,通过对比片段预测、领域感知与循环一致性学习构建跨语言对齐表示,在四个数据集上显著超越基线。

摘要:

开发者引入代码克隆以提高编程生产力。许多现有研究在单语言代码克隆检测中取得了令人印象深刻的性能。然而,在软件开发过程中,越来越多的开发者使用不同语言编写语义等价的程序,以支持不同平台并帮助开发者将项目从一种语言翻译为另一种语言。考虑到收集跨语言平行数据,特别是对于低资源语言,既昂贵又耗时,如何设计一个不依赖任何平行数据的有效跨语言模型是一个重要问题。在本文中,我们提出了一种名为ZC3的新方法,用于零样本跨语言代码克隆检测。ZC3设计了对比片段预测,以在不同编程语言之间形成同构表示空间。在此基础上,ZC3利用领域感知学习和循环一致性学习,进一步约束模型生成在不同语言间对齐、同时又能区分不同类型克隆的表示。为了评估我们的方法,我们在四个代表性的跨语言克隆检测数据集上进行了广泛实验。实验结果表明,ZC3在MAP分数上分别比最先进的基线高出67.12%、51.39%、14.85%和53.01%。我们进一步研究了不同语言的表示分布,并讨论了我们方法的有效性。

英文摘要:

Developers introduce code clones to improve programming productivity. Many existing studies have achieved impressive performance in monolingual code clone detection. However, during software development, more and more developers write semantically equivalent programs with different languages to support different platforms and help developers translate projects from one language to another. Considering that collecting cross-language parallel data, especially for low-resource languages, is expensive and time-consuming, how designing an effective cross-language model that does not rely on any parallel data is a significant problem. In this paper, we propose a novel method named ZC3 for Zero-shot Cross-language Code Clone detection. ZC3 designs the contrastive snippet prediction to form an isomorphic representation space among different programming languages. Based on this, ZC3 exploits domain-aware learning and cycle consistency learning to further constrain the model to generate representations that are aligned among different languages meanwhile are diacritical for different types of clones. To evaluate our approach, we conduct extensive experiments on four representative cross-language clone detection datasets. Experimental results show that ZC3 outperforms the state-of-the-art baselines by 67.12%, 51.39%, 14.85%, and 53.01% on the MAP score, respectively. We further investigate the representational distribution of different languages and discuss the effectiveness of our method.

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

↑