一句话:提出 CDCS,用元学习将通用语言预训练模型迁移到数据稀缺的领域特定语言,实现高效跨领域代码搜索。
预训练编程语言模型如 Code-BERT 在代码搜索上表现优异,但其依赖大量查询-代码平行数据来微调语义映射,导致在 Solidity、SQL 等数据稀缺且昂贵的领域特定语言上实用性受限。本文提出 CDCS,一个面向领域特定语言的代码搜索迁移学习框架:先在大规模通用语言(如 Java、Python)语料上预训练程序表示模型,再通过少样本元学习算法 MAML 学习一组可被目标语言良好复用的模型参数初始化,从而适配到目标领域语言,而非像跨语言 CodeBERT 那样直接在目标语言上微调。作者在 Solidity 和 SQL 两种领域特定语言上、以 Python 和 Java 为源语言进行实验,结果表明 CDCS 显著优于直接在领域特定语言上微调的常规预训练代码模型,且在训练数据稀缺时尤为有效。
Recently, pre-trained programming language models such as Code-BERT have demonstrated substantial gains in code search. Despite their success, they rely on the availability of large amounts of parallel data to fine-tune the semantic mappings between queries and code. This restricts their practicality in domain-specific languages with relatively scarce and expensive data. In this paper, we propose CDCS, a novel approach for domain-specific code search. CDCS employs a transfer learning framework where an initial program representation model is pre-trained on a large corpus of common programming languages (such as Java and Python), and is further adapted to domain-specific languages such as Solidity and SQL. Un-like cross-language CodeBERT, which is directly fine-tuned in the target language, CDCS adapts a few-shot meta-learning algorithm called MAML to learn the good initialization of model parameters, which can be best reused in a domain-specific language. We evaluate the proposed approach on two domain-specific languages, namely Solidity and SQL, with model transferred from two widely used languages (Python and Java). Experimental results show that CDCS significantly outperforms conventional pre-trained code models that are directly fine-tuned in domain-specific languages, and it is particularly effective for scarce data.