Skip to main content
QUICK REVIEW

[Paper Review] Abstract Syntax Networks for Code Generation and Semantic Parsing

Maxim Rabinovich, Mitchell Stern|arXiv (Cornell University)|Apr 25, 2017
Natural Language Processing TechniquesComputer Science25 references38 citations
TL;DR

This paper introduces Abstract Syntax Networks (ASNs), a modular encoder-decoder framework that generates well-formed abstract syntax trees (ASTs) through dynamic, grammar-guided recursive decoding. The approach achieves state-of-the-art results on code generation (79.2 BLEU, 22.7% exact match on Hearthstone) and competitive performance on semantic parsing benchmarks without task-specific engineering.

ABSTRACT

Tasks like code generation and semantic parsing require mapping unstructured (or partially structured) inputs to well-formed, executable outputs. We introduce abstract syntax networks, a modeling framework for these problems. The outputs are represented as abstract syntax trees (ASTs) and constructed by a decoder with a dynamically-determined modular structure paralleling the structure of the output tree. On the benchmark Hearthstone dataset for code generation, our model obtains 79.2 BLEU and 22.7% exact match accuracy, compared to previous state-of-the-art values of 67.1 and 6.1%. Furthermore, we perform competitively on the Atis, Jobs, and Geo semantic parsing datasets with no task-specific engineering.

Motivation & Objective

  • To address the challenge of generating well-formed, executable outputs in code generation and semantic parsing tasks.
  • To model structured outputs with complex syntactic and semantic constraints, such as well-typedness and executability.
  • To develop a flexible, modular decoding framework that mirrors the recursive structure of abstract syntax trees (ASTs).
  • To improve generalization and performance on code generation and semantic parsing without task-specific architectural modifications.
  • To enable end-to-end learning of structured outputs while maintaining strong generalization across diverse datasets.

Proposed method

  • The model uses a sequence-to-sequence encoder-decoder architecture with an attention mechanism to encode input sequences.
  • The decoder is composed of multiple submodels, each responsible for generating a specific AST node type based on the grammar.
  • Decoding proceeds via dynamic, mutually recursive calls between submodels, mirroring the recursive structure of the AST.
  • Each submodel generates its corresponding AST node by predicting its children and attributes in a top-down, hierarchical manner.
  • The system uses greedy decoding with attention to attend to relevant input tokens during generation.
  • The architecture is trained end-to-end using cross-entropy loss on gold-standard ASTs.

Experimental results

Research questions

  • RQ1Can a modular, recursive decoder architecture effectively generate well-formed abstract syntax trees for code and semantic parsing?
  • RQ2Does the dynamic recursion in the decoder better capture the structural dependencies in ASTs compared to standard sequence-to-sequence models?
  • RQ3Can the same framework achieve strong performance across diverse structured prediction tasks with minimal adaptation?
  • RQ4How does the model perform on code generation when compared to prior state-of-the-art methods?
  • RQ5What types of structural and syntactic patterns in code are most challenging for the model to generate?

Key findings

  • On the Hearthstone code generation benchmark, the model achieves 79.2 BLEU and 22.7% exact match accuracy, significantly outperforming the previous SOTA of 67.1 BLEU and 6.1% exact match.
  • On the Jobs dataset, the model achieves 92.9% exact match accuracy, surpassing the previous SOTA of 90.7%.
  • The model performs competitively on the ATIS and Geo datasets, matching or exceeding the exact match performance of Dong and Lapata (2016).
  • The model struggles most with imperative-style code involving complex control flow, variable scoping, and non-trivial logic, often missing key statements or making minor syntactic errors.
  • The model generally performs well on simple and nested function-call-based code, where structural patterns are predictable and reusable.
  • Evaluation metrics like BLEU and exact match are found to be imperfect proxies for functional equivalence, highlighting the need for better evaluation methods.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.