指导性代码检索器:从大型语言模型的反馈中学习以处理代码智能任务
Instructive Code Retriever: Learn from Large Language Model's Feedback for Code Intelligence Tasks
AI总结:
本文提出Instructive Code Retriever(ICR),通过基于树的损失函数和LLM反馈训练检索器,有效捕获查询的语义与结构信息,在代码摘要、程序合成和错误修复等任务上显著超越现有方法。
摘要:
近期的研究提出利用具有上下文学习(ICL)的大型语言模型(LLMs)来处理代码智能任务,而无需微调。ICL采用任务指令和一组示例作为演示,以引导模型生成准确答案,而无需更新其参数。尽管ICL已被证明对代码智能任务有效,但其性能严重依赖于所选的示例。先前的工作在使用BM25为代码智能任务检索示例方面取得了一些成功。然而,现有方法缺乏理解查询的语义和结构信息的能力,导致演示的帮助性较低。此外,它们不能很好地适应不同领域中用户查询的复杂和动态特性。在本文中,我们引入了一种名为Instructive Code Retriever(ICR)的新方法,该方法旨在检索示例以增强模型在各种代码智能任务和数据集上的推理能力。我们通过基于树的损失函数使ICR学习语料库的语义和结构信息。为了更好地理解查询与示例之间的相关性,我们结合了LLMs的反馈来指导检索器的训练。实验结果表明,我们的检索器显著优于最先进的方法。我们在各种任务上评估了模型的有效性,即代码摘要、程序合成和错误修复。与先前的最先进算法相比,我们的方法在两个代码摘要数据集的BLEU-4方面分别取得了50.0%和90.0%的提升,在程序合成数据集上取得了74.6%的CodeBLEU提升,并在两个错误修复数据集上分别增加了3.6和3.2的BLEU-4。
英文摘要:
Recent studies proposed to leverage large language models (LLMs) with In-Context Learning (ICL) to handle code intelligence tasks without fine-tuning. ICL employs task instructions and a set of examples as demonstrations to guide the model in generating accurate answers without updating its parameters. While ICL has proven effective for code intelligence tasks, its performance heavily relies on the selected examples. Previous work has achieved some success in using BM25 to retrieve examples for code intelligence tasks. However, existing approaches lack the ability to understand the semantic and structural information of queries, resulting in less helpful demonstrations. Moreover, they do not adapt well to the complex and dynamic nature of user queries in diverse domains. In this paper, we introduce a novel approach named Instructive Code Retriever (ICR), which is designed to retrieve examples that enhance model inference across various code intelligence tasks and datasets. We enable ICR to learn the semantic and structural information of the corpus by a tree-based loss function. To better understand the correlation between queries and examples, we incorporate the feedback from LLMs to guide the training of the retriever. Experimental results demonstrate that our retriever significantly outperforms state-of-the-art approaches. We evaluate our model's effectiveness on various tasks, i.e., code summarization, program synthesis, and bug fixing. Compared to previous state-of-the-art algorithms, our method achieved improvements of 50.0% and 90.0% in terms of BLEU-4 for two code summarization datasets, 74.6% CodeBLEU on program synthesis dataset, and increases of 3.6 and 3.2 BLEU-4 on two bug fixing datasets.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。