arXiv(opens in a new tab)stat.MLJun 2012Cited by 3 papers on PaperVantage

Manuscript Offprint

arXiv:1206.7051

Stochastic Variational Inference

Matt Hoffman, David M. Blei, Chong Wang, John Paisley

Abstract

We develop stochastic variational inference, a scalable algorithm for approximating posterior distributions. We develop this technique for a large class of probabilistic models and we demonstrate it with two probabilistic topic models, latent Dirichlet allocation and the hierarchical Dirichlet process topic model. Using stochastic variational inference, we analyze several large collections of documents: 300K articles from Nature, 1.8M articles from The New York Times, and 3.8M articles from Wikipedia. Stochastic inference can easily handle data sets of this size and outperforms traditional variational inference, which can only handle a smaller subset. (We also show that the Bayesian nonparametric topic model outperforms its parametric counterpart.) Stochastic variational inference lets us apply complex Bayesian models to massive data sets.

1 Introduction

Modern data analysis requires computation with massive data. As examples, consider the following. (1) We have an archive of the raw text of two million books, scanned and stored online. We want to discover the themes in the texts, organize the books by subject, and build a navigator for users to explore our collection. (2) We have data from an online shopping website containing millions of users’ purchase histories as well as descriptions of each item in the catalog. We want to recommend items to users based on this information. (3) We are continuously collecting data from an online feed of photographs. We want to build a classifier from these data. (4) We have measured the gene sequences of millions of people. We want to make hypotheses about connections between observed genes and other traits.

These problems illustrate some of the challenges to modern data analysis. Our data are complex and high-dimensional; we have assumptions to make—from science, intuition, or other data analyses—that involve structures we believe exist in the data but that we cannot directly observe; and finally our data sets are large, possibly even arriving in a never-ending stream.

Statistical machine learning research has addressed some of these challenges by developing the field of probabilistic modeling, a field that provides an elegant approach to developing new methods for analyzing data (Pearl, 1988; Jordan, 1999; Bishop, 2006; Koller and Friedman, 2009; Murphy, 2012). In particular, probabilistic graphical models give us a visual language for expressing assumptions about data and its hidden structure. The corresponding posterior inference algorithms let us analyze data under those assumptions, inferring the hidden structure that best explains our observations.

In descriptive tasks, like problems #1 and #4 above, graphical models help us explore the data—the organization of books or the connections between genes and traits—with the hidden structure probabilistically “filled in.” In predictive tasks, like problems #2 and #3, we use models to form predictions about new observations. For example, we can make recommendations to users or predict the class labels of new images. With graphical models, we enjoy a powerful suite of probability models to connect and combine; and we have general-purpose computational strategies for connecting models to data and estimating the quantities needed to use them.

The problem we face is scale. Inference algorithms of the 1990s and 2000s used to be considered scalable, but they cannot easily handle the amount of data that we described in the four examples above. This is the problem we address here. We present an approach to computing with graphical models that is appropriate for massive data sets, data that might not fit in memory or even be stored locally. Our method does not require clusters of computers or specialized hardware, though it can be further sped up with these amenities.

As an example of this approach to data analysis, consider topic models. Topic models are probabilistic models of text used to uncover the hidden thematic structure in a collection of documents (Blei, 2012). The main idea in a topic model is that there are a set of topics that describe the collection and each document exhibits those topics with different degrees. As a probabilistic model, the topics and how they relate to the documents are hidden structure and the main computational problem is to infer this hidden structure from an observed collection. Figure 1 illustrates the results of our algorithm on a probabilistic topic model. These are two sets of topics, weighted distributions over the vocabulary, found in 1.8M articles from the New York Times and 300,000 articles from Nature. Topic models are motivated by applications that require analyzing massive collections of documents like this, but traditional algorithms for topic model inference do not easily scale collections of this size.

Figure

Figure 1: Posterior topics from the hierarchical Dirichlet process topic model on two large data sets. These posteriors were approximated using stochastic variational inference with 1.8M articles from the New York Times (top) and 350K articles from Nature (bottom). (See Section 3.3 for the modeling details behind the hierarchical Dirichlet process and Section 4 for details about the empirical study.) Each topic is a weighted distribution over the vocabulary and each topic’s plot illustrates its most frequent words.

Our algorithm builds on variational inference, a method that transforms complex inference problems into high-dimensional optimization problems (Jordan et al., 1999; Wainwright and Jordan, 2008). Traditionally, the optimization is solved with a coordinate ascent algorithm, iterating between re-analyzing every data point in the data set and re-estimating its hidden structure. This is inefficient for large data sets, however, because it requires a full pass through the data at each iteration.

In this paper we derive a more efficient algorithm by using stochastic optimization (Robbins and Monro, 1951), a technique that follows noisy estimates of the gradient of the objective. When used in variational inference, we show that this gives an algorithm which iterates between subsampling the data and adjusting the hidden structure based only on the subsample. This is much more efficient than traditional variational inference. We call our method stochastic variational inference.

