arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2409.15895cs.SE
收藏

面向检索增强代码生成的偏好引导重构微调

Preference-Guided Refactored Tuning for Retrieval Augmented Code Generation

Xinyu Gao, Yun Xiong, Deze Wang, Zhenhan Guan, Zejian Shi, Haofen Wang, Shanshan Li

AI总结:

针对检索增强代码生成中的信息冗余和偏好差距问题,提出RRG框架,通过在检索器与生成器间引入代码重构器模块,有效提升代码生成质量并降低推理成本。

摘要:

检索增强代码生成利用大语言模型作为生成器,并通过检索器提供相关代码、文档等,显著扩展了其代码生成能力。当前方法存在两个主要局限:1)信息冗余。不加区分地包含冗余信息会导致资源浪费,并可能误导生成器,影响其有效性和效率。2)偏好差距。由于优化目标不同,检索器努力获取与真实值相似度更高的代码,但这并不能实质性地使生成器受益。检索器和生成器可能偏好不同的黄金代码,这种偏好差距导致了次优设计。此外,预训练期间获得的参数化知识差异导致不同生成器之间存在不同偏好。为了解决这些局限,本文提出了RRG(Retrieve, Refactor, Generate,检索、重构、生成),一个用于高效有效代码生成的新框架。该框架在检索器和生成器之间引入代码重构器模块以桥接二者。重构过程将原始检索代码转换为更简洁、高效且模型友好的版本。它消除冗余信息和噪声,减少输入长度。因此,生成器接收更高质量的上下文,使其能以更低推理成本产生更准确结果。我们在多个数据集上进行了全面实验。实验中,我们确认了检索器和生成器间存在偏好差距,且RRG有效桥接了该差距。具体而言,RRG实现了显著性能提升,EM提升达28%,BLEU提升13%,CodeBLEU提升6.8%。

英文摘要:

Retrieval-augmented code generation utilizes Large Language Models as the generator and significantly expands their code generation capabilities by providing relevant code, documentation, and more via the retriever. The current approach suffers from two primary limitations: 1) information redundancy. The indiscriminate inclusion of redundant information can result in resource wastage and may misguide generators, affecting their effectiveness and efficiency. 2) preference gap. Due to different optimization objectives, the retriever strives to procure code with higher ground truth similarity, yet this effort does not substantially benefit the generator. The retriever and the generator may prefer different golden code, and this gap in preference results in a suboptimal design. Additionally, differences in parameterization knowledge acquired during pre-training result in varying preferences among different generators. To address these limitations, in this paper, we propose RRG (Retrieve, Refactor, Generate), a novel framework for effective and efficient code generation. This framework introduces a code refactorer module between the retriever and the generator to bridge them. The refactoring process transforms the raw retrieved code into a more concise, efficient, and model-friendly version. It eliminates redundant information and noise, reducing the input length. Consequently, the generator receives higher-quality context, enabling it to produce more accurate results with lower inference costs. We conducted comprehensive experiments on multiple datasets. In the experiments, we confirmed the existence of a preference gap between the retriever and the generator, and RRG effectively bridges this gap. Specifically, RRG achieved significant performance improvements, with increases of up to 28% on EM, 13% on BLEU, and 6.8% on CodeBLEU.

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

↑