[Paper Review] Neural Program Search: Solving Programming Tasks from Description and Examples
This paper proposes Neural Program Search, a method that combines a Seq2Tree neural model with guided tree search to generate correct programs from natural language descriptions and input/output examples. It achieves 85.8% test accuracy on a semi-synthetic dataset, significantly outperforming both sequence-to-sequence and example-only baselines by leveraging structured program decoding and search over a LISP-inspired DSL with type constraints.
We present a Neural Program Search, an algorithm to generate programs from natural language description and a small number of input/output examples. The algorithm combines methods from Deep Learning and Program Synthesis fields by designing rich domain-specific language (DSL) and defining efficient search algorithm guided by a Seq2Tree model on it. To evaluate the quality of the approach we also present a semi-synthetic dataset of descriptions with test examples and corresponding programs. We show that our algorithm significantly outperforms a sequence-to-sequence model with attention baseline.
Motivation & Objective
- Address the challenge of program synthesis from ambiguous natural language descriptions and sparse input/output examples, which limits the scalability of existing methods.
- Overcome the limitations of pure sequence-to-sequence models and example-only approaches by combining neural understanding with symbolic search.
- Design a domain-specific language (DSL) that is expressive enough for common programming tasks yet compact and tractable for efficient search.
- Improve generalization and accuracy in program synthesis by integrating neural sequence-to-tree decoding with beam search guided by learned probabilities.
- Evaluate the approach on a new semi-synthetic dataset, AlgoLISP, to benchmark performance on data transformation-style problems.
Proposed method
- Design a LISP-inspired domain-specific language (DSL) with a static type system to represent programs as abstract syntax trees (ASTs), enabling efficient and precise program generation.
- Train a Seq2Tree model with attention that encodes the natural language description and decodes program syntax trees symbol-by-symbol, predicting the most likely AST nodes.
- Apply tree beam search to explore the most probable program candidates, guided by the Seq2Tree model’s output probabilities, while filtering only those programs that satisfy the provided input/output examples.
- Use a hybrid search strategy where the neural model ranks potential programs, and the search phase validates correctness via test cases, ensuring syntactic and semantic consistency.
- Introduce a semi-synthetic dataset, AlgoLISP, containing problem descriptions, corresponding DSL programs, and test cases, to train and evaluate the model.
- Implement a search algorithm with a configurable limit on visited programs (MAX_VISITED), enabling analysis of search efficiency and model quality.
Experimental results
Research questions
- RQ1Can combining neural sequence-to-tree generation with guided search over a DSL improve program synthesis accuracy beyond end-to-end sequence-to-sequence models?
- RQ2How effective is a LISP-inspired DSL with type constraints in enabling compact, efficient, and accurate program search for common programming tasks?
- RQ3To what extent does incorporating input/output examples improve program synthesis when combined with natural language descriptions?
- RQ4How does the performance of the model scale with the number of programs explored during search, and what does this reveal about the quality of the neural model’s predictions?
- RQ5How does program complexity (measured by AST depth) affect the model’s ability to recover correct programs?
Key findings
- The Seq2Tree model with guided search achieved 85.8% test accuracy on the AlgoLISP dataset, significantly outperforming the baseline sequence-to-sequence model with attention (54.1% accuracy).
- The combination of Seq2Tree and search reduced error rates by over 20 percentage points compared to the next best baseline, IO2Seq, which achieved only 12.8% accuracy with search.
- The Seq2Tree model alone improved accuracy by 11% over the sequence-to-sequence baseline, demonstrating the benefit of structured tree decoding over flat sequence generation.
- Search performance improved with more visited programs (higher MAX_VISITED), but the Seq2Tree+Search model showed rapid convergence, indicating high-quality neural predictions that prioritize correct paths early.
- Accuracy decreased with increasing program depth, confirming that more complex programs are harder to synthesize, though the model still achieved over 70% accuracy on programs with depth 5–7.
- The search-only baseline (without neural guidance) achieved only 0.6% accuracy, showing that neural guidance is essential for effective exploration of the program space.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.