基于IR和基于神经元的评论生成的又一组合
Yet Another Combination of IR- and Neural-based Comment Generation
摘要:
代码注释生成技术旨在为源代码生成自然语言描述。有两种正交的方法来完成这项任务,即,基于信息检索(IR)和基于神经的方法。最近的研究集中在结合他们的优势,通过喂养输入代码和类似的代码片段检索的IR为基础的方法,基于神经的方法,这可以增强基于神经的方法的输出低频词的能力,并进一步提高性能。然而,尽管取得了巨大的进步,我们的试点研究表明,目前的组合是不可推广的,并可能导致性能下降。在本文中,我们提出了一个简单但有效的方法来解决这两个评论生成方法的现有组合的问题。我们不是静态地绑定IR和基于神经的方法,而是以动态的方式将它们结合起来。具体来说,给定一个输入代码片段,我们首先使用基于IR的技术从语料库中检索类似的代码片段。然后,我们使用基于交叉编码器的分类器来决定要动态使用的评论生成方法,即,如果检索到的相似代码片段是真肯定的(即,在语义上类似于输入),我们直接使用基于IR的技术。否则,我们将输入传递给基于神经的模型以生成评论。我们评估我们的方法上的大规模数据集的Java项目。实验结果表明,我们的方法可以达到25.45 BLEU分数,提高了最先进的IR为基础的方法,基于神经网络的方法,以及他们的组合,分别为41%,26%和7%,。我们提出了一个简单但有效的动态组合的IR为基础的和基于神经的评论生成,它优于国家的最先进的方法大幅利润。
英文摘要:
Code comment generation techniques aim to generate natural language descriptions for source code. There are two orthogonal approaches for this task, i.e., information retrieval (IR) based and neural-based methods. Recent studies have focused on combining their strengths by feeding the input code and its similar code snippets retrieved by the IR-based approach to the neural-based approach, which can enhance the neural-based approach's ability to output low-frequency words and further improve the performance. However, despite the tremendous progress, our pilot study reveals that the current combination is not generalizable and can lead to performance degradation. In this paper, we propose a straightforward but effective approach to tackle the issue of existing combinations of these two comment generation approaches. Instead of binding IR- and neural-based approaches statically, we combine them in a dynamic manner. Specifically, given an input code snippet, we first use an IR-based technique to retrieve a similar code snippet from the corpus. Then we use a Cross-Encoder based classifier to decide the comment generation method to be used dynamically, i.e., if the retrieved similar code snippet is a true positive (i.e., is semantically similar to the input), we directly use the IR-based technique. Otherwise, we pass the input to the neural-based model to generate the comment. We evaluate our approach on a large-scale dataset of Java projects. Experiment results show that our approach can achieve 25.45 BLEU score, which improves the state-of-the-art IR-based approach, neural-based approach, and their combination by 41%, 26%, and 7%, respectively. We propose a straightforward but effective dynamic combination of IR-based and neural-based comment generation, which outperforms state-of-the-art approaches by a substantial margin.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。