An Introduction to Probabilistic Programming

Jan-Willem van de Meent, Brooks Paige, Hongseok Yang, Frank Wood

Abstract

Probabilistic Programming Languages (PPLs) represent a foundational bridge between the domains of programming languages and Bayesian statistics. By formalizing the design of PPLs, researchers can transform traditional "forward" simulators into "inverse" reasoning engines. This paper explores the taxonomy of PPLs—ranging from First-Order to Higher-Order systems—and details how they automate complex Bayesian inference, effectively serving as the "automatic differentiation" for probabilistic modeling.

Introduction

In traditional machine learning, the primary objective is often to map inputs to outputs. However, in many scientific and engineering disciplines, the "forward model"—a simulator describing how a system behaves—is already known. For instance, we may have a simulator for how a tree grows or how a Captcha is rendered. The critical challenge lies in "inverse reasoning": given an observed output (e.g., a photo of a tree), how do we determine the hidden parameters that generated it?

Historically, solving these inverse problems required hand-coding bespoke inference algorithms for every new model. Probabilistic Programming addresses this by providing a unified toolchain. Much like automatic differentiation revolutionized deep learning by automating gradient calculations, PPLs allow researchers to define a model as a program and delegate the heavy lifting of Bayesian inference to the underlying system.

Taxonomy of Probabilistic Programming Languages

The architecture of a PPL is largely determined by its expressive power, categorized into two main types:

First-Order Probabilistic Programming (FOPPL)

FOPPLs are restricted to a finite number of random variables and do not support recursion. This constraint allows the program to be compiled into a static graphical model, such as a Bayesian Network. Consequently, traditional algorithms like Gibbs sampling or Expectation Propagation can be applied directly to the resulting graph.

Higher-Order Probabilistic Programming (HOPPL)

HOPPLs are "universal" languages that support recursion and dynamic computation graphs, where the number of variables can change during execution. To manage this complexity, these languages utilize a messaging interface and Continuation-Passing Style (CPS) transformations. In this framework, a probabilistic program is treated as a deterministic computation that "pauses" and cedes control to an inference controller whenever a random choice is encountered. This allows the system to act as a "non-standard scheduler," deciding which execution branches to explore based on observed data.

Deep Probabilistic Programming and Amortized Inference

A significant advancement in the field is the integration of PPLs with deep learning. In Deep Probabilistic Programming, neural networks are used as "guides" to perform amortized inference. Rather than performing a full inference procedure for every new observation, the system trains a neural network to predict the posterior distribution. This approach combines the interpretability of structured probabilistic models with the execution speed of deep learning, making inference nearly instantaneous at test time.

Applications and Demonstrations

While PPLs provide a formal semantic framework, their utility is best demonstrated through diverse applications:

  • Captcha Breaking: Inverting a generative model of text rendering to read distorted images.
  • Constrained Procedural Graphics: Generating realistic 3D models (e.g., trees) that are mathematically constrained to avoid obstacles.
  • Bayesian Neural Networks: Treating the weights of a neural network as latent variables to be inferred, providing a principled approach to uncertainty.
  • The "Pumps" Model: A classic benchmark for Bayesian reliability analysis.

Insights and Technical Challenges

One of the most profound insights in PPL research is the "Math Bug" in deep PPLs. When training these systems, naively differentiating self-normalized importance weights leads to biased gradients. Correcting this requires "unboxing" (blocking gradients) on specific terms within the objective function.

Furthermore, there is an inherent tension between language flexibility and inference efficiency. While HOPPLs offer immense flexibility, they often struggle with high-dimensional continuous spaces where static FOPPLs (like Stan) excel.

Conclusion and Future Work

Despite the automation provided by PPLs, the "Hardness of Inference" remains. PPLs automate the process of inference, but they do not eliminate the underlying NP-hard complexity of the mathematics. Future research is directed toward creating truly "universal" inference algorithms that can perform efficiently across discrete, continuous, and dynamic models without requiring manual tuning. Additionally, bridging the gap for existing simulators—many of which were not designed for the "forking" or "interruption" required by PPL controllers—remains a significant engineering challenge.

Summary updated

BibTeX
@misc{meent2018introduction,
  author = {Jan-Willem van de Meent and Brooks Paige and Hongseok Yang and Frank Wood},
  title = {{An Introduction to Probabilistic Programming}},
  year = {2018},
  eprint = {1809.10756},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1809.10756},
}
Figure