Transformer with Tree-order Encoding for Neural Program Generation
Klaudia-Doris Thellmann, Bernhard Stadler, Ricardo Usbeck, Jens, Lehmann

TL;DR
This paper introduces a Transformer model with tree-order encoding and a grammar-based decoder to incorporate hierarchical syntax information for improved neural program generation, demonstrating benefits over traditional sequential encodings.
Contribution
The authors propose a novel tree-order positional encoding and a grammar graph-based decoder to enhance code generation with hierarchical syntax awareness.
Findings
Tree-order encoding improves code generation performance.
Hierarchical syntax encoding outperforms flat positional encoding.
The approach maintains well-formedness of generated code.
Abstract
While a considerable amount of semantic parsing approaches have employed RNN architectures for code generation tasks, there have been only few attempts to investigate the applicability of Transformers for this task. Including hierarchical information of the underlying programming language syntax has proven to be effective for code generation. Since the positional encoding of the Transformer can only represent positions in a flat sequence, we have extended the encoding scheme to allow the attention mechanism to also attend over hierarchical positions in the input. Furthermore, we have realized a decoder based on a restrictive grammar graph model to improve the generation accuracy and ensure the well-formedness of the generated code. While we did not surpass the state of the art, our findings suggest that employing a tree-based positional encoding in combination with a shared…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Topic Modeling · Machine Learning in Materials Science
MethodsLinear Layer · Attention Is All You Need · Softmax · Multi-Head Attention · Residual Connection · Adam · Label Smoothing · Dropout · Byte Pair Encoding · Layer Normalization
