Code Clone Detection, which aims to retrieve functionally similar programs from large code bases, has been attracting increasing attention. Modern software often involves a diverse range of programming languages. However, current code clone detection methods are generally limited to only a few popular programming languages due to insufficient annotated data as well as their own model design constraints. To address these issues, we present AdaCCD, a novel cross-lingual adaptation method that can detect cloned codes in a new language without any annotations in that language. AdaCCD leverages language-agnostic code representations from pre-trained programming language models and propose an Adaptively Refined Contrastive Learning framework to transfer knowledge from resource-rich languages to resource-poor languages. We evaluate the cross-lingual adaptation results of AdaCCD by constructing a multilingual code clone detection benchmark consisting of 5 programming languages. AdaCCD achieves significant improvements over other baselines, and it is even comparable to supervised fine-tuning.
翻译:代码克隆检测旨在从大型代码库中检索功能相似的程序,近年来受到越来越多的关注。现代软件通常涉及多种编程语言。然而,由于标注数据不足以及模型设计本身的约束,当前的代码克隆检测方法通常仅局限于少数流行编程语言。为解决这些问题,我们提出了AdaCCD——一种新颖的跨语言适配方法,能够在无需目标语言任何标注数据的情况下检测其中的克隆代码。AdaCCD利用预训练编程语言模型中的语言无关代码表示,并设计了一个自适应精炼对比学习框架,将知识从资源丰富语言迁移至资源匮乏语言。通过构建包含5种编程语言的多语言代码克隆检测基准,我们评估了AdaCCD的跨语言适配效果。实验结果表明,AdaCCD相较于其他基线方法取得了显著提升,甚至可与有监督微调方法相媲美。