Unsupervised Learning of Neurosymbolic Encoders

Eric Zhan, Jennifer J. Sun, Ann Kennedy, Yisong Yue, Swarat Chaudhuri

Abstract

We present a framework for the unsupervised learning of neurosymbolic encoders, which are encoders obtained by composing neural networks with symbolic programs from a domain-specific language. Our framework naturally incorporates symbolic expert knowledge into the learning process, which leads to more interpretable and factorized latent representations compared to fully neural encoders. We integrate modern program synthesis techniques with the variational autoencoding (VAE) framework, in order to learn a neurosymbolic encoder in conjunction with a standard decoder. The programmatic descriptions from our encoders can benefit many analysis workflows, such as in behavior modeling where interpreting agent actions and movements is important. We evaluate our method on learning latent representations for real-world trajectory data from animal biology and sports analytics. We show that our approach offers significantly better separation of meaningful categories than standard VAEs and leads to practical gains on downstream analysis tasks, such as for behavior classification.

Introduction

Unsupervised learning, particularly through Variational Autoencoders (VAEs), is highly effective at discovering latent structures in complex data such as animal trajectories or sports analytics. However, the resulting latent representations are typically high-dimensional vectors that lack human interpretability. While neurosymbolic approaches—combining neural networks with symbolic logic—have been explored to improve interpretability, most existing work focuses on decoders or requires supervised labels. This paper introduces a framework for the unsupervised learning of neurosymbolic encoders, enabling the automatic discovery of programmatic rules that describe data without human-provided labels.

The Neurosymbolic-VAE (ns-vae) Framework

The proposed ns-vae partitions the latent representation $z$ into two distinct components:

  1. $z_{neural}$ ($z_\phi$): Computed by a standard neural network to capture high-dimensional residuals and nuances.
  2. $z_{symbolic}$ ($z_{(\alpha,\psi)}$): Computed by a symbolic program written in a Domain-Specific Language (DSL).
The ns-vae architecture featuring a dual-encoder setup: a symbolic encoder (initially neural) and a standard neural encoder feeding into a shared latent space.

Optimization and Program Synthesis

Since discrete program structures are non-differentiable, the authors employ an iterative two-step optimization process:

  • Step 1 (VAE Training): A fully neural version of the encoder and the decoder are trained to maximize the Evidence Lower Bound (ELBO).
  • Step 2 (Program Synthesis): Using Neural Admissible Relaxation (NEAR), the neural encoder's behavior is "distilled" into a symbolic program. The search identifies a program in the DSL that best approximates the mapping from inputs to the latent space.
  • Refinement: These steps are repeated, gradually transitioning the encoder from a neural to a fully symbolic state.
The iterative optimization process: Step 1 optimizes parameters with a fixed program structure, Step 2 updates the symbolic encoder via program synthesis, and the cycle repeats until the encoder is fully symbolic.

To ensure the symbolic component captures meaningful categories rather than redundant information, the framework incorporates adversarial information factorization and channel capacity constraints.

Experimental Evaluation

The framework was evaluated on three trajectory datasets: synthetic 2D paths, real-world social interaction data from mice (CalMS21), and NBA player trajectory data.

Key Results

  • Superior Clustering: On the CalMS21 dataset, the neurosymbolic encoder achieved a Normalized Mutual Information (NMI) of 0.423, significantly outperforming standard Trajectory-VAEs (0.089) and JointVAEs (0.019).
  • Category Separation: Cluster purity reached 0.756 with learned programs, compared to approximately 0.60 for purely neural baselines.
  • Downstream Utility: Automatically learned programs proved highly effective for behavior classification. A single synthesized program performed comparably to ten expert-hand-crafted programs in a task programming framework.

Discussion and Insights

A key strength of the ns-vae is its residual strategy: the neural component handles subtle data nuances while the symbolic component captures high-level logic (e.g., distance thresholds). This makes the model robust to DSL design; experiments showed consistent performance across different expert-provided feature sets. Furthermore, the synthesized programs are directly interpretable; for instance, a behavioral neuroscientist identified a learned program as representing "tail sniffing" based on its nose-to-tail distance logic.

Limitations

Despite its successes, the approach faces challenges in search scalability due to the combinatorial nature of program synthesis. Additionally, while robust, the model still relies on a human-defined DSL. Future research could explore the automatic discovery of DSL primitives and extending the framework to higher-dimensional inputs like raw video.

Conclusion

The ns-vae framework demonstrates that unsupervised learning can produce interpretable, factorized representations by integrating program synthesis with the VAE framework. By bridging the gap between neural intuition and symbolic logic, this approach offers a powerful tool for domain experts to analyze complex behavioral data.

Summary updated

BibTeX
@article{zhan2022unsupervised,
  author = {Eric Zhan and Jennifer J. Sun and Ann Kennedy and Yisong Yue and Swarat Chaudhuri},
  title = {{Unsupervised Learning of Neurosymbolic Encoders}},
  journal = {Accepted by TMLR},
  year = {2022},
  url = {https://openreview.net/forum?id=eWvBEMTlRq},
}
Figure