Skip to main content
QUICK REVIEW

[论文解读] A parallel corpus of Python functions and documentation strings for automated code documentation and code generation

Antonio Valerio Miceli Barone, Rico Sennrich|arXiv (Cornell University)|Jul 7, 2017
Natural Language Processing Techniques参考文献 14被引用 57
一句话总结

本文提出一个从 GitHub 抓取的包含 Python 函数及其文档字符串的大型并行语料库,以及用于代码文档化和代码生成的基线方法,采用神经机器翻译和数据增强,并公开这些资源以供研究使用。

ABSTRACT

Automated documentation of programming source code and automated code generation from natural language are challenging tasks of both practical and scientific interest. Progress in these areas has been limited by the low availability of parallel corpora of code and natural language descriptions, which tend to be small and constrained to specific domains. In this work we introduce a large and diverse parallel corpus of a hundred thousands Python functions with their documentation strings ("docstrings") generated by scraping open source repositories on GitHub. We describe baseline results for the code documentation and code generation tasks obtained by neural machine translation. We also experiment with data augmentation techniques to further increase the amount of training data. We release our datasets and processing scripts in order to stimulate research in these areas.

研究动机与目标

  • 动机:需要大规模、现实的代码-语言语料库,以推动自动化代码文档编制和代码生成的发展。
  • 从 GitHub 收集带有文档字符串的 Python 函数,创建多样化的并行语料库及其相关元数据。
  • 在该语料库上提供代码到文档字符串和文档字符串到代码任务的基线神经机器翻译结果。
  • 探索通过合成文档字符串进行数据增强,以提升训练数据。
  • 向研究社区发布数据集、预处理脚本和基线配置。

提出的方法

  • 从 GitHub 收集 Python 2.7 代码,拆分为函数声明、文档字符串和函数体。
  • 筛选并预处理,生成并行语料库,以及带有合成文档字符串的单独代码语料库。
  • 使用 Moses 进行分词,并应用字节对编码以降低稀疏性。
  • 使用 Nematus,在两个方向(代码→文档字符串和文档字符串→代码)训练神经机器翻译模型,采用特定的超参数。
  • 通过对仅代码数据生成合成文档字符串并重新训练来应用回译。

实验结果

研究问题

  • RQ1一个大型且多样化的 Python 函数-文档字符串语料库是否能够支持代码文档编制和代码生成任务的有效学习?
  • RQ2在这组数据上,代码到文档字符串和文档字符串到代码任务的神经 MT 基线表现如何?
  • RQ3回译与合成文档字符串的增广是否提升了性能?
  • RQ4基线 BLEU 分数对该语料库的任务难度有何指示?

主要发现

系统BLEU有效测试
代码到文档字符串14.0313.84
文档字符串到代码(基线)10.3210.24
文档字符串到代码(回译)10.8510.90
  • 主要并行语料包含 150,370 条函数声明、文档字符串和函数体,设有 109,108 条训练样本、2,000 条验证样本和 2,000 条测试样本。
  • 代码到文档字符串基线 BLEU:14.03(有效)和 13.84(测试)。
  • 文档字符串到代码基线 BLEU(基线):10.32(有效)和 10.24(测试)。
  • 带回译的文档字符串到代码 BLEU:10.85(有效)和 10.90(测试)。
  • 回译在基线文档字符串到代码模型的基础上提供约 0.5–0.6 BLEU 点的中等提升。
  • 该数据集比之前公布的 Python 语料库更具挑战性(如其他数据集的 BLEU 分数多在 60–85 区间),表明具有现实世界的复杂性。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

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