NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Compositional Program Generation for Systematic Generalization

Tim Klinger, Luke Liu, Soham Dan, Maxwell Crouse, Parikshit Ram, Alexander GrayarXiv 2023 · DOI

Introduction

Modern deep learning models, particularly Transformers, have achieved remarkable success across various language tasks. However, they often struggle with systematicity—the ability to understand and produce novel combinations of known components. For instance, a model trained on "walk left twice" and "run" might fail to generalize to "run left twice" without extensive additional training. In contrast, humans exhibit robust compositional generalization, intuitively combining concepts into new structures.

The Compositional Program Generator (CPG) addresses this gap. It is a neuro-symbolic architecture designed to leverage the inherent structure of language to learn more efficiently and generalize more robustly than standard neural approaches.

Methodology

CPG combines the flexibility of neural networks with the structural rigour of symbolic logic through a modular design. The process involves three primary stages:

  1. Grammar-Based Parsing: Input sentences are decomposed into parse trees using a context-free grammar (CFG).
  2. Modular Semantic Programs: Rather than employing a monolithic "black box" network, CPG assigns specific neural modules to individual grammar rules. These modules include Copy programs for moving input tokens to the output and Substitution programs for populating logical templates.
  3. Differentiable Symbolic Operations: Training utilizes a "hard" Gumbel-softmax, making the selection of symbolic operations end-to-end trainable via standard gradient descent.
Figure 2: CPG processing the COGS sentence "Emma ate the bread" through parsing, computation tree generation, and evaluation.

To ensure stability and prevent catastrophic forgetting, CPG employs curricular training. The model masters simple, short sentences first; once a module for a specific grammar rule is learned, its parameters are frozen before moving to more complex structures.

Experimental Evaluation

The model was evaluated on two benchmark datasets for compositional generalization:

  • SCAN: Translating navigation commands into action sequences.
  • COGS: Mapping English sentences to logical semantic forms.

A key contribution of this work is the evaluation of few-shot generalization. The researchers reduced the training sets significantly, using only 14 examples for SCAN and 22 for COGS, testing the model's ability to learn from minimal data.

Results and Discussion

CPG demonstrates exceptional performance across both benchmarks, achieving perfect accuracy while requiring orders of magnitude less data than baseline models.

Figure 6: Performance comparison of CPG against state-of-the-art models on SCAN and COGS datasets.

Key Findings:

  • Extreme Sample Efficiency: As shown in the results table, CPG achieves 100% accuracy on SCAN and COGS with just 14-22 samples. This represents a 1000x improvement in sample efficiency compared to standard neural approaches.
  • Zero-Shot Emergence: Due to its structural modularity, the model often solves longer, more complex sentences in new training stages "zero-shot," generalizing to new lengths before seeing a single training example of that length.
  • Interpretability: The computation tree provides a transparent view of the model's reasoning, allowing researchers to trace which module was responsible for specific parts of the output.

Limitations and Future Work

While CPG shows great promise, it currently relies on a predefined grammar and, in some instances, a dictionary mapping words to types. This limits its immediate applicability to messy, real-world natural language. Future research will focus on learning grammars and dictionaries directly from data and scaling the architecture to handle ambiguous or noisy language tasks.

Summary updated

BibTeX
@misc{klinger2023compositional,
  author = {Tim Klinger and Luke Liu and Soham Dan and Maxwell Crouse and Parikshit Ram and Alexander Gray},
  title = {{Compositional Program Generation for Systematic Generalization}},
  year = {2023},
  eprint = {2309.16467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.16467},
}
Figure