NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Neural Program Search: Solving Programming Tasks from Description and Examples

Illia Polosukhin, Alexander SkidanovWorkshops @ ICLR 2018

Introduction

Program synthesis—the "holy grail" of AI where a computer writes its own code—usually falls into two camps: Programming by Example (PBE) and Programming from Description.

PBE systems (like Excel's Flash Fill) are great for simple data transformations but require massive engineering effort to scale and often struggle with complex logic. On the other hand, synthesizing code from natural language descriptions is notoriously difficult because human language is ambiguous, while code must be syntactically perfect and logically precise.

Neural Program Search is a hybrid framework that addresses this "ambiguity vs. precision" gap. By combining deep learning with traditional program synthesis to generate code from both natural language descriptions and input/output examples, the system achieves over 85% accuracy on complex programming tasks. The authors argue that while a description can provide a high-level "hint" about a program's structure, input/output examples are needed to provide the final ground-truth verification.

Methods

The authors propose a system called Neural Program Search, which relies on three main pillars:

  1. A LISP-inspired DSL: They designed a functional, typed domain-specific language. Because it is LISP-like, programs are naturally represented as Abstract Syntax Trees (ASTs). The type system (integers, strings, arrays, etc.) helps prune the search space by ensuring only valid operations are considered for specific data types.
  2. Seq2Tree Model: Instead of a standard sequence-to-sequence (Seq2Seq) model—which treats code like a flat sentence—they use a Seq2Tree architecture. An encoder reads the natural language description, and a doubly-recurrent decoder generates the program's AST node-by-node. This ensures the model respects the hierarchical structure of programming logic.
Attention mechanism mapping natural language to an AST
  1. Tree-Beam Search: The Seq2Tree model provides probabilities for which code symbols should come next. The system uses these probabilities to conduct a beam search through the space of possible programs. Crucially, as soon as a candidate program is "complete," it is tested against the provided input/output examples. If it passes, the search stops and the program is returned.

To make this efficient, the researchers implemented Persistent Trees (to save memory when cloning candidate programs) and Batched Search (to evaluate multiple tasks simultaneously).

Datasets

The paper introduces a new benchmark called AlgoLISP.

  • Composition: It consists of roughly 100,000 pairs of problem descriptions, LISP-style solutions, and 10 test cases per problem.
  • Nature: It is semi-synthetic, generated by parameterizing common computer science homework assignments (e.g., "find all even elements in an array and return them in sorted order").
  • Split: The dataset is split into 79,214 training tasks, 9,352 dev tasks, and 10,940 test tasks.

Key Insights and Results

The most important takeaway from this research is that deep learning doesn't have to do the whole job. The neural network acts as a heuristic to guide the search toward "likely" programs, while the execution of test cases provides the definitive "truth."

Explicitly modeling the tree structure of code (Seq2Tree) provides a significant boost over treating code as a sequence of text. It prevents the model from wasting time on syntactically impossible programs. Furthermore, search alone (without ML guidance) had a near-zero success rate (0.6%). Conversely, the ML model alone (without search/examples) was much less accurate. The synergy between the two is where the performance lies.

The authors compared their approach against several baselines on the AlgoLISP test set:

  • Standard Seq2Seq + Attention: 54.1% accuracy.
  • Seq2Tree (Model only): 61.0% accuracy.
  • Neural Program Search (Seq2Tree + Search): 85.8% accuracy.
Accuracy comparison across different program depths

The results show that adding search to the Seq2Tree model improved performance by nearly 25 percentage points. Furthermore, the "Search" component proved more effective when guided by the Seq2Tree model than when guided by a standard Seq2Seq model (which reached only 72.3%). As program depth increases, the Seq2Tree + Search method maintains significantly higher accuracy than the baselines.

Limitations and Future Work

While highly effective, the approach has limitations:

  • Synthetic Data: The AlgoLISP dataset is semi-synthetic. While complex, it doesn't fully capture the messy, diverse way humans describe problems in the real world.
  • DSL Constraints: The system is limited to the operations defined in its specific DSL. Expanding this to general-purpose languages like Python or Java remains a massive challenge due to the much larger search space.
  • Training Efficiency: The authors mention that exploring alternative training methods, such as Reinforcement Learning (REINFORCE), might further improve the model's ability to pick the right symbols during search.

Summary updated

BibTeX
@inproceedings{polosukhin2018neural,
  author = {Illia Polosukhin and Alexander Skidanov},
  title = {{Neural Program Search: Solving Programming Tasks from Description and Examples}},
  booktitle = {Workshops @ ICLR},
  year = {2018},
}
Figure