arXiv:2604.15385cs.SEcs.LG2026-04综述

用提示工程提升代码自动生成文档的效果,系统梳理了最佳实践。

Prompt-Driven Code Summarization: A Systematic Literature Review

论文配图:Prompt-Driven Code Summarization: A Systematic Literature Review
图 1 · 摘自论文原文
  • 系统分类了少样本、思维链等代码摘要提示策略
  • 发现提示设计显著影响LLM生成文档的质量与一致性
  • 适合关注AI辅助开发的工程师和研究者参考

软件文档对程序理解、开发者入职、代码审查和长期维护至关重要。但人工编写文档耗时且常不完整或不一致。大语言模型(LLMs)可通过自动从源码生成自然语言描述,提升开发效率,支持缺陷定位和提交信息生成等下游任务。然而LLM在文档生成中的效果高度依赖提示设计。合理的提示工程——即通过输入指令引导模型行为——是基于LLM的软件工程核心方法。少样本提示、思维链推理、检索增强生成和零样本学习等策略在代码摘要中展现出潜力,但现有研究分散,尚不清楚哪种策略在何种模型或条件下最有效。此外,评估方法差异大,多数研究依赖重叠率指标,可能无法反映语义质量。本系统文献综述整合现有证据,分类提示范式,评估其有效性,并识别研究空白,以指导未来研究与实际应用。

原文摘要 · Abstract (English)

Software documentation is essential for program comprehension, developer onboarding, code review, and long-term maintenance. Yet producing quality documentation manually is time-consuming and frequently yields incomplete or inconsistent results. Large language models (LLMs) offer a promising solution by automatically generating natural language descriptions from source code, helping developers understand code more efficiently, facilitating maintenance, and supporting downstream activities such as defect localization and commit message generation. However, the effectiveness of LLMs in documentation tasks critically depends on how they are prompted. Properly structured instructions can substantially improve model performance, making prompt engineering-the design of input prompts to guide model behavior-a foundational technique in LLM-based software engineering. Approaches such as few-shot prompting, chain-of-thought reasoning, retrieval-augmented generation, and zero-shot learning show promise for code summarization, yet current research remains fragmented. There is limited understanding of which prompting strategies work best, for which models, and under what conditions. Moreover, evaluation practices vary widely, with most studies relying on overlap-based metrics that may not capture semantic quality. This systematic literature review consolidates existing evidence, categorizes prompting paradigms, examines their effectiveness, and identifies gaps to guide future research and practical adoption.

代码生成提示工程LLM文献综述

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。