Neural Program Synthesis with a Differentiable Fixer

Matej Balog, Rishabh Singh, Petros Maniatis, Charles SuttonarXiv 2020

Abstract

We present a new program synthesis approach that combines an encoder-decoder based synthesis architecture with a differentiable program fixer. Our approach is inspired from the fact that human developers seldom get their program correct on the first attempt, and perform iterative testing-based program fixing to get to the desired program functionality. Similarly, our approach first learns a distribution over programs conditioned on an encoding of a set of input-output examples, and then iteratively performs fix operations using the differentiable fixer. The fixer takes as input the original examples and the current program's outputs on example inputs, and generates a new distribution over the programs with the goal of reducing the discrepancies between the current program outputs and the desired example outputs. We train our architecture end-to-end on the RobustFill domain, and show that the addition of the fixer module leads to a significant improvement on synthesis accuracy compared to using beam search.

Introduction

Program synthesis—automatically generating code that satisfies a specification such as input-output examples—is a foundational challenge in AI. Most current deep learning approaches, particularly in Programming by Example (PBE), treat this as a "one-shot" translation task. A model observes examples and attempts to generate the correct program in a single pass. When the initial attempt fails, these systems typically rely on beam search to explore variations. However, beam search is fundamentally "blind" to the semantic reasons for failure; it does not analyze the actual output produced by the incorrect code. In contrast, human developers identify discrepancies between actual and desired behavior to iteratively refine their logic. This research introduces a differentiable fixer to bridge this gap.

Methodology

The proposed architecture consists of two primary stages: a Base Synthesizer and a Differentiable Fixer. The Base Synthesizer is a standard LSTM-based encoder-decoder model that generates an initial program $P$ from input-output examples. If $P$ fails to satisfy the specification, the Differentiable Fixer takes over.

The core innovation is the Executed Example Encoder, which processes "triplets" containing the original input, the desired output, and the actual output from the current program. By comparing these, the fixer learns a latent representation of the "bug" and predicts a corrected program $P'$. This entire pipeline is differentiable, allowing end-to-end training.

Architecture of the neural program synthesis model with a differentiable fixer

The model was evaluated on the RobustFill domain, a benchmark for string transformation tasks. Training utilized a massive synthetic dataset of 512 million tasks. Programs involved up to 10 expressions, including concatenations and regex-based indexing, with strings up to 80 characters long.

Key Insights and Results

The fixer shifts the search process from syntactic to semantic. While beam search explores programs that look similar to the top guess, the fixer explores programs that behave more like the target. This allows for "holistic fixes," where multiple parts of a program are changed simultaneously—a feat beam search rarely achieves. Additionally, the fixer helps overcome "path degeneracy" in neural decoders by generating a completely new distribution over programs, effectively "jumping" to different areas of the solution space.

Performance comparison between standard beam search and the proposed fixer model

Empirical results demonstrate a significant accuracy boost. On the validation set, a base model with a hidden size of 512 achieved 53% accuracy using beam search. Integrating the differentiable fixer increased this to 61%. To ensure this gain was not merely due to increased parameter count, the authors compared it against larger baseline models. Even a baseline with ~45% more parameters only reached 56% accuracy. Notably, when the first guess was incorrect, the fixer was more than twice as likely as beam search to find the correct program on the second attempt.

Conclusion and Future Work

While effective, the current fixer is "code blind"—it observes execution outputs but not the source code itself. Future research could incorporate a program encoder to allow the fixer to analyze the buggy code directly. Furthermore, while the current approach relies on a Domain Specific Language (DSL) with fast execution, scaling to general-purpose languages like Python remains an open challenge. Combining this "full-program" fixer with execution-guided synthesis represents a promising path toward even more robust automated programming systems.

Reference: Balog, M., Singh, R., Maniatis, P., & Sutton, C. (2020). Neural Program Synthesis with a Differentiable Fixer. arXiv:2006.10924v1.

Summary updated

BibTeX
@misc{balog2020neural,
  author = {Matej Balog and Rishabh Singh and Petros Maniatis and Charles Sutton},
  title = {{Neural Program Synthesis with a Differentiable Fixer}},
  year = {2020},
  eprint = {2006.10924},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.10924},
}
Figure