Probabilistic programming

Andrew D. Gordon, Thomas A. Henzinger, Aditya V. Nori, Sriram K. Rajamani

Abstract

Probabilistic programming democratizes machine learning by allowing developers to write statistical models using familiar programming constructs like loops and variables. By treating inference as a compiler and runtime problem, this research demonstrates how complex Bayesian mathematics can be abstracted into a "black box" that automatically learns from data.

Introduction

Traditional machine learning and statistical modeling often require deep expertise in probability theory and specialized inference algorithms, creating a significant barrier for domain experts in fields like biology or security who lack advanced statistical training. This paper addresses the "impedance mismatch" between software engineering and statistical modeling. The authors propose that instead of manually deriving mathematical solutions for every new model, developers should express models as programs capable of drawing random values from distributions and conditioning those values based on real-world observations.

Methodology: The PROB Language

The core contribution is PROB, a C-like imperative language extended with two fundamental constructs:

  1. Probabilistic Assignment (x ~ Dist): Drawing a sample from a distribution.
  2. The observe Statement: A construct that filters execution paths to satisfy specific conditions, effectively aligning the program's behavior with observed data.

The formal syntax of the language is defined across expressions, statements, and full programs, as shown in the grammar below:

Formal syntax and grammar of the PROB language, defining expressions, statements, and program structure.

By using familiar constructs like loops and boolean logic, programmers can define complex stochastic processes without needing to derive the underlying joint probability distributions manually. This allows for the creation of models that are both expressive and readable to non-statisticians.

Examples of probabilistic programs using Bernoulli distributions and loops to define stochastic logic.

Technical Innovations

  • Formal Semantics: The authors define the "meaning" of a program as the expected value of its return expression, providing a rigorous denotational foundation.
  • Program Slicing: Standard static analysis is adapted to handle "observe dependence." Unlike traditional code where statements only affect the future, an observe statement can influence variables assigned earlier in the execution path.
  • The R2 Inference Algorithm: This algorithm uses backward program transformation (PRE analysis) to move observations closer to the random draws they constrain. This optimization significantly reduces the computational waste typical of sampling-based inference (e.g., Markov Chain Monte Carlo) by avoiding paths destined for rejection.

Key Insights and Results

The research highlights that machine learning can be treated as a programming language problem. With a sufficiently advanced compiler, the programmer describes the model, and the system manages the mathematics.

Key findings include:

  • Inference Efficiency: The R2 algorithm produces significantly more valid samples within a given time budget compared to naive rejection sampling.
  • Unification of Models: The paper demonstrates that established models like Bayesian Networks and Discrete Time Markov Chains (DTMCs) are restricted subsets of probabilistic programs.
  • Semantic Rigor: Mapping probability to denotational semantics provides a solid foundation for future tool development, such as "Tabular," which allows probabilistic programming within spreadsheet environments.

Limitations and Future Work

Despite its strengths, several challenges remain:

  • Nondeterminism: Current languages struggle with true nondeterminism, which is crucial for modeling adversarial behavior.
  • Continuous Time: Native support for systems changing continuously over time (e.g., chemical kinetics) is still lacking.
  • Structure Learning: While the system excels at learning parameters, learning the program's structure from data remains difficult, with "program sketching" suggested as a potential path forward.
  • Scalability: Exact inference is #P-complete, making scaling to massive industry-sized programs a persistent engineering hurdle.

Summary updated

BibTeX
@inproceedings{gordon2014probabilistic,
  author = {Andrew D. Gordon and Thomas A. Henzinger and Aditya V. Nori and Sriram K. Rajamani},
  title = {{Probabilistic programming}},
  booktitle = {FOSE},
  year = {2014},
  doi = {10.1145/2593882.2593900},
}
Figure