[Paper Review] Composing inference algorithms as program transformations
This paper introduces a modular framework for composing probabilistic inference algorithms as program transformations, enabling automatic generation of exact and approximate inference procedures from probabilistic models. By treating inference as transformations that convert one probabilistic program into another (e.g., from a model to a sampler or density calculator), the approach supports composition of multiple inference methods—such as combining exact inference with MCMC or variational inference—while achieving performance comparable to state-of-the-art systems like WebPPL and JAGS.
Probabilistic inference procedures are usually coded painstakingly from scratch, for each target model and each inference algorithm. We reduce this effort by generating inference procedures from models automatically. We make this code generation modular by decomposing inference algorithms into reusable program-to-program transformations. These transformations perform exact inference as well as generate probabilistic programs that compute expectations, densities, and MCMC samples. The resulting inference procedures are about as accurate and fast as other probabilistic programming systems on real-world problems.
Motivation & Objective
- To reduce the manual, error-prone effort of implementing inference algorithms from scratch for each model and algorithm combination.
- To enable the composition of multiple inference methods—such as exact and approximate inference—over the same model without rewriting code.
- To support modular, composable inference by expressing inference as transformations that convert probabilistic programs into other probabilistic programs.
- To allow reuse of existing inference implementations through transformation composition, enabling novel inference pipelines.
- To achieve performance comparable to existing probabilistic programming systems while maintaining modularity and formal compositionality.
Proposed method
- Represents probabilistic models as probabilistic programs, enabling inference to be expressed as transformations on these programs.
- Uses program-to-program transformations such as disintegration and expectation to generate new programs that implement specific inference tasks.
- Applies transformations in sequence to compose multiple inference methods, e.g., using exact inference on part of a model and MCMC on another.
- Supports transformations that compute densities, conditional distributions, and MCMC samplers, even in the presence of deterministic dependencies.
- Generates optimized code via simplification and loop unrolling, enabling efficient execution on large datasets.
- Leverages formal equivalences (e.g., conjugacy) to compose approximate and exact inference methods.
Experimental results
Research questions
- RQ1Can inference algorithms be systematically composed by transforming probabilistic programs rather than reimplementing them from scratch?
- RQ2How can exact and approximate inference methods be composed over the same model using a uniform program transformation interface?
- RQ3Can program transformations generate inference procedures that match the performance of hand-optimized systems like WebPPL and JAGS?
- RQ4To what extent can deterministic dependencies and complex model structures be handled during inference transformation?
- RQ5Can modular, composable inference pipelines be constructed using reusable transformation components?
Key findings
- The system generates inference procedures that are as accurate and fast as other probabilistic programming systems on real-world problems.
- For Kalman filtering tasks, the Hakaru sampler achieved higher Effective Sample Size (ESS) per sample than WebPPL, indicating better sampling efficiency.
- In Gaussian mixture modeling, Hakaru achieved over 50% accuracy after one sweep, outperforming JAGS chains which required several sweeps to catch up.
- For document classification on the 20 Newsgroups corpus, Hakaru’s collapsed Gibbs sampler achieved higher accuracy than JAGS after one sweep and remained superior across data sizes.
- Hakaru’s initialization time was constant regardless of data size, while JAGS’s initialization time grew with data size, making Hakaru more scalable for large datasets.
- Despite being about an order of magnitude slower than JAGS in raw sampling speed, Hakaru’s performance was practical and competitive, especially considering its ability to reuse computation and generate optimized code.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.