arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2407.13648cs.SE
收藏

COMCAT:利用人类判断改进自动文档生成与摘要

COMCAT: Leveraging Human Judgment to Improve Automatic Documentation and Summarization

Skyler Grandel, Scott Thomas Andersen, Yu Huang, Kevin Leach

AI总结:

COMCAT利用专家引导上下文增强大语言模型,自动生成代码注释,显著提升开发者代码理解能力,优于ChatGPT生成注释,并发布相关数据集。

摘要:

软件维护占软件总生命周期成本的相当大一部分,其中很大一部分归因于代码理解。通过诸如注释之类的文档(这些注释总结并解释代码)可以减轻软件理解的难度。我们提出了COMCAT,一种通过用专家引导的上下文增强大型语言模型(LLMs)来自动生成注释的方法,旨在对源代码进行注释以提高理解性。我们的方法能够为给定的代码片段或包含源代码的文件选择最相关且信息量最大的注释。我们开发了COMCAT流水线来注释C/C++文件,通过(1)自动识别放置注释的合适位置,(2)预测每个位置最有帮助的注释类型,以及(3)基于所选位置和注释类型生成注释。在人类受试者评估中,我们证明COMCAT生成的注释显著提高了开发者在三个代表性软件工程任务中的代码理解能力,对87%的参与者提升高达12%。此外,我们证明COMCAT生成的注释至少与人类生成的注释一样准确和可读,并且在高达92%的代码片段中优于标准ChatGPT生成的注释。此外,我们开发并发布了一个包含源代码片段、人类编写的注释和人类标注的注释类别的数据集。COMCAT利用LLMs在多种人类软件工程任务中显著提高了代码理解能力。

英文摘要:

Software maintenance constitutes a substantial portion of the total lifetime costs of software, with a significant portion attributed to code comprehension. Software comprehension is eased by documentation such as comments that summarize and explain code. We present COMCAT, an approach to automate comment generation by augmenting Large Language Models (LLMs) with expertise-guided context to target the annotation of source code with comments that improve comprehension. Our approach enables the selection of the most relevant and informative comments for a given snippet or file containing source code. We develop the COMCAT pipeline to comment C/C++ files by (1) automatically identifying suitable locations in which to place comments, (2) predicting the most helpful type of comment for each location, and (3) generating a comment based on the selected location and comment type. In a human subject evaluation, we demonstrate that COMCAT-generated comments significantly improve developer code comprehension across three indicative software engineering tasks by up to 12% for 87% of participants. In addition, we demonstrate that COMCAT-generated comments are at least as accurate and readable as human-generated comments and are preferred over standard ChatGPT-generated comments for up to 92% of snippets of code. Furthermore, we develop and release a dataset containing source code snippets, human-written comments, and human-annotated comment categories. COMCAT leverages LLMs to offer a significant improvement in code comprehension across a variety of human software engineering tasks.

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

↑