Skip to main content
QUICK REVIEW

[Paper Review] Write, Execute, Assess: Program Synthesis with a REPL

Kevin Ellis, Maxwell Nye|arXiv (Cornell University)|Jun 9, 2019
Reinforcement Learning in RoboticsComputer Science21 references20 citations
TL;DR

This paper proposes a neural program synthesis framework that integrates writing, executing, and assessing code via a REPL (Read-Eval-Print Loop) to navigate the semantic space of programs. By combining a policy network for action selection, a value function for long-term assessment, and Sequential Monte Carlo search with execution feedback, the method achieves faster, more reliable synthesis of complex text-editing and 3D/2D graphics programs than prior approaches.

ABSTRACT

We present a neural program synthesis approach integrating components which write, execute, and assess code to navigate the search space of possible programs. We equip the search process with an interpreter or a read-eval-print-loop (REPL), which immediately executes partially written programs, exposing their semantics. The REPL addresses a basic challenge of program synthesis: tiny changes in syntax can lead to huge changes in semantics. We train a pair of models, a policy that proposes the new piece of code to write, and a value function that assesses the prospects of the code written so-far. At test time we can combine these models with a Sequential Monte Carlo algorithm. We apply our approach to two domains: synthesizing text editing programs and inferring 2D and 3D graphics programs.

Motivation & Objective

  • To address the challenge of semantic sensitivity in program synthesis, where small syntactic changes cause large semantic shifts.
  • To enable neural agents to emulate human programming workflows by interleaving writing, execution, and assessment of partial programs.
  • To improve program synthesis robustness and efficiency by grounding search in execution states rather than syntax alone.
  • To validate the framework across diverse domains: text editing and 2D/3D graphics program synthesis.
  • To demonstrate generalization to long programs beyond the training distribution, including those with over 40 actions.

Proposed method

  • The framework uses a policy network to propose the next code token or construct based on the current partial program and its execution state.
  • A value function evaluates the long-term promise of the current partial program state, guiding search toward more productive paths.
  • A REPL executes partially written programs in real time, exposing their semantics and enabling immediate feedback on correctness.
  • Sequential Monte Carlo (SMC) search is used at inference time to sample actions via the policy, reweight candidates based on value function scores, and prune unpromising branches.
  • The system performs stochastic search in the semantic space by conditioning on execution outcomes rather than program syntax.
  • The policy and value networks are trained via reinforcement learning on a distribution of synthesis tasks, with rewards shaped by program correctness.

Experimental results

Research questions

  • RQ1Can integrating a REPL into neural program synthesis improve semantic understanding and reduce sensitivity to syntactic noise?
  • RQ2Does learning a value function that assesses partial programs enhance search efficiency and convergence in program synthesis?
  • RQ3Can a unified framework based on writing, executing, and assessing code generalize across diverse domains like text editing and 3D graphics?
  • RQ4How does SMC-based search with execution feedback compare to beam search or rollout in terms of synthesis accuracy and efficiency?
  • RQ5To what extent can the model generalize to programs longer than seen during training?

Key findings

  • The value-guided SMC sampler achieved the highest number of correct programs on a challenging 87-problem text-editing dataset, outperforming beam search and rollout methods.
  • The system synthesized programs with up to 40 actions and over 350 bits of description length, demonstrating strong out-of-distribution generalization beyond its 30-action training limit.
  • Beam search with the value function outperformed beam search without it, confirming the value function’s role in improving search quality.
  • The method consistently found correct programs on held-out test instances, such as correctly transforming 'Dr James Watson' to 'Watson, James (Dr)' and '12/8/2019' to 'date: 8 mo: 12 year: 2019'.
  • The integration of a REPL reduced the model’s reliance on syntactic patterns, enabling more robust learning of semantic relationships between code and behavior.
  • The framework showed superior performance and lower node expansion counts compared to baseline methods like RobustFill, especially on complex, long-form transformations.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.