arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.06690cs.SEcs.CLcs.LGcs.PL
收藏

用于源代码合成与补全的神经模型

Neural Models for Source Code Synthesis and Completion

Ruprecht-Karls-Universität Heidelberg(海德堡大学)

Mitodru Niyogi

AI总结:

本文提出序列到序列深度学习模型及训练范式,直接生成源代码词元,实现自然语言到代码的推荐与双向转换,并扩展代码补全功能,性能超越TranX 10.82%。

摘要:

自然语言(NL)到代码的推荐系统通过将自然语言表述翻译为可编译的代码片段,在集成开发环境(IDE)中为开发者提供辅助。当前的方法主要涉及基于语义解析的硬编码、基于规则的系统。这些系统大量使用手工制作的规则,将自然语言中的模式或其语法解析树中的元素映射到各种查询构造,并且只能在具有受限自然语言语法的有限自然语言子集上工作。这些系统无法从开发者的编码意图中提取语义信息,并且通常无法推断类型、名称和源代码的上下文以获得准确的系统级代码建议。在这篇硕士论文中,我们提出了序列到序列的深度学习模型和训练范式,将自然语言映射到通用编程语言,该模型可以在给定自然语言意图的情况下,通过推荐源代码片段来辅助用户,同时还在用户编写源代码时为其扩展源代码的自动补全功能。所开发的架构将上下文感知能力融入到神经模型中,该模型直接生成源代码词元,而不是从源代码生成解析树/抽象语义表示再将其转换回源代码。所提出的预训练策略和数据增强技术提升了该架构的性能。研究发现,基于BLEU-4指标,所提出的架构的性能超越了神经语义解析器TranX 10.82%。随后,引入了一种针对CoNaLA挑战中来自自然语言意图的可解析代码翻译的更精细分析。所提出的系统是双向的,因为它也可以在给定源代码的情况下用于生成自然语言代码文档。最后,提出了一个针对Python的RoBERTa掩码语言模型,以扩展所开发的系统用于代码补全。

英文摘要:

Natural language (NL) to code suggestion systems assist developers in Integrated Development Environments (IDEs) by translating NL utterances into compilable code snippet. The current approaches mainly involve hard-coded, rule-based systems based on semantic parsing. These systems make heavy use of hand-crafted rules that map patterns in NL or elements in its syntax parse tree to various query constructs and can only work on a limited subset of NL with a restricted NL syntax. These systems are unable to extract semantic information from the coding intents of the developer, and often fail to infer types, names, and the context of the source code to get accurate system-level code suggestions. In this master thesis, we present sequence-to-sequence deep learning models and training paradigms to map NL to general-purpose programming languages that can assist users with suggestions of source code snippets, given a NL intent, and also extend auto-completion functionality of the source code to users while they are writing source code. The developed architecture incorporates contextual awareness into neural models which generate source code tokens directly instead of generating parse trees/abstract meaning representations from the source code and converting them back to source code. The proposed pretraining strategy and the data augmentation techniques improve the performance of the proposed architecture. The proposed architecture has been found to exceed the performance of a neural semantic parser, TranX, based on the BLEU-4 metric by 10.82%. Thereafter, a finer analysis for the parsable code translations from the NL intent for CoNaLA challenge was introduced. The proposed system is bidirectional as it can be also used to generate NL code documentation given source code. Lastly, a RoBERTa masked language model for Python was proposed to extend the developed system for code completion.

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

↑