Source-linked AI summary
On Contrastive Learning for Likelihood-free Inference
Conor Durkan, Iain Murray, George Papamakarios
TL;DR
Likelihood-free inference is needed when simulator likelihoods are intractable, motivating methods that learn density ratios or posterior distributions from simulations. The paper shows that classifier-based SRE and posterior-based SNPE-C fit a common contrastive learning framework, then compares them to clarify when each is preferable. It concludes that conditional density estimators can be preferred under matched training objectives, while support mismatch creates a specific SNPE-C limitation.
Problem
Likelihood-free inference must support parameter inference when simulator likelihoods are intractable, while existing classifier-based and posterior-estimation approaches were treated as distinct.
Method
The paper formulates SRE and SNPE-C within a general contrastive learning scheme and directly compares their properties and behavior.
Results
SRE and SNPE-C are both instances of the general contrastive scheme, and control experiments find similar representations when both use the same codebase and classification objective.
Takeaways & Limitations
When trained under the same objective, a conditional density estimator should be preferred because it provides a normalized posterior and removes the need for MCMC.
Takeaways & Limitations
SNPE-C can suffer from posterior density leaking outside the prior support when the estimator and prior supports do not match.
Abstract
from arXiv · showhide
Likelihood-free methods perform parameter inference in stochastic simulator models where evaluating the likelihood is intractable but sampling synthetic data is possible. One class of methods for this likelihood-free problem uses a classifier to distinguish between pairs of parameter-observation samples generated using the simulator and pairs sampled from some reference distribution, which implicitly learns a density ratio proportional to the likelihood. Another popular class of methods fits a conditional distribution to the parameter posterior directly, and a particular recent variant allows for the use of flexible neural density estimators for this task. In this work, we show that both of these approaches can be unified under a general contrastive learning scheme, and clarify how they should be run and compared.
1. Introduction
Likelihood-free inference addresses parameter inference in stochastic simulators where likelihood evaluation is intractable but simulation is possible. This paper unifies classifier-based ratio estimation and conditional posterior estimation as contrastive learning methods and compares their behavior.
- Likelihood-free methods often rely on very large numbers of simulator-generated samples.
- Neural-network methods can reduce the simulations needed for effective inference by orders of magnitude.
- The paper studies classification-based density-ratio estimation and conditional density estimation for neural likelihood-free inference.
- Both approaches are shown to instantiate a general contrastive learning scheme rather than unrelated methods.
- The unified perspective supports direct comparison of the algorithms' properties and behavior and motivates practical recommendations.
2. Background
Likelihood-free inference replaces direct likelihood evaluation with simulator-based methods, including density-ratio classification and conditional posterior estimation. The section develops these approaches and describes their sequential variants, along with limitations involving estimator flexibility and proposal weighting.
- A stochastic simulator maps parameters and latent random numbers to observations, but its likelihood is generally intractable.
- Binary classification recovers the ratio between positive and negative sample densities, with the optimal classifier score equal to log r(x).
- In likelihood-free inference, joint parameter-observation samples are positive examples, while independently sampled marginals form negative examples.
- Sequential ratio estimation focuses simulations on parameters plausible for a target observation, trading exact posterior evaluation for a more targeted ratio estimate and retaining MCMC sampling.
- Conditional density estimation learns qφ(θ | x) toward the posterior, while sequential neural posterior estimation narrows training toward parameters relevant to the observation.
- SNPE-A restricts flexible density estimators when tractable posterior correction is required, whereas SNPE-B permits arbitrary estimators but can suffer from high-variance importance weights.
- SNPE-C reparameterizes the proposal-posterior objective so maximum likelihood can recover the true posterior directly.
3. Method
The paper unifies SRE and SNPE-C as instances of a general contrastive learning scheme, connecting binary and multi-class classification with posterior density estimation. This framework supports sequential inference and clarifies choices such as contrasting-set size and classifier parameterization.
- Unifying SRE and SNPE-C: SRE and SNPE-C are both instances of a general contrastive learning scheme.The framework differs between them mainly through the number of classes and classifier parameterization.
- Contrastive framework: The contrastive framework uses one parameter-observation pair generated jointly with an observation and contrasting parameters drawn from another distribution.The general algorithm iteratively refines a posterior approximation across sequential rounds.
- Density-ratio interpretation: The learned classifier recovers the desired log-density ratio up to proportionality, including when parameters are sampled from a proposal rather than the prior.This establishes the connection between contrastive classification and likelihood-free posterior inference.
- SRE: Setting K = 2 with a feed-forward classifier recovers SRE, while multiple classes generalize SRE beyond its binary formulation.The paper states that the multi-class generalization generally improves SRE performance.
- SNPE-C: Parameterizing the classifier as log qφ(θ | x) recovers SNPE-C and can provide normalized posterior approximations with efficient evaluation and sampling.This construction is valid when the density and prior share support, with efficiency depending on the chosen density estimator.
- Mutual-information connection: Using a minibatch as the contrasting set makes the scheme equivalent to setting K = B and connects its loss to a multi-sample mutual-information lower bound.The bound is limited above by log K, motivating larger contrasting sets and sequentially targeted proposals.
4. Related Work
The related work situates the paper among ABC, likelihood-learning, density-ratio estimation, and contrastive-learning approaches to likelihood-free inference. These methods differ in whether they rely on summary-statistic rejection, likelihood approximation, or relative density comparison.
- Approximate Bayesian Computation (ABC): ABC methods use summary statistics, a distance metric, and a tolerance to reject simulator-generated samples that are insufficiently close to observations.They can require many simulations, which is problematic when simulators are expensive.
- Approximate Bayesian Computation (ABC): Conditional neural density estimators can outperform traditional approaches such as Sequential Monte Carlo ABC according to comparisons in the existing literature.The cited discussion frames neural density estimators as an alternative to simulation-intensive ABC methods.
- Learning the likelihood: Likelihood-learning methods approximate p(x|θ), either separately for each parameter or amortized across parameters, and can draw parameters from arbitrary proposals.This contrasts with fitting the posterior conditional distribution directly.
- Contrastive learning: Contrastive learning estimates relative probabilities by comparing examples, with Noise Contrastive Estimation as a prominent example for unnormalized distributions.The paper places classifier-based density-ratio estimation within this broader learning-by-comparison paradigm.
- Density-ratio estimation: Density-ratio methods target quantities such as p(x|θ)/p(x), which are central to Bayesian inference and can be estimated for likelihood-free inference.SRE is identified as one example of this approach.
- Empirical comparison: Figure 1 compares SRE and SNPE-C across tasks and metrics using means and standard deviations over 10 random seeds.The metrics include negative log probability of true parameters and median L2 distance between generated and true observations.
5. Experiments
Experiments compare SRE, SNPE-C, and SNL, examining contrasting-set size, sampling behavior, and performance. SNPE-C closely matches SRE on inference quality but can leak density outside the prior support, while SNL generally outperforms SRE, especially on M/G/1.
- Comparison of SRE and SNPE-C: SNPE-C can leak density outside the prior support because its classification objective constrains density ratios only within that support.The issue arises when posterior and prior supports differ; maximum-likelihood training in the first round mitigates it initially.
- Contrasting-set size: Increasing the contrasting-set size generally improves inference efficiency across tasks and metrics, although gains are sometimes marginal.The experiments evaluate K ∈ {2, 50, 100}.
- Comparison of SRE and SNPE-C: SNPE-C closely matches SRE in inference quality, and i.i.d. sampling performs essentially the same as MCMC sampling in the reported control.SNPE-C additionally provides density evaluation and i.i.d. posterior sampling after training.
- Comparison of SRE and SNPE-C: Acceptance rates around 1% can make SNPE-C i.i.d. sampling up to 100 times slower, although it may remain faster than MCMC.Figure 2 reports acceptance-rate distributions across rounds and random seeds, with leakage occurring in two of three tasks and high variance in the third.
- Comparison of SRE and SNL: SNL generally outperforms SRE, particularly on the M/G/1 task, while SNL also supports goodness-of-fit testing through its surrogate likelihood.Both methods rely on MCMC sampling to generate posterior samples in each round.
- Comparison of SRE and SNL: SRE has an advantage for high-dimensional observations because it feeds observations directly to a classifier instead of parameterizing their distribution.SNL makes posterior-likelihood evaluation and sampling available, but requires a surrogate likelihood model.
6. Discussion
The discussion unifies previously distinct likelihood-free approaches while identifying practical trade-offs and unresolved limitations. Control experiments find similar representations under a shared classification objective, but SNPE-C can face support-mismatch problems.
- Current methods still require too many simulations for very slow simulators, struggle with multiple observations, and handle failed simulations poorly.
- The paper connects SRE and SNPE-C as previously distinct approaches and generalizes SRE to multi-class classification.
- Control experiments using the same codebase and classification objective produce similar representations for SRE and SNPE-C.
- When performance is similar, SNPE-C is preferred because it provides a normalized posterior and removes the need for MCMC.
- SNPE-C may require MCMC for compact-support priors when rejection rates become extremely high.
A.1. SRE vs SNPE-C
Figures 4 and 5 compare posterior samples and metrics for SRE and SNPE-C across tasks, highlighting transient overconfidence before multimodal posterior recovery.
- Figure 4 compares SRE and SNPE-C posterior samples on each task using K = 100 contrasting examples.
- Figure 5 compares SRE and SNPE-C metrics on the Nonlinear Gaussian task.
- Before recovering the multimodal posterior, either method can become too confident in particular parameter settings, producing the observed negative log likelihood behavior.
A.2. SRE vs SNL
Figures 6–8 compare SRE with SNL and examine SNPE-C when MCMC replaces independent sampling in each round.
- Figure 6 compares SNL and SRE posterior samples on each task.
- Figure 7 compares SRE and SNL metrics for the Nonlinear Gaussian task.
- Figure 8 reports metrics for SNPE-C on Nonlinear Gaussian, Lotka–Volterra, and M/G/1 when MCMC replaces i.i.d. sampling in each round.
B. Correctness of SNPE-C for arbitrary proposals ˜p(θ)
The correctness argument concludes that, under the stated classifier optimality assumption, the conditional density estimator recovers the true posterior for any proposal distribution.
- The correctness derivation assumes an optimal classifier.
- Exponentiating and integrating the classifier relation with respect to θ advances the derivation toward posterior recovery.
- The derivation then characterizes the resulting expression for the optimal classifier.
- The parameterized conditional density estimator recovers the true posterior for any proposal ˜p(θ).