We will derive stochastic variational inference for a large class of graphical models. We will study its performance on two kinds of probabilistic topic models. In particular, we demonstrate stochastic variational inference on latent Dirichlet allocation (Blei et al., 2003), a simple topic model, and the hierarchical Dirichlet process topic model (Teh et al., 2006a), a more flexible model where the number of discovered topics grows with the data. (This latter application demonstrates how to use stochastic variational inference in a variety of Bayesian nonparametric settings.) Stochastic variational inference can efficiently analyze massive data sets with complex probabilistic models.

Technical summary. We now turn to the technical context of our method. In probabilistic modeling, we use hidden variables to encode hidden structure in observed data; we articulate the relationship between the hidden and observed variables with a factorized probability distribution (i.e., a graphical model); and we use inference algorithms to estimate the posterior distribution, the conditional distribution of the hidden structure given the observations.

Consider a graphical model of hidden and observed random variables for which we want to compute the posterior. For many models of interest, this posterior is not tractable to compute and we must appeal to approximate methods. The two most prominent strategies in statistics and machine learning are Markov chain Monte Carlo (MCMC) sampling and variational inference. In MCMC sampling, we construct a Markov chain over the hidden variables whose stationary distribution is the posterior of interest (Metropolis et al., 1953; Hastings, 1970; Geman and Geman, 1984; Gelfand and Smith, 1990; Robert and Casella, 2004). We run the chain until it has (hopefully) reached equilibrium and collect samples to approximate the posterior. In variational inference, we define a flexible family of distributions over the hidden variables, indexed by free parameters (Jordan et al., 1999; Wainwright and Jordan, 2008). We then find the setting of the parameters (i.e., the member of the family) that is closest to the posterior. Thus we solve the inference problem by solving an optimization problem.

Neither MCMC nor variational inference scales easily to the kinds of settings described in the first paragraph. Researchers have proposed speed-ups of both approaches, but these usually are tailored to specific models or compromise the correctness of the algorithm (or both). Here, we develop a general variational method that scales.

As we mentioned above, the main idea in this work is to use stochastic optimization (Robbins and Monro, 1951; Spall, 2003). In stochastic optimization, we find the maximum of an objective function by following noisy (but unbiased) estimates of its gradient. Under the right conditions, stochastic optimization algorithms provably converge to an optimum of the objective. Stochastic optimization is particularly attractive when the objective (and therefore its gradient) is a sum of many terms that can be computed independently. In that setting, we can cheaply compute noisy gradients by subsampling only a few of these terms.

Variational inference is amenable to stochastic optimization because the variational objective decomposes into a sum of terms, one for each data point in the analysis. We can cheaply obtain noisy estimates of the gradient by subsampling the data and computing a scaled gradient on the subsample. If we sample independently then the expectation of this noisy gradient is equal to the true gradient. With one more detail—the idea of a natural gradient (Amari, 1998)—stochastic variational inference has an attractive form:

  1. Subsample one or more data points from the data.
  2. Analyze the subsample using the current variational parameters.
  3. Implement a closed-form update of the variational parameters.
  4. Repeat.

While traditional algorithms require repeatedly analyzing the whole data set before updating the variational parameters, this algorithm only requires that we analyze randomly sampled subsets. We will show how to use this algorithm for a large class of graphical models.

Related work. Variational inference for probabilistic models was pioneered in the mid-1990s. In Michael Jordan’s lab, the seminal papers of Saul et al. (1996); Saul and Jordan (1996) and Jaakkola (1997) grew out of reading the statistical physics literature (Peterson and Anderson, 1987; Parisi, 1988). In parallel, the mean-field methods explained in Neal and Hinton (1999) (originally published in 1993) and Hinton and Van Camp (1993) led to variational algorithms for mixtures of experts (Waterhouse et al., 1996).

In subsequent years, researchers began to understand the potential for variational inference in more general settings and developed generic algorithms for conjugate exponential-family models (Attias, 1999; Attias, 2000; Wiegerinck, 2000; Ghahramani and Beal, 2001; Xing et al., 2003). These innovations led to automated variational inference, allowing a practitioner to write down a model and immediately use variational inference to estimate its posterior (Bishop et al., 2003). For good reviews of variational inference see Jordan et al. (1999) and Wainwright and Jordan (2008).

In this paper, we develop scalable methods for generic Bayesian inference by solving the variational inference problem with stochastic optimization (Robbins and Monro, 1951). Our algorithm builds on the earlier approach of Sato (2001), whose algorithm only applies to the limited set of models that can be fit with the EM algorithm (Dempster et al., 1977). Specifically, we generalize his approach to the much wider set of probabilistic models that are amenable to closed-form coordinate ascent inference. Further, in the sense that EM itself is a mean-field method (Neal and Hinton, 1999), our algorithm builds on the stochastic optimization approach to EM (Cappé and Moulines, 2009). Finally, we note that stochastic optimization was also used with variational inference in Platt et al. (2008) for fast approximate inference in a specific model of web service activity.

