Skip to main content
QUICK REVIEW

[论文解读] Code to Comment "Translation": Data, Metrics, Baselining & Evaluation

David Gros, Hariharan Sezhiyan|arXiv (Cornell University)|Oct 3, 2020
Natural Language Processing Techniques参考文献 61被引用 7
一句话总结

本文批判性地评估了神经机器翻译模型在代码到注释生成中的应用,揭示出代码注释远比自然语言文本更具重复性,导致BLEU分数被高估。研究显示,简单的信息检索基线模型通常优于当前最先进的深度学习模型,挑战了该领域当前评估实践的有效性。

ABSTRACT

The relationship of comments to code, and in particular, the task of generating useful comments given the code, has long been of interest. The earliest approaches have been based on strong syntactic theories of comment-structures, and relied on textual templates. More recently, researchers have applied deep learning methods to this task, and specifically, trainable generative translation models which are known to work very well for Natural Language translation (e.g., from German to English). We carefully examine the underlying assumption here: that the task of generating comments sufficiently resembles the task of translating between natural languages, and so similar models and evaluation metrics could be used. We analyze several recent code-comment datasets for this task: CodeNN, DeepCom, FunCom, and DocString. We compare them with WMT19, a standard dataset frequently used to train state of the art natural language translators. We found some interesting differences between the code-comment data and the WMT19 natural language data. Next, we describe and conduct some studies to calibrate BLEU (which is commonly used as a measure of comment quality). using "affinity pairs" of methods, from different projects, in the same project, in the same class, etc; Our study suggests that the current performance on some datasets might need to be improved substantially. We also argue that fairly naive information retrieval (IR) methods do well enough at this task to be considered a reasonable baseline. Finally, we make some suggestions on how our findings might be used in future research in this area.

研究动机与目标

  • 评估在使用相似深度学习模型的前提下,代码注释生成是否真正类似于自然语言翻译。
  • 探究代码注释中高度重复的特性对BLEU等评估指标可靠性的影响。
  • 通过基于亲和力的模型组对BLEU分数进行校准,建立更现实的性能预期。
  • 评估简单信息检索方法是否可作为代码注释生成的强基线。
  • 倡导未来在代码注释生成研究中采用标准化的评估与基线实践。

提出的方法

  • 通过Zipf图比较代码注释数据集(CodeNN、DeepCom、FunCom、DocString)与WMT19自然语言翻译数据集之间的三元语法频率分布。
  • 定义了‘亲和对’方法(相同项目、相同类、相同方法名),以校准BLEU分数并评估基于相似性的性能。
  • 在不同数据划分和预处理方法下测量BLEU分数,以评估其方差与可靠性。
  • 使用TF-IDF向量化与余弦相似度实现一个简单的信息检索基线,从相似方法中检索注释。
  • 将基于检索的基线性能与标准数据集上报告的SOTA结果进行评估。
  • 建议未来研究应采用类似于GLUE和SQuAD等NLP基准中使用的标准化评估协议。

实验结果

研究问题

  • RQ1代码注释的语言特征与WMT19等标准翻译数据集中的自然语言相比如何?
  • RQ2代码注释中高度重复的特性在多大程度上扭曲了BLEU分数作为注释质量度量的可靠性?
  • RQ3简单信息检索方法是否能在代码注释生成任务中实现与或优于当前最先进深度学习模型的性能?
  • RQ4不同层次的方法亲和度(如相同类、相同项目)如何影响预期的BLEU分数?它们揭示了基线性能的哪些信息?
  • RQ5为确保代码注释生成研究中公平且可复现的比较,评估实践需要在哪些方面进行改进?

主要发现

  • 代码注释的三元语法重复性显著高于WMT19中的自然语言,Zipf图斜率更陡峭,表明其语言更具饱和性与模板化特征。
  • WMT19数据集表现出更强的输入-输出依赖性,即相似的德语输入会产生相似的英语输出,但这种模式在代码注释数据集中微弱或完全缺失。
  • BLEU分数对数据划分和预处理方法高度敏感,某些情况下其波动幅度甚至超过声称的模型改进量。
  • 使用TF-IDF与余弦相似度的简单信息检索基线在多个数据集上实现了与报告的SOTA神经网络模型相当或更优的性能。
  • 从同一类中的方法检索注释,平均BLEU分数与当前SOTA模型相当,表明这是强有力的基线。
  • 本研究揭示了现有代码注释数据集在预处理、划分和评估函数方面存在显著不一致,严重削弱了可比性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。