Principle:Pyro ppl Pyro Probabilistic Modeling
| Knowledge Sources | |
|---|---|
| Domains | Probabilistic_Programming, Bayesian_Inference |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
A foundational principle for defining probabilistic models as Python callables that specify joint distributions over observed and latent random variables.
Description
Probabilistic modeling in Pyro involves writing a standard Python function (the model) that uses special primitives to declare random variables and their relationships. Each random variable is declared via a sample statement, which names a site, specifies a probability distribution, and optionally conditions on observed data. The model function defines the joint distribution p(data, latents) by composing these sample statements.
This approach enables universal probabilistic programming: any computable stochastic function can serve as a model, including those with recursion, higher-order functions, and stochastic control flow. The Pyro runtime intercepts sample statements via an effect handler system, enabling different inference algorithms to manipulate the model's execution without changing its source code.
The key insight is the separation of model specification from inference. The same model function can be used with SVI, MCMC, importance sampling, or any other inference algorithm. The model declares what the generative process is; the inference algorithm determines how to compute the posterior.
Usage
Use this principle whenever you need to specify a generative process for Bayesian inference. This is the first step in any Pyro workflow: defining a model function that describes how data is generated from latent parameters and priors. It applies to regression models, deep generative models (VAEs), hidden Markov models, and any other probabilistic model.
Theoretical Basis
A probabilistic model defines a joint distribution:
where are latent variables with priors and are observed variables with likelihood .
Pseudo-code:
# Abstract probabilistic model pattern
def model(data):
# Declare priors on latent variables
z = sample("z", Prior(...))
# Define likelihood connecting latents to data
x = sample("x", Likelihood(z, ...), obs=data)
return x
The model is a stochastic function — each execution traces a path through the joint distribution. Inference algorithms use these traces to approximate the posterior .