Neural Program Meta-Induction

Jacob Devlin, Rudy R. Bunel, Rishabh Singh, Matthew J. Hausknecht, Pushmeet Kohli

Introduction

This paper tackles the challenge of "few-shot" neural program induction—teaching a machine learning model to mimic a program's behavior using only a handful of input/output (I/O) examples. Traditional neural program induction models are notoriously data-hungry. To learn a simple algorithm like sorting, they often require thousands or even near-infinite I/O examples. In the real world, however, we often want a system to learn from just a few demonstrations (similar to Microsoft Excel’s FlashFill feature).

The core challenge addressed here is data efficiency: How can a model leverage knowledge from a broad family of related tasks to learn a specific new task with minimal data? The authors specifically investigate programs with complex control flow (loops, conditionals), which are significantly harder to induce than simple linear sequences. By introducing a new benchmark based on the Karel programming language and comparing transfer learning against $k$-shot conditioning, the authors demonstrate that the optimal strategy shifts depending on the number of available examples.

Methods and Architecture

The authors evaluate four distinct strategies for cross-task knowledge sharing:

  1. Plain Program Induction (PLAIN): A baseline supervised model trained from scratch on a single task.
  2. Portfolio-Adapted Program Induction (PLAIN+ADAPT): A transfer learning approach. The system maintains a "portfolio" of models pretrained on different tasks. When a new task arrives, the model that best predicts the new I/O examples is selected as a starting point and fine-tuned using Stochastic Gradient Descent (SGD).
  3. Meta Program Induction (META): A $k$-shot learning approach. Instead of fine-tuning, the model is trained to take $k$ demonstration I/O pairs as additional inputs. It learns a latent representation of the "task" and generalizes to new inputs without any weight updates at test time.
  4. Adapted Meta Program Induction (META+ADAPT): A hybrid approach where the META model is fine-tuned on the specific new task. To prevent overfitting on tiny datasets, they use data-mixture regularization, mixing the new task's data with random samples from other background tasks during fine-tuning.
Plain Induction Network Architecture

Architecture: All models use a CNN-based encoder for the 2D grid states and an LSTM decoder. Crucially, instead of predicting the final grid in one step, the LSTM predicts a "delta"—a sequence of actions (like "move," "turn," "pick marker") that transforms the input to the output.

The Karel Benchmark Dataset

To test these methods, the authors introduced a new benchmark based on Karel, an educational programming language.

Karel Sample Task and DSL
  • The Domain: A robot moves in a 2D grid with obstacles and markers.
  • The DSL: The language includes if/then/else, while loops, and repeat blocks, but no variables.
  • Complexity: Unlike simple list sorting, Karel requires the model to understand complex control flow that must work on arbitrary-size grids.
  • Scale: The authors generated 1,000,000 unique tasks for training the meta-models, providing a massive library of related tasks.

Key Insights and Results

The study reveals that there is no "one size fits all" method for program induction; the best approach depends heavily on data availability:

  • Extreme Data Sparsity ($n < 10$): META induction is the clear winner. PLAIN models fail completely in this regime.
  • Intermediate Data ($n = 20$ to $100$): META+ADAPT (the hybrid) performs best, successfully bridging the gap between general intuition and task-specific precision.
  • High Data ($n > 1000$): PLAIN+ADAPT (Portfolio) becomes the strongest approach, reaching nearly 90% accuracy on the Karel benchmark.

Interestingly, a pretrained Meta model can actually be a worse starting point for fine-tuning than a plain model if you have a massive amount of data. This is because the Meta model is optimized to represent an "average" of many tasks rather than the extreme precision required for one specific task. Furthermore, model capacity matters significantly more for Meta-induction than Plain induction, as representing an entire family of tasks requires more parameters.

Overall, all proposed transfer and meta methods dramatically outperformed the PLAIN baseline, which required nearly 10,000 examples to reach the performance that META achieved with just 5.

Limitations and Future Work

These methods rely heavily on having a massive library of "related" background tasks (100k+ for Meta-induction). In domains where such a library doesn't exist, these techniques are harder to apply. Additionally, while Karel is complex, it remains a synthetic DSL. Future work should explore these "adapted meta-induction" strategies in more principled real-world scenarios, such as natural language-to-code translation. Finally, transitioning from direct induction (generating the output grid) to program synthesis (generating the actual Karel code) could provide better interpretability and formal guarantees.

Summary updated

BibTeX
@inproceedings{devlin2017neural,
  author = {Jacob Devlin and Rudy R. Bunel and Rishabh Singh and Matthew J. Hausknecht and Pushmeet Kohli},
  title = {{Neural Program Meta-Induction}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
  url = {https://openreview.net/forum?id=r1ZZ7dbu-S},
}
Figure