Skip to main content
QUICK REVIEW

[Paper Review] Learning to Synthesize Programs as Interpretable and Generalizable Policies

Dweep Trivedi, Jesse Zhang|arXiv (Cornell University)|Aug 31, 2021
Reinforcement Learning in RoboticsComputer Science116 references10 citations
TL;DR

This paper proposes LEAPS, a two-stage framework that learns to synthesize interpretable, generalizable programmatic policies for reinforcement learning tasks using only reward signals. It first learns a continuous program embedding space from unsupervised program-reward pairs, then uses CEM-based search over this space to discover task-solving programs, outperforming DRL and program synthesis baselines in the Karel domain while enabling human interpretability and generalization to unseen configurations.

ABSTRACT

Recently, deep reinforcement learning (DRL) methods have achieved impressive performance on tasks in a variety of domains. However, neural network policies produced with DRL methods are not human-interpretable and often have difficulty generalizing to novel scenarios. To address these issues, prior works explore learning programmatic policies that are more interpretable and structured for generalization. Yet, these works either employ limited policy representations (e.g. decision trees, state machines, or predefined program templates) or require stronger supervision (e.g. input/output state pairs or expert demonstrations). We present a framework that instead learns to synthesize a program, which details the procedure to solve a task in a flexible and expressive manner, solely from reward signals. To alleviate the difficulty of learning to compose programs to induce the desired agent behavior from scratch, we propose to first learn a program embedding space that continuously parameterizes diverse behaviors in an unsupervised manner and then search over the learned program embedding space to yield a program that maximizes the return for a given task. Experimental results demonstrate that the proposed framework not only learns to reliably synthesize task-solving programs but also outperforms DRL and program synthesis baselines while producing interpretable and more generalizable policies. We also justify the necessity of the proposed two-stage learning scheme as well as analyze various methods for learning the program embedding.

Motivation & Objective

  • To address the lack of interpretability and generalization in deep reinforcement learning (DRL) policies.
  • To enable program synthesis from sparse reward signals without expert demonstrations or input/output pairs.
  • To develop a flexible, expressive program representation that supports loops and conditionals for complex behaviors.
  • To create a reusable, continuous latent space for efficient search over program structures.
  • To demonstrate that learned programs generalize to larger and unseen state configurations while remaining human-editable.

Proposed method

  • Learns a continuous program embedding space via autoencoding randomly generated programs and their induced behaviors in the environment, using a variational autoencoder (VAE) with a differentiable program decoder.
  • Employs a two-stage training: first pre-training the program VAE on unsupervised program-reward reconstruction, then fine-tuning with policy gradient objectives.
  • Uses CMA-ES (CEM) to search over the learned latent space to find programs that maximize return for a given MDP task.
  • Introduces a program decoder that reconstructs executable code from latent vectors using a transformer-based sequence model.
  • Applies curriculum learning and reward shaping to improve training stability and sample efficiency.
  • Reuses the pre-trained program embedding space across multiple tasks without retraining.

Experimental results

Research questions

  • RQ1Can a program embedding space be learned purely from reward signals, without expert supervision or input/output pairs?
  • RQ2Does the two-stage learning scheme—unsupervised pre-training followed by reward-based search—improve sample efficiency and policy performance compared to end-to-end training?
  • RQ3Can the learned program policies generalize to larger state spaces and unseen environment configurations beyond the training distribution?
  • RQ4How do different program representations (e.g., with or without loops and conditionals) affect policy performance and interpretability?
  • RQ5To what extent can the synthesized programs be interpreted and edited by humans to improve task performance?

Key findings

  • LEAPS achieved 100% success rate across 10 random initial configurations on all Karel tasks, including complex ones like STAIRCLIMBER and FOURCORNER, where DRL methods failed.
  • LEAPS outperformed DRL, HRL, VIPER, and program synthesis baselines in both success rate and sample efficiency, with 100% success on CLEANHOUSE and HARVESTER where DRL agents learned no meaningful behavior.
  • The ablation study showed that the two-stage learning scheme was essential: random search over the latent space (LEAPS-rand) failed to find effective policies, while CEM search over the learned space succeeded.
  • Programs synthesized by LEAPS generalized to larger state spaces (e.g., 10x larger mazes) and unseen configurations, demonstrating robust generalization beyond training data.
  • Human users were able to interpret and edit LEAPS-generated programs to improve performance, confirming the method’s interpretability and editability.
  • The framework required only 8.8GB GPU memory and 104 hours for full training on M1, with inference via CEM taking under 10 minutes per task.

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.