You Augment Me: 探索基于ChatGPT的语义代码搜索数据增强方法
You Augment Me: Exploring ChatGPT-based Data Augmentation for Semantic Code Search
AI总结:
针对语义代码搜索高质量训练数据获取难的问题,提出基于ChatGPT的ChatDANCE数据增强方法,通过提示词生成、交叉编码器过滤和重训练实现模型自增长,性能显著优于现有基线。
摘要:
代码搜索在软件开发中至关重要,它使开发者能够通过自然语言查询检索并复用代码。尽管代码搜索模型的性能会随着高质量数据的增加而提升,但获取这类数据既困难又成本高昂。近年来,ChatGPT等大语言模型(LLM)在自然语言与编程语言的理解和生成方面取得了显著进展,可通过简单提示词提供用户友好的交互方式。受这些进展启发,我们提出了一种名为ChatDANCE的新方法,该方法利用大语言模型生成的高质量、多样化增强数据,并借助过滤机制剔除低质量增强样本。具体而言,我们首先提出了一套专门针对源代码和查询设计的ChatGPT提示词规则。随后,我们基于相应提示词利用ChatGPT重写代码和查询,接着提出一种过滤机制——从骨干模型UniXcoder训练出一个交叉编码器,以过滤掉匹配分数较低的代码-查询对。最后,我们使用获得的高质量增强数据重新训练骨干模型。实验结果表明,ChatDANCE取得了当前最优性能,相较最佳基线模型,R@1指标提升13.2%,MRR指标提升7%。令人意外的是,我们发现这种“增强-过滤-重训练”策略能够让骨干模型(UniXcoder)实现自我成长。此外,大量实验验证了各组件的有效性,且ChatDANCE在不同超参数设置下均能保持稳定性能。我们还通过定性与定量分析探究了ChatDANCE效果优异的原因,发现它能学习到更均匀的表征分布,并有效对齐代码空间与查询空间。
英文摘要:
Code search plays a crucial role in software development, enabling developers to retrieve and reuse code using natural language queries. While the performance of code search models improves with an increase in high-quality data, obtaining such data can be challenging and expensive. Recently, large language models (LLMs) such as ChatGPT have made remarkable progress in both natural and programming language understanding and generation, offering user-friendly interaction via simple prompts. Inspired by these advancements, we propose a novel approach ChatDANCE, which utilizes high-quality and diverse augmented data generated by a large language model and leverages a filtering mechanism to eliminate low-quality augmentations. Specifically, we first propose a set of ChatGPT prompting rules that are specifically designed for source code and queries. Then, we leverage ChatGPT to rewrite code and queries based on the according prompts and then propose a filtering mechanism which trains a cross-encoder from the backbone model UniXcoder to filter out code and query pairs with low matching scores. Finally, we re-train the backbone model using the obtained high-quality augmented data. Experimental results show that ChatDANCE achieves state-of-the-art performance, improving the best baseline by 13.2% (R@1) and 7% (MRR). Surprisingly, we find that this augment-filter-retrain strategy enables the backbone model (UniXcoder) to self-grow. Moreover, extensive experiments show the effectiveness of each component and ChatDANCE has stable performance under different hyperparameter settings. In addition, we conduct qualitative and quantitative analyses to investigate why ChatDANCE works well and find that it learns a more uniform distribution of representations and effectively aligns the code and query spaces.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。