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

什么构成了基于LLM的代码智能任务的良好上下文示例?

What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?

Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang, Hongyu Zhang, Michael R. Lyu

AI总结:

本文实证研究了上下文示例的选择、顺序和数量对代码智能任务中大型语言模型ICL性能的影响,发现这三个因素均显著影响效果,并基于实验发现提出了构建有效示范的建议,在代码摘要、错误修复和程序合成任务上取得显著提升。

摘要:

源代码预训练模型在许多代码智能任务中获得了广泛应用。最近,随着模型和语料库规模的扩大,大型语言模型展现出了上下文学习(ICL)的能力。ICL使用任务指令和少量示例作为示范,然后将示范输入语言模型以进行预测。这种新的学习范式无需训练,并在各种自然语言处理和代码智能任务中表现出色。然而,ICL的性能严重依赖于示范的质量,例如所选的示例。系统地研究如何为代码相关任务构建良好的示范非常重要。在本文中,我们实证探讨了三个关键因素对代码智能任务中ICL性能的影响:示范示例的选择、顺序和数量。我们在三个代码智能任务上进行了大量实验,包括代码摘要、错误修复和程序合成。我们的实验结果表明,上述三个因素都极大地影响了代码智能任务中ICL的性能。此外,我们总结了我们的发现,并从这三个角度提供了如何构建有效示范的实用建议。我们还表明,基于我们的发现精心设计的示范可以带来比广泛使用的示范构建方法显著的改进,例如,在代码摘要、错误修复和程序合成上,BLEU-4、EM和EM分别至少提高了9.90%、175.96%和50.81%。

英文摘要:

Pre-trained models of source code have gained widespread popularity in many code intelligence tasks. Recently, with the scaling of the model and corpus size, large language models have shown the ability of in-context learning (ICL). ICL employs task instructions and a few examples as demonstrations, and then inputs the demonstrations to the language models for making predictions. This new learning paradigm is training-free and has shown impressive performance in various natural language processing and code intelligence tasks. However, the performance of ICL heavily relies on the quality of demonstrations, e.g., the selected examples. It is important to systematically investigate how to construct a good demonstration for code-related tasks. In this paper, we empirically explore the impact of three key factors on the performance of ICL in code intelligence tasks: the selection, order, and number of demonstration examples. We conduct extensive experiments on three code intelligence tasks including code summarization, bug fixing, and program synthesis. Our experimental results demonstrate that all the above three factors dramatically impact the performance of ICL in code intelligence tasks. Additionally, we summarize our findings and provide takeaway suggestions on how to construct effective demonstrations, taking into account these three perspectives. We also show that a carefully-designed demonstration based on our findings can lead to substantial improvements over widely-used demonstration construction methods, e.g., improving BLEU-4, EM, and EM by at least 9.90%, 175.96%, and 50.81% on code summarization, bug fixing, and program synthesis, respectively

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

↑