For approximate inference, the main alternative to variational methods is Markov chain Monte Carlo (MCMC) (Robert and Casella, 2004). Despite its popularity in Bayesian inference, relatively little work has focused on developing MCMC algorithms that can scale to very large data sets. One exception is sequential Monte Carlo, although these typically lack strong convergence guarantees (Doucet et al., 2001). Another is the stochastic gradient Langevin method of Welling and Teh (2011), which enjoys asymptotic convergence guarantees and also takes advantage of stochastic optimization. Finally, in topic modeling, researchers have developed several approaches to parallel MCMC (Newman et al., 2009; Smola and Narayanamurthy, 2010; Ahmed et al., 2012).

The organization of this paper. In Section 2, we review variational inference for graphical models and then derive stochastic variational inference. In Section 3, we review probabilistic topic models and Bayesian nonparametric models and then derive the stochastic variational inference algorithms in these settings. In Section 4, we study stochastic variational inference on several large text data sets.

References (76)

  • Scalable inference in latent variable models
  • On smoothing and inference for topic models
  • Bayesian Theory
  • VIBES: A variational inference engine for Bayesian networks
  • Ferguson distributions via Pólya urn schemes
  • Variational inference for Dirichlet process mixtures
  • Dynamic topic models
  • A correlated topic model of Science
  • Latent Dirichlet allocation
  • Learning using large datasets
  • On-line expectation-maximization algorithm for latent data models
  • A generalization of principal component analysis to the exponential family
  • Maximum likelihood from incomplete data via the EM algorithm
  • An introduction to sequential Monte Carlo methods
  • Bayesian density estimation and inference using mixtures
  • The hierarchical hidden Markov model: Analysis and applications
  • An HDP-HMM for systems with state persistence
  • Bayesian Nonparametric Inference of Switching Dynamic Linear Models
  • A Sticky HDP-HMM with Application to Speaker Diarization
  • Sampling based approaches to calculating marginal densities
  • Data Analysis Using Regression and Multilevel/Hierarchical Models
  • Stochastic relaxation, Gibbs distributions and the Bayesian restoration of images
  • A tutorial on Bayesian nonparametric models
  • Nonparametric variational inference
  • Variational inference for Bayesian mixtures of factor analysers
  • Propagation algorithms for variational Bayesian learning
  • Factorial hidden Markov models
  • Variational Bayesian multinomial probit regression with Gaussian process priors
  • Scalable inference of overlapping communities
  • Finding scientific topics
  • Keeping the neural networks simple by minimizing the description length of the weights
  • Bayesian Nonparametrics
  • On-line learning for latent Dirichlet allocation
  • Bayesian nonparametric matrix factorization for recorded music
  • Natural conjugate gradient in variational inference
  • Learning in Graphical Models
  • Introduction to variational methods for graphical models
  • Non-conjugate variational message passing for multinomial and binary regression
  • Probabilistic Graphical Models: Principles and Techniques
  • On information and sufficiency
  • Learning semantic correspondences with less supervision
  • Online learning for matrix factorization and sparse coding
  • Empirical Bayes methods
  • Generalized Linear Models
  • Equations of state calculations by fast computing machines
  • Sparse stochastic inference for latent Dirichlet allocation
  • Expectation-propagation for the generative aspect model
  • A view of the EM algorithm that justifies incremental, sparse, and other variants
  • Distributed algorithms for topic models
  • Nonparametric factor analysis with beta process priors
  • Variational Bayesian inference with stochastic search
  • The discrete infinite logistic normal distribution
  • Nested hierarchical Dirichlet processes (opens arXiv in a new tab)
  • A mean field theory learning algorithm for neural networks
  • Fast variational inference for large-scale internet diagnosis
  • An adaptive learning rate for stochastic variational inference
  • A stochastic approximation method
  • Monte Carlo Statistical Methods
  • Bayesian probabilistic matrix factorization using Markov chain Monte Carlo
  • Exploiting tractable substructures in intractable networks
  • Mean field theory for sigmoid belief networks
  • An architecture for parallel topic models
  • General intelligence
  • Hierarchical Dirichlet processes
  • A collapsed variational Bayesian inference algorithm for latent Dirichlet allocation
  • Collapsed variational inference for HDP. In Neural Information Processing Systems, 2007
  • Probabilistic principal component analysis
  • Larger residuals, less work: Active document scheduling for latent dirichlet allocation
  • Graphical models, exponential families, and variational inference
  • Rethinking LDA: Why priors matter
  • Variational inference in nonconjugate models
  • Continuous time dynamic topic models
  • Online variational inference for the hierarchical Dirichlet process
  • Bayesian methods for mixtures of experts
  • Bayesian learning via stochastic gradient Langevin dynamics
  • A generalized mean field algorithm for variational inference in exponential families