paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Retrieve and refine

检索与精炼
ASE Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering2020匹配度 1/10 · 论文聚焦代码注释生成,使用IR检索相似代码注释作为范例来指导seq2seq模型,属于软件工程中的代码摘要任务;它与用户关注的静态分析、Agentic程序、浮点程序分析、贝叶斯程序分析以及LLM与程序分析的交叉均无直接关系,也未涉及LLM/Agent或强模型工具。引用 69 inbox
Bolin Wei, Yongmin Li, Ge Li, Xin Xia, Zhi Jin
crossref: 2026-09-12

AI 速览

一句话:提出用检索到的相似代码注释作范例,指导 seq2seq 神经网络生成代码注释,在 Java 语料上显著优于现有方法。

代码注释生成旨在自动为源代码生成自然语言描述。传统方法依赖人工模板或信息检索,近年神经网络方法虽效果显著,但仅以代码信息为输入,未利用软件复用中相似代码注释的参考价值。本文受 IR 与模板方法启发,提出神经注释生成方法:给定代码,先用 IR 检索相似代码片段,将其注释作为范例;再设计 seq2seq 神经网络,输入代码、AST、相似代码及范例注释,基于语义相似性利用范例信息辅助生成目标注释。在约 200 万样本的大规模 Java 语料上评估,结果显著超越当前最优方法。

问题
如何利用软件复用中相似代码片段的注释信息,提升代码注释自动生成的效果。
方法
先用信息检索获取相似代码片段并将其注释作为范例,再设计 seq2seq 神经网络,输入代码、AST、相似代码及范例注释,基于语义相似性引导注释生成。
评估
在约 200 万样本的大规模 Java 语料上开展实验,结果表明该模型显著优于现有最优方法。
原文摘要(Abstract)

Code comment generation which aims to automatically generate natural language descriptions for source code, is a crucial task in the field of automatic software development. Traditional comment generation methods use manually-crafted templates or information retrieval (IR) techniques to generate summaries for source code. In recent years, neural network-based methods which leveraged acclaimed encoder-decoder deep learning framework to learn comment generation patterns from a large-scale parallel code corpus, have achieved impressive results. However, these emerging methods only take code-related information as input. Software reuse is common in the process of software development, meaning that comments of similar code snippets are helpful for comment generation. Inspired by the IR-based and template-based approaches, in this paper, we propose a neural comment generation approach where we use the existing comments of similar code snippets as exemplars to guide comment generation. Specifically, given a piece of code, we first use an IR technique to retrieve a similar code snippet and treat its comment as an exemplar. Then we design a novel seq2seq neural network that takes the given code, its AST, its similar code, and its exemplar as input, and leverages the information from the exemplar to assist in the target comment generation based on the semantic similarity between the source code and the similar code. We evaluate our approach on a large-scale Java corpus, which contains about 2M samples, and experimental results demonstrate that our model outperforms the state-of-the-art methods by a substantial margin.

链接与引用

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

BibTeX
@inproceedings{paperbot6015,
  title = {Retrieve and refine},
  author = {Bolin Wei and Yongmin Li and Ge Li and Xin Xia and Zhi Jin},
  booktitle = {ASE},
  year = {2020},
  doi = {10.1145/3324884.3416578}
}