Prior Swapping for Data-Independent Inference

Willie Neiswanger, Eric P. XingarXiv 2016

In Bayesian machine learning, a fundamental trade-off exists between the accuracy of domain-specific priors and the computational feasibility of inference. While complex priors—such as sparsity-inducing or diversity-promoting distributions—often better reflect real-world constraints, they typically render inference computationally grueling. Consequently, researchers often settle for "convenient" false priors (e.g., Gaussians) that allow for fast, tractable inference, even at the cost of model fidelity.

This paper introduces Prior Swapping (PS), a framework that resolves this dilemma. Prior Swapping allows practitioners to perform initial inference with a convenient prior and subsequently "swap" it for a complex target prior without re-processing the original dataset. By treating the initial result as a surrogate for the likelihood, PS enables efficient, accurate inference under complex priors at a fraction of the cost of standard data-dependent methods.

The Challenge of Data-Dependent Inference

The core difficulty in Bayesian inference is that the posterior distribution depends on both the prior and the likelihood. Standard algorithms, such as Markov Chain Monte Carlo (MCMC) or Variational Inference (VI), are data-dependent: every iteration requires a pass over the entire dataset. Changing the prior usually necessitates re-running these expensive algorithms from scratch.

A common shortcut is Importance Sampling (IS), which reweights samples from a "false" posterior to approximate a "target" one. However, IS fails spectacularly when the false and target priors are dissimilar. As shown in Figure 1, even with $10^8$ samples, IS can maintain significant error if the distributions lack sufficient overlap.

Figure 1: Importance sampling fails to converge even with a massive number of samples when priors are poorly matched.

Prior Swapping: A Data-Independent Framework

The key insight of Prior Swapping is that the initial inference result (the "false posterior") already encapsulates the information from the data. The authors define a prior swap density $p_s(\theta)$:

$$p_s(\theta) \propto \frac{\tilde{p}_f(\theta)\pi(\theta)}{\pi_f(\theta)}$$

Where $\tilde{p}_f$ is the false posterior, $\pi$ is the target prior, and $\pi_f$ is the false prior. Crucially, this expression is independent of the raw data $x^n$. The paper outlines three implementation strategies:

  1. Prior Swap Exact: Direct MCMC on the swap density when the false posterior has a closed-form PDF.
  2. Prior Swap Parametric: Fitting a parametric density estimate to samples from the false posterior.
  3. Prior Swap Semiparametric: Using a parametric start with a non-parametric kernel correction to ensure asymptotic consistency.

Because these methods are data-independent, the computational cost per iteration is $O(1)$ relative to the dataset size, allowing for near-instantaneous updates regardless of the number of observations.

Key Results and Performance

The authors evaluated Prior Swapping across regression, classification, and topic modeling tasks using large-scale datasets like YearPredictionMSD ($n \approx 515,000$) and MiniBooNE ($n \approx 130,000$).

  • Speed and Accuracy: In Bayesian linear and logistic regression, Prior Swapping reached near-zero error in seconds, whereas standard IS remained stuck at high error levels. Unlike IS, which is a one-shot reweighting, PS uses the swap density as a target for iterative sampling, allowing it to move toward high-probability regions of the target posterior.
  • Scalability: While standard MCMC and VI wall times grow with dataset size $n$, Prior Swapping's wall time remains flat once the initial false posterior is computed.
  • Complex Priors: PS successfully applied diversity-promoting priors to LDA topic models, merging redundant topics into distinct, meaningful clusters without re-running the full LDA pipeline.
Figure 3: Comparison of posterior error over time for linear and logistic regression. PS methods converge rapidly compared to baselines.

Conclusion

Prior Swapping offers a powerful paradigm shift for Bayesian practitioners. By decoupling data processing from prior selection, it allows for iterative hypothesis testing and the use of sophisticated priors that were previously considered too expensive. While the method's success depends on the quality of the initial false posterior and the accuracy of density estimation, it provides a scalable path forward for fast inference in large-scale Bayesian models.

Summary updated

Abstract

While Bayesian methods are praised for their ability to incorporate useful prior knowledge, in practice, convenient priors that allow for computationally cheap or tractable inference are commonly used. In this paper, we investigate the following question: for a given model, is it possible to compute an inference result with any convenient false prior, and afterwards, given any target prior of interest, quickly transform this result into the target posterior? A potential solution is to use importance sampling (IS). However, we demonstrate that IS will fail for many choices of the target prior, depending on its parametric form and similarity to the false prior. Instead, we propose prior swapping, a method that leverages the pre-inferred false posterior to efficiently generate accurate posterior samples under arbitrary target priors. Prior swapping lets us apply less-costly inference algorithms to certain models, and incorporate new or updated prior information "post-inference". We give theoretical guarantees about our method, and demonstrate it empirically on a number of models and priors.
BibTeX
@misc{neiswanger2016prior,
  author = {Willie Neiswanger and Eric P. Xing},
  title = {{Prior Swapping for Data-Independent Inference}},
  year = {2016},
  eprint = {1606.00787},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1606.00787},
}
Figure