Using probabilistic programs as proposals

Marco F. Cusumano-Towner, Vikash K. MansinghkaarXiv 2018

Abstract

Monte Carlo inference methods, such as Importance Sampling and Metropolis-Hastings, are often limited by the quality of their proposal distributions. While domain-specific heuristics can offer high-quality guesses, they are difficult to integrate into rigorous Bayesian frameworks because their exact probability densities are often intractable. This paper introduces proposal programs, a framework for wrapping arbitrary randomized heuristics and neural networks into probabilistic programs that serve as proposals. By employing an approximate interface for probability estimation, these programs maintain asymptotic consistency while drastically improving the efficiency of posterior exploration.

The Challenge of Custom Proposals

In probabilistic inference, Monte Carlo methods rely on a "proposal distribution" to suggest regions of high probability. Generic proposals, like simple Gaussians, often lead to slow convergence in complex spaces, wasting time exploring low-probability regions.

Conversely, domain experts often have access to fast, randomized heuristics (e.g., RANSAC for geometric fitting) that provide excellent initial guesses. However, using such a heuristic as a proposal requires calculating its exact probability density—a task that becomes mathematically intractable when the heuristic involves complex internal logic or black-box code. This paper addresses the challenge of allowing users to write arbitrary probabilistic programs as proposals without breaking the rigorous mathematical guarantees of Monte Carlo inference.

Proposal Programs: Bridging Heuristics and Rigorous Bayes

The authors introduce proposal programs as a new abstraction. These are probabilistic programs that generate a sample through a sequence of internal random choices and deterministic computations.

The structure of a proposal program, where input $x$ and parameters $\theta$ guide internal choices and a heuristic algorithm to produce the output $z$.

A proposal program distinguishes between two types of variables: internal choices (intermediate computations) and output choices (the final proposed sample). Because marginalizing out internal choices to find the exact proposal probability is intractable, the authors introduce an approximate interface:

  • SIMULATE and ASSESS: Instead of exact computation, the system executes the proposal program $K$ times while holding the output choices fixed to generate an unbiased estimate of the proposal probability.
  • Algorithmic Integration: These estimates are plugged into standard Importance Sampling (IS) or Metropolis-Hastings (MH) algorithms. Using auxiliary variable constructions (akin to pseudo-marginal MCMC), the authors prove that using these estimates preserves the asymptotic consistency of the overall inference process.

Offline Optimization

To maximize performance, proposal programs can be optimized offline through inference compilation. The parameters of the program, such as neural network weights, are trained using stochastic gradient ascent to maximize a lower bound on the expected conditional log-likelihood. This effectively teaches the proposal program to mimic the true posterior distribution.

Experimental Evaluation: Bayesian Linear Regression

The method was evaluated on a Bayesian linear regression task involving significant outlier noise. The researchers compared three approaches:

  1. Prior Proposal: A generic baseline.
  2. Neural Network (NN) Proposal: A learned proposal without domain-specific logic.
  3. RANSAC+NN Proposal Program: A program that uses the RANSAC heuristic to guess the line and a neural network to estimate variability.

Key Results

  • Accuracy: With only 6 particles ($N=6$), the RANSAC+NN proposal program significantly outperformed both the pure NN and the generic prior, producing much more accurate posterior samples.
  • Training Efficiency: The RANSAC+NN hybrid achieved a lower expected KL divergence during training compared to the pure NN, suggesting that incorporating algorithmic heuristics makes the learning problem significantly easier.
  • Low Overhead: Implementation in Gen.jl demonstrated that these programs can execute at the speed of native code, avoiding the runtime overhead typically associated with probabilistic programming systems.

Conclusion and Future Directions

Proposal programs offer a powerful way to inject domain knowledge into Bayesian inference without sacrificing mathematical rigor. By treating heuristics as probabilistic programs, practitioners can leverage existing "dirty" algorithms to drive "clean" Bayesian inference.

Future work aims to extend the theoretical proofs to continuous internal random choices and explore more dynamic control flows, such as programs that switch between different heuristics based on the input data. Additionally, the authors suggest using symbolic integration to compute exact probabilities for parts of the program where possible, further reducing the variance of the estimates.

Summary updated

BibTeX
@misc{cusumanotowner2018using,
  author = {Marco F. Cusumano-Towner and Vikash K. Mansinghka},
  title = {{Using probabilistic programs as proposals}},
  year = {2018},
  eprint = {1801.03612},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1801.03612},
}
Figure