arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2201.08810cs.PLcs.CLcs.LGcs.SE

GAP-Gen:引导式自动Python代码生成

GAP-Gen: Guided Automatic Python Code Generation

University of California, Irvine(加州大学欧文分校)

Junchen Zhao, Yurun Song, Junlin Wang, Ian G. Harris

AI总结:

提出GAP-Gen方法,通过Syntax-Flow和Variable-Flow引入Python语法与语义约束,改进微调过程,在多个数据集上微调T5和CodeT5,显著提升自动Python代码生成性能。

摘要:

从自然语言描述中自动生成代码在软件开发过程中可以带来极大的益处。在这项工作中,我们提出了GAP-Gen,一种基于Python语法约束和语义约束的引导式自动Python代码生成方法。我们首先以Syntax-Flow的形式引入Python语法约束,Syntax-Flow是抽象语法树(AST)的简化版本,在降低抽象语法树的规模和复杂性的同时保留了Python代码的关键语法信息。除了Syntax-Flow之外,我们还引入了Variable-Flow,它一致地抽象了代码中的变量和函数名称。在我们的工作中,我们不是关注预训练,而是专注于修改微调过程,这降低了计算需求,同时在自动Python代码生成任务上保持了较高的生成性能。GAP-Gen使用Code-to-Docstring数据集CodeSearchNet、CodeSearchNet AdvTest和来自EdinburghNLP的Code-Docstring Corpus对基于Transformer的语言模型T5和CodeT5进行微调。我们的实验表明,GAP-Gen在自动Python代码生成任务上取得了比以往工作更好的结果。

英文摘要:

Automatic code generation from natural language descriptions can be highly beneficial during the process of software development. In this work, we propose GAP-Gen, a Guided Automatic Python Code Generation method based on Python syntactic constraints and semantic constraints. We first introduce Python syntactic constraints in the form of Syntax-Flow, which is a simplified version of Abstract Syntax Tree (AST) reducing the size and high complexity of Abstract Syntax Tree but maintaining crucial syntactic information of Python code. In addition to Syntax-Flow, we introduce Variable-Flow which abstracts variable and function names consistently through out the code. In our work, rather than pretraining, we focus on modifying the finetuning process which reduces computational requirements but retains high generation performance on automatic Python code generation task. GAP-Gen fine-tunes the transformer based language models T5 and CodeT5 using the Code-to-Docstring datasets CodeSearchNet, CodeSearchNet AdvTest and Code-Docstring Corpus from EdinburghNLP. Our experiments show that GAP-Gen achieves better results on automatic Python code generation task than previous works.

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

↑