Post-Inference Prior Swapping

Willie Neiswanger, Eric P. Xing

Post-Inference Prior Swapping is a framework that allows researchers to perform Bayesian inference using a computationally "convenient" (but incorrect) prior, and then efficiently transform that result into the posterior for any "target" prior. By decoupling the data-intensive part of inference from the prior-specific part, this method enables the use of complex, non-conjugate priors—such as sparsity or diversity-promoting priors—at a fraction of the usual computational cost.

The Trade-off: Realistic Priors vs. Fast Algorithms

In Bayesian modeling, researchers often face a strict trade-off between the realism of their prior beliefs and the speed of their inference algorithms. "Convenient" priors (like Gaussian or conjugate priors) lead to fast, sometimes closed-form solutions. However, real-world constraints often require "difficult" priors, such as Laplace priors for sparsity or heavy-tailed distributions. These complex priors force the use of expensive, iterative algorithms like Markov Chain Monte Carlo (MCMC).

Because MCMC algorithms typically scale with the size of the dataset ($O(n)$ per iteration), they become prohibitively slow for large-scale data. A common workaround is Importance Sampling (IS): infer using a simple prior and reweight the samples later. Unfortunately, IS often fails spectacularly—suffering from infinite variance—if the target prior is significantly different from the "false" prior used during inference. This paper seeks a way to "swap" priors post-inference that is both accurate and computationally independent of the data size.

Methodology: The Swap Density

The authors propose Prior Swapping, which treats the pre-inferred "false" posterior as a surrogate for the likelihood.

Instead of sampling from the true target posterior $p(\theta|x^n) \propto \pi(\theta)L(\theta|x^n)$, they define a "swap density": $$p_s(\theta) \propto \frac{\tilde{p}_f(\theta)\pi(\theta)}{\pi_f(\theta)}$$

Here, $\tilde{p}_f(\theta)$ is an approximation of the posterior calculated using the "false" prior $\pi_f$. Because the likelihood information is already captured in $\tilde{p}_f(\theta)$, running MCMC on the swap density has a cost of $O(1)$ per iteration relative to the data size $n$. You only need to process the full dataset once to get the initial false posterior.

Prior Swapping successfully draws samples from the target posterior region, achieving low error in fractions of a second compared to Importance Sampling.

The authors introduce three implementation flavors depending on the available information:

  1. Prior Swap Exact: Used when the false posterior has a known closed-form (e.g., conjugate models).
  2. Prior Swap Parametric: When only samples from the false posterior are available, Score Matching is used to fit a parametric density to those samples.
  3. Prior Swap Semiparametric: A robust version that uses a nonparametric kernel correction to account for inaccuracies in the parametric fit, providing asymptotic guarantees of correctness.

Key Insights

  • Likelihood as a Bottleneck: The core insight is realizing that the likelihood function is the only part of the posterior that depends on the data. If you can "bake" the likelihood into a density function once, you can swap priors as many times as you want without ever touching the raw data again.
  • Moving vs. Reweighting: Importance Sampling fails because it tries to represent a complex distribution using a fixed set of weights on old samples. Prior Swapping actually moves samples to the correct regions of the parameter space by running a new (but computationally cheap) Markov chain.
  • The "False" Prior as a Tool: Usually, a "false" prior is a modeling mistake. Here, it is a strategic choice—a computational "stepping stone" that makes the initial heavy lifting easier.

Experimental Results

The authors evaluated their method on several real-world and synthetic benchmarks, including YearPredictionMSD (regression), MiniBooNE (logistic regression), and Simple English Wikipedia (topic modeling).

Performance of Prior Swapping in Bayesian linear regression, demonstrating rapid convergence (a, b) and accurate density alignment across dimensions (c, d).
  • Massive Speedups: In Bayesian linear regression, Prior Swapping converged to near-zero error in seconds, while standard MCMC on the target posterior took hours to reach the same accuracy.
  • Robustness: In a toy example where IS would require $10^{31}$ samples to reach a certain error threshold (due to tail mismatch), Prior Swapping achieved better results with just a few thousand samples.
  • Complex Priors Made Easy: The authors demonstrated the ability to apply "Diversity-Promoting" priors to Latent Dirichlet Allocation (LDA). This allowed them to automatically merge redundant topics into distinct, clean categories—a task that is traditionally very difficult to implement in standard collapsed Gibbs samplers.

Limitations and Future Work

While powerful, Prior Swapping has limitations. It assumes support match—meaning the "false" posterior must cover the same general region of the parameter space as the "target" posterior. If the false prior is so restrictive that the resulting posterior has zero mass where the target posterior should be, the swap will fail. Additionally, the parametric and semiparametric versions rely on accurately estimating the density of the false posterior, which remains challenging in extremely high dimensions due to the curse of dimensionality.

Future directions include extending this framework to "post-inference model swapping" or using it to incorporate streaming data by treating an old posterior as a "false" prior for new incoming data.

Summary updated

BibTeX
@inproceedings{neiswanger2017post,
  author = {Willie Neiswanger and Eric P. Xing},
  title = {{Post-Inference Prior Swapping}},
  booktitle = {International Conference on Machine Learning},
  year = {2017},
}
Figure