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

TreeGen:一种基于树的Transformer代码生成结构

TreeGen: A Tree-Based Transformer Architecture for Code Generation

Peking University(北京大学);University of Alberta(阿尔伯塔大学)

Zeyu Sun, Qihao Zhu, Yingfei Xiong, Yican Sun, Lili Mou, Lu Zhang

摘要:

一种代码生成系统基于输入的自然语言描述生成程序设计语言代码。现有技术的方法依赖于神经网络来进行代码生成。然而,这些代码生成器存在两个问题。一个是长依赖性问题,其中代码元素通常依赖于另一个遥远的代码元素。例如,变量引用取决于它的定义,它可能出现在相当多的行之前。另一个问题是结构建模,因为程序包含丰富的结构信息。在本文中,我们提出了一种新的基于树的神经架构,TreeGen,代码生成。TreeGen使用Transformers的注意力机制来缓解长依赖问题,并引入了一种新的AST阅读器(编码器),将语法规则和AST结构纳入网络。我们在一个Python基准测试HearthStone和两个语义解析基准测试ATIS和GEO上评估了TreeGen。TreeGen在HearthStone上的表现超过了之前最先进的方法4.5个百分点,并且在ATIS(89.1%)和GEO(89.6%)上实现了基于神经网络的方法中的最佳准确性。我们还进行了消融测试,以更好地了解我们模型的每个组件。

英文摘要:

A code generation system generates programming language code based on an input natural language description. State-of-the-art approaches rely on neural networks for code generation. However, these code generators suffer from two problems. One is the long dependency problem, where a code element often depends on another far-away code element. A variable reference, for example, depends on its definition, which may appear quite a few lines before. The other problem is structure modeling, as programs contain rich structural information. In this paper, we propose a novel tree-based neural architecture, TreeGen, for code generation. TreeGen uses the attention mechanism of Transformers to alleviate the long-dependency problem, and introduces a novel AST reader (encoder) to incorporate grammar rules and AST structures into the network. We evaluated TreeGen on a Python benchmark, HearthStone, and two semantic parsing benchmarks, ATIS and GEO. TreeGen outperformed the previous state-of-the-art approach by 4.5 percentage points on HearthStone, and achieved the best accuracy among neural network-based approaches on ATIS (89.1%) and GEO (89.6%). We also conducted an ablation test to better understand each component of our model.

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

↑