arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.10263cs.SE
收藏

基于批判模型的代码补全自适应检索轻量级框架

A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model

Wenrui Zhang, Tiehang Fu, Ting Yuan, Ge Zhang, Dong Chen, Jie Wang

AI总结:

本文提出轻量级批判方法CARD,通过判断检索必要性并从多预测中选优,自适应地增强RAG代码补全,在减少检索与延迟的同时提升准确率。

摘要:

检索增强生成(Retrieval-Augmented Generation,RAG)的最新进展显著提升了仓库级代码补全效果。已有多种基于RAG的代码补全系统依据不同设计选择被提出,例如以多次重复检索—生成过程为代价来获得更高的有效性。然而,当前方法不加区分地使用检索,在效率和有效性两方面都暴露出问题:相当一部分检索是不必要的,并且可能向代码语言模型引入无益甚至有害的建议。为应对这些挑战,我们提出CARD,这是一种轻量级批判方法,旨在洞察检索的必要性,并从多个预测中选择最优答案。CARD可无缝集成到任何基于RAG的代码补全系统中。评估表明,CARD在行补全、API补全和函数补全上分别节省21%至46%、14%至40%以及6%至46.5%的检索次数,同时提高准确率。CARD将延迟降低16%至83%。它可泛化到不同的语言模型、检索器和编程语言,并且十分轻量:训练仅需数秒,推理仅需数毫秒。

英文摘要:

Recent advancements in Retrieval-Augmented Generation have significantly enhanced code completion at the repository level. Various RAG-based code completion systems are proposed based on different design choices. For instance, gaining more effectiveness at the cost of repeating the retrieval-generation process multiple times. However, the indiscriminate use of retrieval in current methods reveals issues in both efficiency and effectiveness, as a considerable portion of retrievals are unnecessary and may introduce unhelpful or even harmful suggestions to code language models. To address these challenges, we introduce CARD, a lightweight critique method designed to provide insights into the necessity of retrievals and select the optimal answer from multiple predictions. CARD can seamlessly integrate into any RAG-based code completion system. Our evaluation shows that CARD saves 21% to 46% times of retrieval for Line completion, 14% to 40% times of retrieval for API completion, and 6% to 46.5% times of retrieval for function completion respectively, while improving the accuracy. CARD reduces latency ranging from 16% to 83%. CARD is generalizable to different LMs, retrievers, and programming languages. It is lightweight with training in few seconds and inference in few milliseconds.

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

↑