Exact Bayesian Inference on Discrete Models via Probability Generating Functions: A Probabilistic Programming Approach

We present an exact Bayesian inference method for discrete statistical models, which can find exact solutions to a large class of discrete inference problems, even with infinite support and continuous priors. To express such models, we introduce a probabilistic programming language that supports discrete and continuous sampling, discrete observations, affine functions, (stochastic) branching, and conditioning on discrete events. Our key tool is probability generating functions: they provide a compact closed-form representation of distributions that are definable by programs, thus enabling the exact computation of posterior probabilities, expectation, variance, and higher moments. Our inference method is provably correct and fully automated in a tool called Genfer, which uses automatic differentiation (specifically, Taylor polynomials), but does not require computer algebra. Our experiments show that Genfer is often faster than the existing exact inference tools PSI, Dice, and Prodigy. On a range of real-world inference problems that none of these exact tools can solve, Genfer's performance is competitive with approximate Monte Carlo methods, while avoiding approximation errors.

Paper

References (32)

Scroll for more · 20 remaining

Similar papers

Peer review

Reviewer JaNH8/10 · confidence 4/52023-07-06

Summary

This paper proposes a new approach to exact inference in probabilistic programs. Existing approaches to exact inference attempt to compute marginal and normalized probabilities by efficiently computing the necessary (finite) sums, or using computer algebra to recognize and solve tractable integrals. By contrast, the present work constructs the moment-generating function ($G(x) = \mathbb{E}_{X \sim \mu}[x^X]$) for the distribution represented by the program, and takes its (higher-order) derivatives (using AD) to compute exact posterior marginal probabilities, as well as exact moments. This enables automated exact inference in a broader class of models than handled by existing techniques. The approach is implemented in Rust, and experiments in four example models show that their implementation typically computes exact answers in less time than it takes for Anglican’s generic Monte Carlo algorithms (e.g., sequential Monte Carlo with the prior as the proposal) to converge to accurate estimates.

Strengths

The key strengths I see in this paper are: - It introduces a significant new approach to PPL inference (automatic differentiation on compositionally constructed moment-generating functions), and I believe it’s important enough that most people working in PPLs will want to understand the new technique. The exposition is clear and should be accessible to a broad probabilistic programming audience. - The generating function approach resolves a key limitation of other exact inference methods: it can marginalize latent variables with infinite support. - Limitations of the language, and performance concerns, are clearly outlined (e.g., in the Restrictions paragraph on L147, and the Limitations paragraph on L83). - The appendix contains rigorous correctness proofs and further exposition of the generating function semantics. There is also a Rust implementation that helps clarify the actual implementation of the technique (e.g., the data representation of Taylor polynomials used by the AD algorithm).

Weaknesses

