treelstm-code-generation
A PyTorch Tree2Tree model that translates natural-language descriptions into source code by decoding a syntax tree of grammar rules instead of generating tokens one at a time.
treelstm-code-generation is a PyTorch implementation of a Tree2Tree neural network that translates natural-language descriptions into source code, built for the author's master's thesis on generating code from text with syntactic parsing. The approach parses the input sentence into a syntax tree (CCG, PCFG or dependency), encodes it with a recursive tree-LSTM, and decodes the output as a sequence of grammar rules that assemble a target-language abstract syntax tree, rather than generating code token-by-token. It is inspired by, and follows a structure similar to, Yin and Neubig's syntactic neural code-generation model and its NL2code reference implementation.
It is trained and evaluated on two natural-language-to-code datasets: HearthStone card text mapped to Python card implementations, and Django docstrings and comments mapped to Python code. Model and training options such as encoder type, syntax formalism, embedding sizes and the copy mechanism are configured in a single config file.
The author describes it as research/thesis code rather than production software.