paperbot · PL 论文追踪

全部论文 待读 收藏

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

什么构成了面向代码智能任务的优秀上下文示例?——基于大语言模型的实证研究
ASE 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)2023匹配度 2/10 · 该文研究 LLM 上下文示例的选择、顺序与数量对代码智能任务的影响,属于提示词层面提升 LLM 性能,不涉及静态分析、形式化验证、浮点程序分析、贝叶斯程序分析或 Agentic 程序分析。它与用户核心方向“PL 与 AI 交叉中的分析/验证”匹配度很低。引用 154 inbox
Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang, Hongyu Zhang, Michael R. Lyu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:系统实证示例的选择、顺序与数量三因素对代码智能任务中上下文学习的影响,并给出示例构造建议。

大语言模型的上下文学习(ICL)无需训练即可用于代码智能任务,但其效果高度依赖示例(demonstration)的质量,而如何为代码相关任务构造好示例尚缺乏系统研究。本文针对代码摘要、缺陷修复与程序合成三项任务,通过大量实验系统考察示例的选择、排序与数量这三个关键因素对ICL性能的影响。结果表明三者均显著影响效果;作者据此归纳出构造有效示例的发现与建议。采用该建议构造的示例相较广泛使用的示例构造方法取得显著提升:代码摘要的BLEU-4、缺陷修复与程序合成的EM分别至少提升9.90%、175.96%与50.81%。

问题
上下文学习(ICL)在代码智能任务上的性能高度依赖示例(demonstration)的质量,但如何为代码相关任务选择与组织示例缺乏系统研究。
方法
在代码摘要、缺陷修复、程序合成三个任务上开展大量实验,考察示例的选择、顺序与数量三个因素对ICL性能的影响,并总结构造有效示例的建议。
评估
以BLEU-4、EM等指标比较不同示例构造策略;基于本文发现构造的示例在代码摘要、缺陷修复、程序合成上分别较常用方法至少提升9.90%、175.96%和50.81%。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{GaoWGWZL23,
  title = {What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?},
  author = {Shuzheng Gao and Xin-Cheng Wen and Cuiyun Gao and Wenxuan Wang and Hongyu Zhang and Michael R. Lyu},
  booktitle = {ASE},
  year = {2023},
  doi = {10.1109/ase56229.2023.00109}
}