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

Learning to Infer Generative Template Programs for Visual Concepts

R. Kenny Jones, Siddhartha Chaudhuri, Daniel Ritchie

Introduction

Humans possess a remarkable ability for few-shot learning. Upon seeing just a few examples of a new concept—such as a specific style of chair or a handwritten character—we can recognize new instances and even generate novel variations. In machine learning, achieving this level of generalization remains a significant hurdle.

Current approaches typically diverge into two paths. Neural methods are flexible and data-driven but often struggle with out-of-distribution generalization and are usually specialized for a single task, such as image generation or part segmentation. Conversely, symbolic or grammar-based methods offer high interpretability and strong generalization but are often brittle, requiring hand-engineered grammars that do not easily transfer between domains (e.g., from 2D sketches to 3D shapes).

This research introduces a neurosymbolic framework designed to bridge this gap by inferring "Template Programs" that capture the structural essence of a visual concept across diverse domains.

Methods: The Template Program Architecture

The core innovation of this work is the Template Program (TP). Unlike a standard program that describes a single object, a TP describes a set of objects. It utilizes a HOLE construct—a symbolic placeholder that allows different members of a concept group to possess varying sub-structures while sharing a consistent global template.

The inference process is handled by a pipeline of three specialized neural networks:

  1. TemplateNet: Analyzes a group of images (e.g., several instances of the same character) to predict a shared Template Program.
  2. ExpansionNet: Takes the inferred TP and a specific input image to determine how to fill the HOLE tokens for that particular instance.
  3. ParamNet: Predicts the continuous parameters (such as size, position, and orientation) required to instantiate the final, executable program.
The four-step inference architecture for generating programs from visual inputs.

The Learning Paradigm

To overcome the lack of ground-truth programs for real-world images, the authors employ a two-step unsupervised learning regime. First, the model undergoes synthetic pretraining on random programs sampled from a domain-specific language (DSL). Second, it uses bootstrapped fine-tuning, a "Wake-Sleep" style algorithm where the model oscillates between inferring programs for real data and training on its own "dreams" (synthesized programs). This process aligns the neural networks with the target visual domain without requiring manual labels.

Key Insights

  • Structural Diversity via HOLE: By explicitly modeling variance through holes, the system handles concepts with inherent structural diversity, such as chairs that may or may not have armrests.
  • Neurosymbolic Synergy: Neural networks manage the perception of converting pixels or voxels into symbols, while the symbolic DSL acts as a bottleneck ensuring that outputs are structurally valid.
  • Emergent Co-segmentation: Because the model must find one TP to explain a group of images, it naturally learns to correspond parts across instances. It identifies that the "top bar" of different characters corresponds to the same line of code in the inferred TP.

Key Results

The framework was evaluated across three distinct domains: 2D Primitive Layouts, Omniglot handwritten characters, and 3D Shape Structures (from the PartNet dataset).

Qualitative results showing input images, inferred part segmentations, and generated variations across 2D and 3D domains.
  • Omniglot Generation: The model outperformed general neural baselines like FSDM and VHE. It performed competitively with highly specialized handwriting models (BPL and GNS), despite being a domain-general system. In a perceptual study, humans preferred this method's generations 94% of the time over the strongest neural baseline.
  • 3D Co-segmentation: On 3D shapes, the framework achieved a 68.6 mIoU, significantly outperforming BAE-NET (53.2 mIoU), a popular deep learning baseline for shape parsing.
  • Out-of-Distribution Generalization: The model demonstrated robustness by generalizing to complex, unseen categories (like bookshelves) by recombining known elements of its DSL.

Limitations and Future Work

While successful, the current system uses a fixed input group size (typically five examples). Future iterations could utilize random masking to handle variable-sized groups. Additionally, the current Template Programs capture simple parametric relations; future work could incorporate more complex mathematical constraints between parts. Finally, the system's representational power is currently bounded by the complexity of the underlying DSL, making organic shapes a remaining challenge.

Summary updated

BibTeX
@inproceedings{jones2024learning,
  author = {R. Kenny Jones and Siddhartha Chaudhuri and Daniel Ritchie},
  title = {{Learning to Infer Generative Template Programs for Visual Concepts}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=ttaTyweIr1},
}
Figure