一句话:将设计文档作为上下文输入 LLM 生成代码注释,实验表明设计感知上下文可提升注释的有用性。
代码注释对开发与维护流程十分有用。随着工具可及性与能力的提升,新手程序员创建了大量代码库,但由于缺乏标准化,他们的注释往往效果不佳,反而延长了后续维护所需的时间。本文探讨利用大语言模型生成更有效注释的可行性,重点研究能否将设计文档作为上下文提供给 LLM,从而生成更有用的注释。作者通过实验比较在有/无此类上下文时生成注释的有用性,结果显示,采用设计感知的上下文信息后,注释的有用性有所提升。
Comments are very useful in the code development workflow. With increased access to and capability of tools, novice coders have been creating a significant amount of codebases. However, due to lack of standardization, their comments are often ineffective and can increase the time taken for subsequent maintenance. This study investigates the utility of using Large Language Models (LLMs) to generate more effective comments. The study focuses on the feasibility of utilizing design documents as a context for LLMs to generate more useful comments. Our results show that the usefulness of comments increases when using such contextual information.
@inproceedings{paperbot11990,
title = {Leveraging Design-Aware Context in Large Language Models for Code Comment Generation},
author = {Aritra Mitra and Srijoni Majumdar and Anamitra Mukhopadhyay and Partha Pratim Das and Paul D Clough and Partha Pratim Chakrabarti},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3786582.3786825}
}