Embedding API Dependency Graph for Neural Code Generation
arXiv:2103.15361 · doi:10.1007/s10664-021-09968-2
Abstract
The problem of code generation from textual program descriptions has long been viewed as a grand challenge in software engineering. In recent years, many deep learning based approaches have been proposed, which can generate a sequence of code from a sequence of textual program description. However, the existing approaches ignore the global relationships among API methods, which are important for understanding the usage of APIs. In this paper, we propose to model the dependencies among API methods as an API dependency graph (ADG) and incorporate the graph embedding into a sequence-to-sequence (Seq2Seq) model. In addition to the existing encoder-decoder structure, a new module named ``embedder" is introduced. In this way, the decoder can utilize both global structural dependencies and textual program description to predict the target code. We conduct extensive code generation experiments on three public datasets and in two programming languages (Python and Java). Our proposed approach, called ADG-Seq2Seq, yields significant improvements over existing state-of-the-art methods and maintains its performance as the length of the target code increases. Extensive ablation tests show that the proposed ADG embedding is effective and outperforms the baselines.
References in corpus (22)
- Adam: A Method for Stochastic Optimization
- Neural Machine Translation by Jointly Learning to Align and Translate
- Sequence to Sequence Learning with Neural Networks
- DeepWalk: Online Learning of Social Representations
- Semi-Supervised Classification with Graph Convolutional Networks
- Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
- Inductive Representation Learning on Large Graphs
- Convolutional Sequence to Sequence Learning
- Gated Graph Sequence Neural Networks
- Grid Long Short-Term Memory
- Convolutional Neural Networks over Tree Structures for Programming Language Processing
- Graph Matching Networks for Learning the Similarity of Graph Structured Objects
- Language to Logical Form with Neural Attention
- Latent Predictor Networks for Code Generation
- Generative Code Modeling with Graphs
- Multi-task Sequence to Sequence Learning
- Code Generation as a Dual Task of Code Summarization
- Dynamic Neural Program Embedding for Program Repair
- On End-to-End Program Generation from User Intention by Deep Neural Networks
- Learning to Represent Programs with Graphs
- Understanding and Resolving Performance Degradation in Graph Convolutional Networks
- TreeGen: A Tree-Based Transformer Architecture for Code Generation