基于提示的代码摘要:系统文献综述
Prompt-Driven Code Summarization: A Systematic Literature Review
AI总结:
本文综述了基于提示的代码摘要方法,分析了不同提示策略的有效性及评估挑战,旨在为未来研究和实际应用提供指导。
摘要:
软件文档对于程序理解、开发者入职、代码审查和长期维护至关重要。然而,手动生成高质量文档耗时且常导致不完整或不一致的结果。大型语言模型(LLMs)通过自动从源代码生成自然语言描述,提供了一种有前景的解决方案,帮助开发者更高效地理解代码,促进维护,并支持缺陷定位和提交信息生成。然而,LLMs在文档任务中的有效性严重依赖于如何提示。适当结构化的指令可以显著提高模型性能,使提示工程——设计输入提示以指导模型行为——成为基于LLM的软件工程中的基础技术。诸如少量样本提示、思维链推理、检索增强生成和零样本学习等方法在代码摘要中显示出潜力,但当前研究仍较为分散。对哪种提示策略最适合、哪种模型以及在何种条件下最有效尚缺乏深入理解。此外,评估实践差异较大,大多数研究依赖于重叠度度量,这可能无法捕捉语义质量。本系统文献综述整合现有证据,分类提示范式,检验其有效性,并识别差距,以指导未来研究和实际应用。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。