The key weaknesses I notice are: - The novel capabilities (and limitations) with respect to the line of work by Klinkenberg et al. could be more clearly described. It would also be good to cite and explain the differences with their recent LAFI abstract, “Exact Probabilistic Inference Using Generating Functions” (https://arxiv.org/pdf/2302.00513.pdf). That workshop abstract is non-archival and much less thorough than the present work, so I don’t mean this as a critique of your work’s novelty. But I think readers will appreciate a clear-eyed description of exactly how their proposed approach differs from yours. - It is unclear to what extent the limitations of the language are fundamental limitations of the generating function technique, vs. concessions made to get to a simple first publication/implementation of the idea. Could the technique be extended to programs with loops, or does that seem unlikely? What about compound distributions with more than one random parameter (e.g., Binomial where both $n$ and $p$ is also random)? What about ‘score statements’ that multiply a non-negative (affine?) expression into the likelihood? (It seems this should be possible for scores < 1, because we can `observe 1 ~ Bernoulli(X)`, but can it be made to work for more general scores?) - The experiments are all on programs for which existing exact inference methods fail. But it would be nice to understand how the new approach compares to existing methods on the programs that both approaches can handle. (Even if it is much less efficient, I believe the method still warrants publication, but it would be useful to readers to understand the expressiveness / efficiency trade-offs clearly.) - L310-312 incorrectly state that WebPPL does not support SMC or particle MCMC. See the SMC and PMCMC implementations here: https://github.com/probmods/webppl/tree/master/src/inference.

Questions

1. Are you 100% sure that systems like Hakaru and $\lambda$PSI cannot handle your examples? I don’t have a great handle on their capabilities, but I expect Maple’s computer algebra simplifications can handle at least some infinite sums and integrals. Have you tried implementing the example programs and seeing what these tools spit out? 2. What are the prospects for a generating-function semantics of a functional (rather than imperative) source language, such as Anglican (but suitably restricted)?

Rating

8: Strong Accept: Technically strong paper, with novel ideas, excellent impact on at least one area, or high-to-excellent impact on multiple areas, with excellent evaluation, resources, and reproducibility, and no unaddressed ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

3 good

Contribution

4 excellent

Limitations

The paper is up-front about both the expressiveness limitations of the probabilistic language they support, and the factors in which their algorithm scales exponentially.

Reviewer SkQ56/10 · confidence 2/52023-07-06

Summary

This paper proposes a new probabilistic programming language called statistical guarded command language (SGCL) and an exact Bayesian inference method for any discrete statistical model that can be expressed in SGCL. Empirical evaluatios on a variety of different discrete probabilistic models demonstrate the effectiveness of the method, especially for challenging distributions with discrete variables that have infinite support.

Strengths

- The paper is well organized and clearly written. - The proposed method seems novel, and is very useful especially for challenging discrete distributions involving variables with infinite support.

Weaknesses

- The paper seems to miss discussions on probabilistic circuits which is a large body of work concerning probabilistic models with tractable inference. - Given the limitations of the proposed PPL and its specialized use cases, it would also be helpful to add some discussions on how this can potentially be integrated into/work together with other more general PPLs to expand the applicability of the proposed method. - The current title and abstract seems slightly misleading, in the sense that the proposed PPL is not generally applicable to any discrete distributions. It would be better to rephrase to make the scope of its applicability clearer, and also emphasize its targeted use case is distributions with variables having infinite support.

Questions

See weaknesses.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

2: You are willing to defend your assessment, but it is quite likely that you did not understand the central parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

The authors adequately addressed the limitations.

Reviewer hi498/10 · confidence 4/52023-07-07

Summary

The paper presents a restricted, first-order probabilistic programming language in which inference for infinite-support latent variables, with continuous or discrete sample spaces, admits a closed form. For experiments they compare against importance sampling, Lightweight M-H, Random Walk M-H (RMH), sequential Monte Carlo, particle Gibbs sampling, and interacting particle MCMC (IPMCMC) in the Anglican universal PPL. The authors achieve much lower error than Monte Carlo sampling across experiments, typically with significantly less compute.

Strengths

The paper demonstrates that when latent variables are subject only to affine transformations, a first-order (lacking general recursion) probabilistic programming language can admit tractable exact inference for certain important classes of discrete observations. Even when the resulting exact inference engine takes compute time comparable to the Anglican Monte Carlo inference routines, it tends to run in the middle of the pack while providing much lower approximation error.

Weaknesses

Since the paper focuses on proving and benchmarking something that has an exact answer, it has few weaknesses as such. It could perhaps have done a better job of making explicit the if-and-only-if conditions that must be met for generating functions to support closed-form inference. The authors have addressed this concern in the rebuttal.

Questions

How could the exact inference algorithm in this paper be used in a larger probabilistic programming framework, such as when probabilistic circuits admitting exact density calculations are applied as proposals in a broader family of inference algorithms? When the paper mentions outputting posterior probability masses for certain intervals of integer-valued latent variables, why not also include densities for continuous latent variables? The authors have addressed these questions in their response.

Rating

8: Strong Accept: Technically strong paper, with novel ideas, excellent impact on at least one area, or high-to-excellent impact on multiple areas, with excellent evaluation, resources, and reproducibility, and no unaddressed ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

3 good

Contribution

4 excellent

Limitations

The authors have admitted the limitations of their work, and in exchange for those limitations in expressivity they gain performance in both error and compute time.

Reviewer c91c8/10 · confidence 5/52023-07-07

Summary

A probabilistic programming framework for exact inference in discrete probabilistic programs with infinite support is introduced. The framework levegares probability generating functions as a first class attribute of discrete distributions. The probabilistic programming language is formally defined, inference is theoretically analysed for correctness. The performance and accuracy are empirically evaluated and compared with baselines on real-world examples.

Strengths

The paper brings the idea of using GF as a first-class property of a distribution into a practical implementation as a probabilistic programming language. Formal properties of the language and inference are rigorously analysed. The empirical evaluation demonstrates capabilities of the approach, and favorably compares to alternatives. The submission is accompanied by a working and well organized code based.

Weaknesses

The PPL is implemented in Rust, a language which, while it certainly has its merits, less popular for statistical modelling and Bayesian inference, which may make adoption of the approach more difficult. This is a matter of taste though.

Questions

You apparently unroll loops in your benchmarks (I assume because the language does not support loops). What prevents you from implementing restricted loops in the language? The syntax in the examples is richer than the BNF in the paper. What is '+~' for example? Can you define the full syntax in the paper, at least briefly? Why rust? Have you considered other options?

Rating

8: Strong Accept: Technically strong paper, with novel ideas, excellent impact on at least one area, or high-to-excellent impact on multiple areas, with excellent evaluation, resources, and reproducibility, and no unaddressed ethical considerations.

Confidence

5: You are absolutely certain about your assessment. You are very familiar with the related work and checked the math/other details carefully.

Soundness

4 excellent

Presentation

4 excellent

Contribution

3 good

Limitations

The paper adequately discusses limitations of the proposed solution.

Reviewer c91c2023-08-12

I have read the authors' response and stand by my score. Will be glad to see the paper accepted.

Reviewer SkQ52023-08-19

Thanks for the response

I thank the authors for the response which addressed my concerns. Please add the relevant discussions and clarifications as mentioned in the rebuttal.

Reviewer hi492023-08-19

Read the rebuttals

To the authors, Thank you for your clear and enlightening rebuttal and for addressing my comments.

Reviewer JaNH2023-08-21

Thank you for this very thorough response. The comparison to PSI and Prodigy makes the value of your novel contributions (in particular the AD-based implementation) even clearer, and accordingly I am raising my score to an 8. I hope that in revision you will find the space to include some of the points from your responses in the paper or appendix. In particular, if you have the space, I'd like to see the ideas from your first two bolded paragraphs in the general response included, as well as the point about why GF semantics for functional languages might be more difficult.

Program Chairsdecision2023-09-21

Decision

Accept (oral)

© 2026 NYSGPT2525 LLC