arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2210.12285cs.SEcs.IRcs.LG
收藏

探索代码搜索的表示级增强

Exploring Representation-Level Augmentation for Code Search

Nanyang Technological University(南洋理工大学);China-Singapore International Joint Research Institute(中新国际联合研究院);Sun Yat-sen University(中山大学);The University of Newcastle(纽卡斯尔大学)

Haochen Li, Chunyan Miao, Cyril Leung, Yanxian Huang, Yuan Huang, Hongyu Zhang, Yanlin Wang

摘要:

代码搜索是软件开发实践中的一种常见活动,其目的是为给定的自然语言查询检索最相关的代码片段。最近,对比学习被广泛用于代码搜索研究,其中许多用于源代码的数据增强方法(例如,语义保持程序变换)来学习更好的表示。然而,这些增强是在原始数据级别,这需要在预处理阶段进行额外的代码分析,并在训练阶段增加额外的训练成本。在本文中,我们探讨了增强数据(包括代码和查询)在表示级别,不需要额外的数据处理和训练的方法,并在此基础上,我们提出了一个通用的格式表示级增强,统一现有的方法。然后,我们提出了三个新的增强方法(线性外推,二进制插值,高斯缩放)的基础上的一般格式。此外,我们从理论上分析了所提出的增强方法的优势,传统的对比学习方法的代码搜索。我们的实验评估所提出的代表级增强方法与国家的最先进的代码搜索模型的大规模的公共数据集,包括六个程序设计语言。实验结果表明,我们的方法可以持续提高所研究的代码搜索模型的性能。我们的源代码可在https://github.com/Alex-HaochenLi/RACS上获得。

英文摘要:

Code search, which aims at retrieving the most relevant code fragment for a given natural language query, is a common activity in software development practice. Recently, contrastive learning is widely used in code search research, where many data augmentation approaches for source code (e.g., semantic-preserving program transformation) are proposed to learn better representations. However, these augmentations are at the raw-data level, which requires additional code analysis in the preprocessing stage and additional training costs in the training stage. In this paper, we explore augmentation methods that augment data (both code and query) at representation level which does not require additional data processing and training, and based on this we propose a general format of representation-level augmentation that unifies existing methods. Then, we propose three new augmentation methods (linear extrapolation, binary interpolation, and Gaussian scaling) based on the general format. Furthermore, we theoretically analyze the advantages of the proposed augmentation methods over traditional contrastive learning methods on code search. We experimentally evaluate the proposed representation-level augmentation methods with state-of-the-art code search models on a large-scale public dataset consisting of six programming languages. The experimental results show that our approach can consistently boost the performance of the studied code search models. Our source code is available at https://github.com/Alex-HaochenLi/RACS.

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

↑