MESIA:理解并利用方法级注释的补充性质以实现自动注释生成
MESIA: Understanding and Leveraging Supplementary Nature of Method-level Comments for Automatic Comment Generation
AI总结:
本文提出名为MESIA的新指标评估方法级注释的补充信息量,发现减少训练集中低补充信息注释可提升模型生成高补充信息注释的能力,并指出当前评估缺乏合适真实基准的问题。
摘要:
代码注释对于开发者的程序理解非常重要。在理解和重用方法的场景中,开发者期望代码注释能够提供方法签名之外的补充信息。然而,不同代码注释中此类补充信息的程度差异很大。在本文中,我们唤起对方法级注释补充性质的关注,并提出一个名为 MESIA(Mean Supplementary Information Amount,平均补充信息量)的新指标,用于评估代码注释所能提供的补充信息程度。借助 MESIA 指标,我们在一个流行的代码-注释数据集和三种常见类型的神经方法上进行了实验,以生成方法级注释。我们的实验结果通过多项发现证明了所提工作的价值。(1) Small-MESIA 注释约占数据集的 20%,且大多仅属于 WHAT 注释类别。(2) 能够提供各类重要信息的大-MESIA 注释,现有的神经方法很难生成。(3) 我们可以通过减少训练集中 Small-MESIA 注释的比例,来提升现有神经方法生成大-MESIA 注释的能力。(4) 重新训练的模型能够为大-MESIA 测试集中的方法生成传达重要且有意义的补充信息的大-MESIA 注释,但在评估中会获得较低的 BLEU 分数。这些发现表明,拥有良好的训练数据时,自动生成的注释有时甚至能超越人工编写的参考注释,而评估中缺乏合适的真实基准是未来自动注释生成工作需要解决的问题。
英文摘要:
Code comments are important for developers in program comprehension. In scenarios of comprehending and reusing a method, developers expect code comments to provide supplementary information beyond the method signature. However, the extent of such supplementary information varies a lot in different code comments. In this paper, we raise the awareness of the supplementary nature of method-level comments and propose a new metric named MESIA (Mean Supplementary Information Amount) to assess the extent of supplementary information that a code comment can provide. With the MESIA metric, we conduct experiments on a popular code-comment dataset and three common types of neural approaches to generate method-level comments. Our experimental results demonstrate the value of our proposed work with a number of findings. (1) Small-MESIA comments occupy around 20% of the dataset and mostly fall into only the WHAT comment category. (2) Being able to provide various kinds of essential information, large-MESIA comments in the dataset are difficult for existing neural approaches to generate. (3) We can improve the capability of existing neural approaches to generate large-MESIA comments by reducing the proportion of small-MESIA comments in the training set. (4) The retrained model can generate large-MESIA comments that convey essential meaningful supplementary information for methods in the small-MESIA test set, but will get a lower BLEU score in evaluation. These findings indicate that with good training data, auto-generated comments can sometimes even surpass human-written reference comments, and having no appropriate ground truth for evaluation is an issue that needs to be addressed by future work on automatic comment generation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。