Composing Modeling and Inference Operations with Probabilistic Program Combinators

Eli Sennesh, Adam Scibior, Hao Wu, Jan-Willem van de MeentarXiv 2018

Introduction

Probabilistic Programming Languages (PPLs) have revolutionized how we build and reason about complex statistical models. By allowing developers to define models using general-purpose programming constructs, PPLs support "dynamic computation graphs"—structures where the number of random variables can change based on data, such as in recursive processes or open-universe models. However, this flexibility often comes at the cost of inference efficiency. General-purpose inference engines frequently treat these models as "black boxes," failing to exploit structural properties like conditional independence or exchangeability.

This paper introduces a library of "combinators" for the Probabilistic Torch framework. These combinators allow researchers to build complex models and inference strategies by composing simpler, reusable functional blocks. This approach seeks a "middle ground" by providing a way to statically compose models and inference steps while allowing the underlying evaluation to remain dynamic.

The Combinator Framework

The core contribution is the formalization of Probabilistic Program Combinators. Drawing from functional programming, these are higher-order functions that transform or combine stochastic processes.

Model Combinators

Model combinators utilize classic patterns to build complex structures from sub-models:

  • compose: Chains two models together.
  • map: Applies a model across a sequence, useful for time-series data.
  • partial: Fixes certain arguments of a model.

Inference Combinators

Inference combinators transform how a model is evaluated, treating inference as a first-class, modular citizen. Key operations include importance (sampling from a proposal), resample (standardizing weights), and move (applying MCMC-style kernels).

Formal semantics for inference combinators, ensuring proper weighting.

A critical requirement for these combinators is Proper Weighting. The authors ensure that every inference transformation preserves the property that the resulting weight is an unbiased estimator of the model's marginal likelihood. This mathematical "glue" allows composed models to be trained using modern variational methods like the Evidence Lower Bound (ELBO) or wake-sleep algorithms.

Experimental Evaluation: The Bouncing Particle

To demonstrate the power of this modular approach, the authors evaluated it on a simulated "bouncing particle" scenario. A particle moves within a 2D box with piece-wise constant noisy velocity. The dataset consists of 30 time series, each with 200 time points. The goal is to infer the particle's travel directions and the transition probabilities between those directions, modeled as a Hidden Markov Model (HMM).

Using the combinator library, a full HMM with custom Sequential Monte Carlo (SMC) inference was implemented in just 64 lines of model-specific code. This modularity allows for easy experimentation with different inference strategies.

Results from the bouncing particle experiment comparing the combinator-based HMM with VBEM.

Key Results

The combinator-based "wake-sleep SMC" successfully recovered ground-truth parameters. A significant finding was the comparison with Variational Bayesian Expectation Maximization (VBEM). While VBEM optimizes the "exclusive" KL divergence and often results in under-dispersed (overly certain) posteriors, the combinator approach optimizes the "inclusive" KL divergence, providing a much better approximation of the posterior distribution's true variance and recovering transition probabilities more accurately.

Discussion and Future Work

The combinator framework allows developers to reason about a "coarsened" computation graph. Instead of managing thousands of individual random variables, one can manipulate a few nodes representing entire sub-models (like transition or observation models).

While powerful, the current framework makes few assumptions about model structure to maintain generality. Future work could improve performance by explicitly exploiting graphical structures through belief propagation or automated enumeration. Additionally, the authors suggest using Just-In-Time (JIT) compilation to speed up the execution of these statically composed but dynamically evaluated graphs. The ultimate goal is to apply these tools to complex "intuitive physics" problems in computer vision and perception.

Summary updated

BibTeX
@misc{sennesh2018composing,
  author = {Eli Sennesh and Adam Scibior and Hao Wu and Jan-Willem van de Meent},
  title = {{Composing Modeling and Inference Operations with Probabilistic Program Combinators}},
  year = {2018},
  eprint = {1811.05965},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.05965},
}
Figure