arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2010.03150cs.LGcs.SE
收藏

PyMT5:使用Transformers对自然语言和Python代码进行多模式翻译

PyMT5: multi-mode translation of natural language and Python code with transformers

Microsoft Cloud and AI(微软云和人工智能部门);Stanford University(斯坦福大学)

Colin B. Clement, Dawn Drain, Jonathan Timcheck, Alexey Svyatkovskiy, Neel Sundaresan

摘要:

同时对源代码和自然语言建模在自动化软件开发和理解中有许多令人兴奋的应用。为了实现这种技术,我们引入了PyMT 5,Python方法文本到文本转换Transformer,它被训练为在所有Python方法特征组合之间进行转换:一个单一的模型,既可以从自然语言文档字符串(docstrings)预测整个方法,也可以将代码总结为任何常见风格的docstrings。我们对一个包含2600万个Python方法和770万个方法-文档字符串对的大规模并行语料库进行了分析和建模,结果表明,对于文档字符串和方法生成,PyMT 5的性能优于类似大小的自回归语言模型(GPT 2),后者是英语预训练或随机初始化的。在CodeSearchNet测试集上,我们的最佳模型预测了92.1%的语法正确的方法体,方法生成的BLEU得分为8.59,文档字符串生成(摘要)的BLEU得分为16.3,方法生成的ROUGE-LF得分为24.8,文档字符串生成的ROUGE-LF得分为36.7。

英文摘要:

Simultaneously modeling source code and natural language has many exciting applications in automated software development and understanding. Pursuant to achieving such technology, we introduce PyMT5, the Python method text-to-text transfer transformer, which is trained to translate between all pairs of Python method feature combinations: a single model that can both predict whole methods from natural language documentation strings (docstrings) and summarize code into docstrings of any common style. We present an analysis and modeling effort of a large-scale parallel corpus of 26 million Python methods and 7.7 million method-docstring pairs, demonstrating that for docstring and method generation, PyMT5 outperforms similarly-sized auto-regressive language models (GPT2) which were English pre-trained or randomly initialized. On the CodeSearchNet test set, our best model predicts 92.1% syntactically correct method bodies, achieved a BLEU score of 8.59 for method generation and 16.3 for docstring generation (summarization), and achieved a ROUGE-L F-score of 24.8 for method generation and 36.7 for docstring generation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