Introduction
Probabilistic Programming Languages (PPLs), such as Pyro and Stan, offer a robust framework for modeling uncertainty. However, performing inference—calculating the posterior probability of latent variables given observations—remains a significant computational bottleneck. Traditional methods like Markov Chain Monte Carlo (MCMC) are accurate but slow, while Variational Inference (VI) often struggles with complex, high-dimensional distributions.
Existing amortised inference methods attempt to accelerate this process by training neural networks to predict latent variables. However, these models are typically rigid, trained for a specific set of observations and latent variables. The Universal Marginaliser (UM) addresses this limitation by providing a single, flexible inference engine capable of approximating any conditional marginal distribution within a probabilistic program without the need for retraining.
Methodology
The Universal Marginaliser is a feed-forward neural network designed as a universal function approximator for a PPL's marginal distributions. Unlike standard amortised models, the UM treats inference as a "completion" task, similar to masked language modeling in NLP.
Dynamic Probabilistic Masking
The core innovation of the UM is its training regime. During training, the model is presented with samples from the program's prior. For each batch, a random subset of variables is "masked" or replaced with their prior values. This dynamic masking forces the network to learn the dependencies between all variables, allowing it to predict any subset of variables given any other subset at test time.
UM-Flex and Decoupled Optimization
The authors introduce UM-Flex, an enhanced architecture that handles mixed data types (e.g., discrete and continuous) more effectively. Instead of a single global loss, UM-Flex assigns a specific loss function and a separate optimizer to each output node. This decoupled approach allows the model to adapt to the unique characteristics of each variable in the probabilistic program, significantly improving performance in complex models.
Experimental Setup
The UM was benchmarked using synthetic probabilistic programs implemented in Pyro. These programs were designed to represent common graph topologies of varying complexity and dimensionality (up to 32 nodes).
The benchmarks included:
- Grid Graphs: (Grid9, Grid16)
- Star Graphs: (Star4, Star8, Star32)
- Chain Graphs: (Chain4, Chain16, Chain32)
Training data was generated entirely from prior samples, enabling the model to learn the underlying logic of the program before encountering real-world data.
Key Results
Performance was evaluated by measuring the correlation between the UM's predictions and ground-truth posteriors obtained via high-fidelity Importance Sampling (1 million samples).
- High Accuracy: UM-Flex consistently achieved correlation scores between 0.85 and 0.95 across most architectures.
- Scalability: In the complex Star32 benchmark, UM-Flex maintained a correlation of 0.811, significantly outperforming the standard UM (0.667).
- Versatility: Once trained, the same model successfully answered diverse queries involving different sets of evidence without performance degradation or fine-tuning.
Limitations and Future Work
Currently, the UM is limited to probabilistic programs with a fixed, bounded number of random variables. It cannot yet accommodate programs with recursion or loops where the number of variables varies per execution. Future research will explore mapping unbounded random choices to fixed "slots" and integrating the UM more deeply into PPL frameworks to enable automatic, background training for amortised inference.
Summary updated