EgoCoder: Intelligent Program Synthesis with Hierarchical Sequential Neural Network Model

Jiawei Zhang, Limeng Cui, Fisher B. GouzaarXiv 2018 · OpenReview

Abstract

Programming has been an important skill for researchers and practitioners in computer science and other related areas. To learn basic programing skills, a long-time systematic training is usually required for beginners. According to a recent market report, the computer software market is expected to continue expanding at an accelerating speed, but the market supply of qualified software developers can hardly meet such a huge demand. In recent years, the surge of text generation research works provides the opportunities to address such a dilemma through automatic program synthesis. In this paper, we propose to make our try to solve the program synthesis problem from a data mining perspective. To address the problem, a novel generative model, namely EgoCoder, will be introduced in this paper. EgoCoder effectively parses program code into abstract syntax trees (ASTs), where the tree nodes will contain the program code/comment content and the tree structure can capture the program logic flows. Based on a new unit model called Hsu, EgoCoder can effectively capture both the hierarchical and sequential patterns in the program ASTs. Extensive experiments will be done to compare EgoCoder with the state-of-the-art text generation methods, and the experimental results have demonstrated the effectiveness of EgoCoder in addressing the program synthesis problem.

The Challenge of Program Synthesis

The global demand for software developers is rapidly outstripping supply, leading researchers to seek automated solutions for program synthesis. However, writing code is fundamentally different from generating natural language. While natural language is relatively unstructured, computer code is highly structured, following a strict hierarchy and sequential logic.

Traditional deep learning models often treat code as a flat string of tokens. This "flat" approach misses the underlying logic flow and the nested dependencies that define how a program functions. To bridge this gap, the EgoCoder framework treats code as a structured tree rather than a simple sequence of text.

The hierarchical and sequential structure of a Python program, mapping source code to its logical components.

The EgoCoder Framework

EgoCoder moves away from raw text processing in favor of Abstract Syntax Trees (ASTs). By parsing source code into an AST, the model can represent components (like loops or assignments) as nodes and their logical relationships as edges.

The Hsu Unit (Hierarchical Sequential Unit)

The primary architectural innovation of this paper is the Hsu unit. To effectively process the tree structure of an AST, the authors designed a unit composed of two specialized sub-units:

  • Evolutional Sequential Unit (ESU): Designed for bottom-up tasks. It "evolves" information from child nodes up to the parent node, making it ideal for program interpretation (summarizing what a block of code does).
  • Inherited Sequential Unit (ISU): Designed for top-down tasks. It "inherits" context from the parent node to generate children, which is essential for program generation (writing code from a natural language prompt).
The internal architecture of the Hierarchical Sequential Unit (Hsu), illustrating the ESU and ISU sub-units and their information flow.

By combining these units with bi-directional sibling processing, EgoCoder captures both the nested logic (hierarchy) and the step-by-step flow (sequence) of programming languages.

Experimental Results

The authors evaluated EgoCoder on a real-world dataset of Python implementations for fundamental algorithms. The model was tested on three primary tasks: generation, interpretation, and completion.

Key Performance Metrics

  • Next Line Inference: EgoCoder achieved an accuracy of 0.949, significantly higher than the ~0.86 achieved by standard AST-based RNN baselines.
  • Program Generation: When given a natural language comment, EgoCoder successfully generated 35 out of 43 complete programs without a single mistake. Traditional methods could only manage 1 or 2.
  • Efficiency: Because the model understands the underlying grammar of the language, it converges much faster. EgoCoder required roughly 1/100th of the iterations compared to a standard AutoEncoder to reach superior performance.

Conclusion and Future Work

EgoCoder demonstrates that the grammar of a programming language is its most valuable feature for synthesis. By forcing the neural network to operate on the AST, the model focuses on logic rather than just syntax. While the model currently struggles with highly repetitive code or ambiguous logical paths in complex algorithms like the Sieve of Atkin, it represents a major step toward intelligent, automated programming. Future work will focus on integrating deeper context to resolve these logical conflicts and scaling the model to large-scale software systems.

Summary updated

Abstract

Programming has been an important skill for researchers and practitioners in computer science and other related areas. To learn basic programing skills, a long-time systematic training is usually required for beginners. According to a recent market report, the computer software market is expected to continue expanding at an accelerating speed, but the market supply of qualified software developers can hardly meet such a huge demand. In recent years, the surge of text generation research works provides the opportunities to address such a dilemma through automatic program synthesis. In this paper, we propose to make our try to solve the program synthesis problem from a data mining perspective. To address the problem, a novel generative model, namely EgoCoder, will be introduced in this paper. EgoCoder effectively parses program code into abstract syntax trees (ASTs), where the tree nodes will contain the program code/comment content and the tree structure can capture the program logic flows. Based on a new unit model called Hsu, EgoCoder can effectively capture both the hierarchical and sequential patterns in the program ASTs. Extensive experiments will be done to compare EgoCoder with the state-of-the-art text generation methods, and the experimental results have demonstrated the effectiveness of EgoCoder in addressing the program synthesis problem.
BibTeX
@misc{zhang2018egocoder,
  author = {Jiawei Zhang and Limeng Cui and Fisher B. Gouza},
  title = {{EgoCoder: Intelligent Program Synthesis with Hierarchical Sequential Neural Network Model}},
  year = {2018},
  eprint = {1805.08747},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.08747},
}
Figure