一句话:提出检索增强的代码建议框架,用代码搜索检索相似片段增强语言模型,显著提升代码补全与生成性能。
现代 IDE 提供代码补全与代码生成等自动代码建议技术,这些技术或从代码库检索相似片段,或利用深度学习模型生成建议,但如何系统性地用代码检索增强代码建议仍缺乏研究。本文提出一个检索增强的代码建议框架:该框架先使用不同的检索方法与搜索策略从代码库中搜索相似代码片段,再将检索结果用于增强语言模型在代码建议任务上的表现。作者将多种语言模型集成到框架中,并与原始模型进行对比实验。结果表明,该框架在 BLEU-4 指标上使代码补全性能最高提升 53.8%,代码生成性能最高提升 130.8%,说明将检索过程融入代码建议可以大幅提升效果。
Modern integrated development environments (IDEs) provide various automated code suggestion techniques (e.g., code completion and code generation) to help developers improve their efficiency. Such techniques may retrieve similar code snippets from the code base or leverage deep learning models to provide code suggestions. However, how to effectively enhance the code suggestions using code retrieval has not been systematically investigated. In this paper, we study and explore a retrieval-augmented framework for code suggestions. Specifically, our framework leverages different retrieval approaches and search strategies to search similar code snippets. Then the retrieved code is used to further enhance the performance of language models on code suggestions. We conduct experiments by integrating different language models into our framework and compare the results with their original models. We find that our framework noticeably improves the performance of both code completion and code generation by up to 53.8% and 130.8% in terms of BLEU-4, respectively. Our study highlights that integrating the retrieval process into code suggestions can improve the performance of code suggestions by a large margin.
@inproceedings{paperbot11383,
title = {Code Search is All You Need? Improving Code Suggestions with Code Search},
author = {Junkai Chen and Xing Hu and Zhenhao Li and Cuiyun Gao and Xin Xia and David Lo},
booktitle = {ICSE},
year = {2024},
doi = {10.1145/3597503.3639085}
}