[Paper Review] Automatic Program Synthesis of Long Programs with a Learned Garbage Collector
This paper proposes a neural program synthesis method that generates long programs by predicting the next statement in a sequence using a learned garbage collector to manage memory. It achieves two orders of magnitude faster runtime and more than double the program length compared to prior state-of-the-art methods, while maintaining high accuracy on complex input-output examples using beam search and joint learning of statement and variable deletion decisions.
We consider the problem of generating automatic code given sample input-output pairs. We train a neural network to map from the current state and the outputs to the program's next statement. The neural network optimizes multiple tasks concurrently: the next operation out of a set of high level commands, the operands of the next statement, and which variables can be dropped from memory. Using our method we are able to create programs that are more than twice as long as existing state-of-the-art solutions, while improving the success rate for comparable lengths, and cutting the run-time by two orders of magnitude. Our code, including an implementation of various literature baselines, is publicly available at https://github.com/amitz25/PCCoder
Motivation & Objective
- Address the challenge of synthesizing long programs in a domain-specific language (DSL) using few input-output examples.
- Overcome the exponential growth of search space in program synthesis by using a step-by-step, autoregressive neural prediction approach.
- Improve generalization and scalability by jointly training a neural network to predict both the next program statement and which variables to discard from memory.
- Enable synthesis of programs over twice as long as previous state-of-the-art methods while significantly reducing runtime and improving success rates.
Proposed method
- Use a feed-forward neural network to predict the next program statement (operator and operands) based on the current program environment, which includes input-output pairs and intermediate variable states.
- Apply beam search over predictions at each step, reapplying the neural network to guide the search toward valid and correct programs.
- Train a second neural network to predict which variables should be discarded from memory, improving memory management and generalization of the main network.
- Represent program states as concatenated input-output pairs and intermediate values, forming a dynamic environment vector that serves as input to the neural network.
- Use a joint training objective where variable deletion prediction acts as an auxiliary task to improve the primary task of statement prediction.
- Limit program length to a fixed maximum $ t $, but enable scalability through the use of a learned garbage collector that manages variable lifetime and reduces state explosion.
Experimental results
Research questions
- RQ1Can a neural network trained to predict the next statement in a program, combined with a learned garbage collector, significantly extend the length of synthesizable programs compared to existing methods?
- RQ2Does jointly training for statement prediction and variable deletion improve generalization and reduce search space in program synthesis?
- RQ3To what extent does the use of beam search guided by neural predictions reduce runtime compared to exhaustive search methods like DFS or CAB?
- RQ4How does the number of input-output examples during training and inference affect the success rate and solution diversity of the synthesis model?
- RQ5Is the learned representation of program environments invariant to the specific set of input-output examples used, indicating robustness to data variation?
Key findings
- The proposed PCCoder method achieves a success rate of 83% on programs of length 8, solving 83% of 1,000 test programs within a 1,000-second timeout, outperforming DeepCoder and RobustFill variants.
- With a 1,000-second timeout, PCCoder solves programs over twice as long as previous state-of-the-art methods, demonstrating a significant scalability improvement.
- PCCoder reduces average runtime by two orders of magnitude compared to DeepCoder, solving 83% of length-8 programs in just 3 seconds on average.
- The model trained on 10 input-output pairs (PCCoder_Ten) achieves 84% success rate on length-8 programs, and even better performance (84%) when tested on only 5 examples, indicating strong generalization.
- The ablation study shows that removing the IO state representation (PCCoder_No_IO) reduces success rate to 4%, highlighting the importance of tracking intermediate states.
- t-SNE visualization confirms that environments for the same program are grouped together regardless of input-output sample variation, indicating that the model learns invariant representations of program semantics.
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.