基于提示调优的零样本代码表示学习
Zero-Shot Code Representation Learning via Prompt Tuning
AI总结:
针对下游任务标注成本高、预训练与下游任务异构的问题,提出基于提示调优的零样本代码表示方法Zecoler,通过可训练提示对齐任务形式,在五项代码智能任务零样本设置下性能显著优于基线。
摘要:
代码表示学习是代码克隆检测、代码生成等众多软件工程任务的核心前提。当前最先进的程序表示技术主要利用CodeBERT等预训练语言模型(PLMs):首先在大规模代码语料库上预训练Transformer编码器,以获取源代码的通用知识,随后使用大量标注数据在特定任务上微调预训练模型。但为下游任务收集训练样本成本极高,对于领域特定语言或项目特定任务而言并不现实。此外,预训练任务与下游任务通常存在异构性,导致难以充分挖掘预训练阶段习得的知识。本文提出Zecoler——一种用于代码表示学习的零样本方法。Zecoler基于预训练编程语言模型构建,为高效提取PLMs中的知识,它通过在原始输入中插入可训练提示,将下游任务转换为与预训练目标相同的形式,这些提示可引导PLMs生成更优结果。随后,我们采用提示调优技术自动为PLMs搜索最优提示,使表示模型能通过在源语言领域数据集上微调高效适配下游任务,再以零样本方式将预训练知识复用于目标领域。我们在代码克隆检测、代码搜索、方法名预测、代码摘要、代码生成五项代码智能任务上评估Zecoler,结果表明在零样本设置下,该方法性能显著优于基线模型。
英文摘要:
Learning code representations has been the core prerequisite of many software engineering tasks such as code clone detection and code generation. State-of-the-art program representation techniques mainly utilize pre-trained language models (PLMs) such as CodeBERT. A Transformer encoder is firstly pre-trained on a large-scale code corpus to acquire general knowledge about source code. The pre-trained model is then fine-tuned on specific tasks using an amount of labeled data. However, gathering training samples for the downstream tasks can be prohibitively expensive and impractical for domain-specific languages or project-specific tasks. Besides, pre-training and downstream tasks are usually heterogeneous, which makes it difficult to fully explore the knowledge learned during pre-training. In this paper, we propose Zecoler, a zero-shot approach for learning code representations. Zecoler is built upon a pre-trained programming language model. In order to elicit knowledge from the PLMs efficiently, Zecoler casts the downstream tasks to the same form of pre-training objectives by inserting train-able prompts into the original input. These prompts can guide PLMs on how to generate better results. Subsequently, we employ the prompt tuning technique to search for the optimal prompts for PLMs automatically. This enables the representation model to efficiently fit the downstream tasks through fine-tuning on the dataset in source language domain and then reuse the pre-trained knowledge for the target domain in a zero-shot style. We evaluate Zecoler in five code intelligence tasks including code clone detection, code search, method name prediction, code summarization, and code generation. The results show that our approach significantly outperforms baseline models under the zero-shot setting.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。