Skip to main content
QUICK REVIEW

[Paper Review] Learning to Infer Program Sketches

Maxwell Nye, Luke Hewitt|arXiv (Cornell University)|Feb 17, 2019
Software Engineering ResearchComputer Science32 citations
TL;DR

This paper proposes SketchAdapt, a neuro-symbolic program synthesis system that learns to generate intermediate program sketches from input-output examples and natural language specifications. By dynamically balancing neural pattern recognition and symbolic search through a self-supervised training objective, the model achieves state-of-the-art performance on English-to-code tasks, matching neural models in memorization and symbolic methods in generalization.

ABSTRACT

Our goal is to build systems which write code automatically from the kinds of specifications humans can most easily provide, such as examples and natural language instruction. The key idea of this work is that a flexible combination of pattern recognition and explicit reasoning can be used to solve these complex programming problems. We propose a method for dynamically integrating these types of information. Our novel intermediate representation and training algorithm allow a program synthesis system to learn, without direct supervision, when to rely on pattern recognition and when to perform symbolic search. Our model matches the memorization and generalization performance of neural synthesis and symbolic search, respectively, and achieves state-of-the-art performance on a dataset of simple English description-to-code programming problems.

Motivation & Objective

  • To develop a domain-general program synthesis system that combines neural pattern recognition with symbolic reasoning for programming-by-example and natural language specification.
  • To enable the system to learn when to rely on pattern recognition versus symbolic search without explicit supervision.
  • To improve data efficiency and generalization to out-of-sample tasks, especially for rare or unseen subexpressions.
  • To validate the approach on complex, real-world programming tasks such as AlgoLisp, where pure neural or symbolic methods struggle.

Proposed method

  • Introduces a flexible, domain-general sketch grammar that allows the model to generate intermediate program representations of varying specificity.
  • Employs a learned neural sketch generator to propose sketches conditioned on input examples and natural language descriptions.
  • Uses a symbolic enumerative program synthesizer to complete sketches by searching over possible implementations of the holes.
  • Applies a novel self-supervised training objective that encourages the model to learn appropriate sketch granularity based on task difficulty.
  • Trains the system end-to-end using contrastive learning and reconstruction signals from program outputs.
  • Supports dynamic adaptation: simpler tasks lead to more complete sketches (neural dominance), while complex tasks yield more abstract sketches (symbolic dominance).

Experimental results

Research questions

  • RQ1Can a neuro-symbolic system learn to balance pattern recognition and symbolic reasoning without explicit supervision?
  • RQ2How does the system's ability to generate intermediate sketches affect data efficiency and generalization on out-of-sample tasks?
  • RQ3Can the system achieve state-of-the-art performance on English-to-code programming tasks that require both memorization and generalization?
  • RQ4How well does the system generalize to previously unseen subexpressions, such as 'odd' values in a list, when not seen during training?
  • RQ5To what extent can the system leverage unstructured natural language specifications in addition to input-output examples?

Key findings

  • SketchAdapt achieves state-of-the-art performance on the AlgoLisp English-to-code dataset, outperforming both RNN-based baselines and purely symbolic methods.
  • With a beam size of 10 and full training data, SketchAdapt achieves near-perfect accuracy, significantly exceeding previously reported SOTA results.
  • On smaller training subsets, SketchAdapt generalizes better than the 'Generator only' RNN baseline, demonstrating improved data efficiency.
  • SketchAdapt exhibits strong zero-shot generalization to the 'odd' subexpression, solving 635 test programs containing 'odd' that were not in the training data, while the RNN baseline fails on this task.
  • The model generalizes effectively to 'even' programs as well, showing robustness to both seen and unseen subexpressions.
  • The symbolic synthesis component enables strong generalization, while the neural component ensures high memorization accuracy, achieving a balance unmatched by prior models.

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.