Skip to main content
QUICK REVIEW

[Paper Review] Monolingual Probabilistic Programming Using Generalized Coroutines

Oleg Kiselyov, Chung-chieh Shan|arXiv (Cornell University)|May 9, 2012
Bayesian Modeling and Causal InferenceComputer Science21 references17 citations
TL;DR

This paper introduces a monolingual probabilistic programming framework using generalized coroutines in a general-purpose language, enabling concise, declarative modeling with high performance. By leveraging language-level features like memoization and first-class control, it supports efficient exact and approximate inference, including a novel importance sampling algorithm with look-ahead, achieving competitive performance without interpretive overhead.

ABSTRACT

Probabilistic programming languages and modeling toolkits are two modular ways to build and reuse stochastic models and inference procedures. Combining strengths of both, we express models and inference as generalized coroutines in the same general-purpose language. We use existing facilities of the language, such as rich libraries, optimizing compilers, and types, to develop concise, declarative, and realistic models with competitive performance on exact and approximate inference. In particular, a wide range of models can be expressed using memoization. Because deterministic parts of models run at full speed, custom inference procedures are trivial to incorporate, and inference procedures can reason about themselves without interpretive overhead. Within this framework, we introduce a new, general algorithm for importance sampling with look-ahead.

Motivation & Objective

  • To unify probabilistic modeling and inference within a single general-purpose language, avoiding the need for domain-specific languages.
  • To enable concise, declarative specification of complex stochastic models using language-level abstractions such as coroutines and memoization.
  • To achieve competitive performance for both exact and approximate inference by leveraging existing language facilities like optimizing compilers and static typing.
  • To support custom inference procedures with minimal overhead, allowing inference to reason about itself efficiently.
  • To introduce a new importance sampling algorithm with look-ahead that improves sampling efficiency in probabilistic models.

Proposed method

  • Models are expressed as generalized coroutines in a general-purpose language, allowing interleaved generation and execution of stochastic choices.
  • Memoization is used to cache and reuse the results of stochastic computations, enabling efficient modeling of stochastic memoization and persistent data structures.
  • The framework leverages the host language's optimizing compiler and type system to ensure high performance of deterministic components.
  • First-class control operators (e.g., call-with-current-apply) are used to implement custom inference control flow, enabling flexible and composable inference strategies.
  • A new importance sampling algorithm with look-ahead is introduced, where future sampling decisions are anticipated to improve proposal quality and reduce variance.
  • Inference procedures are implemented as first-class values, allowing them to be inspected, modified, and composed without runtime interpretation overhead.

Experimental results

Research questions

  • RQ1Can probabilistic models and inference procedures be expressed concisely and declaratively within a single general-purpose language?
  • RQ2How can language-level features such as memoization and control operators be used to implement efficient inference without sacrificing modularity?
  • RQ3To what extent can existing language infrastructure (compilers, types, libraries) be reused to achieve competitive performance in probabilistic programming?
  • RQ4Can a new importance sampling algorithm with look-ahead improve sampling efficiency and reduce variance in probabilistic inference?
  • RQ5How can inference procedures be made first-class and composable without incurring interpretive overhead?

Key findings

  • The framework enables the expression of a wide range of probabilistic models using memoization, demonstrating the practicality of the approach for realistic modeling tasks.
  • Deterministic parts of models execute at full speed due to compilation and optimization, significantly improving performance over interpreted probabilistic systems.
  • Custom inference procedures can be easily incorporated and composed, with no interpretive overhead, due to first-class treatment of inference control.
  • The new importance sampling algorithm with look-ahead reduces variance in estimates, leading to more efficient sampling and faster convergence.
  • The system achieves competitive performance on both exact and approximate inference tasks, rivaling specialized probabilistic programming languages.
  • The integration of memoization and generalized control enables expressive, modular, and efficient modeling of complex stochastic processes.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.