The Population Posterior
and Bayesian Inference on Streams
Many modern data analysis problems involve inferences from streaming data. However, streaming data is not easily amenable to the standard probabilistic modeling approaches, which assume that we condition on finite data. We develop population variational Bayes, a new approach for using Bayesian modeling to analyze streams of data. It approximates a new type of distribution, the population posterior, which combines the notion of a population distribution of the data with Bayesian inference in a probabilistic model. We study our method with latent Dirichlet allocation and Dirichlet process mixtures on several large-scale data sets.
The Population Posterior
and Bayesian Inference on Streams
James McInerney Data Science Institute Columbia University New York, NY 10027 firstname.lastname@example.org Rajesh Ranganath Computer Science Department Princeton University Princeton, NJ 08540 email@example.com David M. Blei Data Science Institute, Department of Statistics & Department of Computer Science Columbia University New York, NY 10027 firstname.lastname@example.org
Probabilistic modeling has emerged as a powerful tool for data analysis. It is an intuitive language for describing assumptions about data and provides efficient algorithms for analyzing real data under those assumptions. The main idea comes from Bayesian statistics. We encode our assumptions about the data in a structured probability model of hidden and observed variables; we condition on a data set to reveal the posterior distribution of the hidden variables; and we use the resulting posterior as needed, for example to form predictions through the posterior predictive distribution or to explore the data through the posterior expectations of the hidden variables.
Many modern data analysis problems involve inferences from streaming data. Examples include exploring the content of massive social media streams (e.g., Twitter, Facebook), analyzing live video streams, modeling the preferences of users on an online platform for recommending new items, and predicting human mobility patterns for anticipatory computing. Such problems, however, cannot easily take advantage of the standard approach to probabilistic modeling, which always assumes that we condition on a finite data set. This might be surprising to some readers; after all, one of the tenets of the Bayesian paradigm is that we can update our posterior when given new information. (“Yesterday’s posterior is today’s prior.”). But there are two problems with using Bayesian updating on data streams.
The first problem is that Bayesian posteriors will become overconfident. Conditional on never-ending data, most posterior distributions (with a few exceptions) result in a point mass at a single configuration of the latent variables. That is, the posterior contains no variance around its idea of the hidden variables that generated the observed data. In theory this is sensible, but only in the impossible scenario where the data truly came from the proposed model. In practice, all models provide approximations to the data-generating distribution, and we always harbor uncertainty about the model (and thus the hidden variables) even in the face of an infinite data stream.
The second problem is that the data stream might change over time. This is an issue because, frequently, our goal in applying probabilistic models to streams is not to characterize how they change, but rather to accommodate it. That is, we would like for our current estimate of the latent variables to be accurate to the current state of the stream and to adapt to how the stream might slowly change. (This is in contrast, for example, to time series modeling.) Traditional Bayesian updating cannot handle this. Either we explicitly model the time series, and pay a heavy inferential cost, or we tacitly assume that the data are independent and exchangeable.
In this paper we develop new ideas for analyzing data streams with probabilistic models. Our approach combines the frequentist notion of the population distribution with probabilistic models and Bayesian inference.
Main idea: The population posterior. Consider a latent variable model of data points. (This is unconventional notation; we will describe why we use it below.) Following , we define the model to have two kinds of hidden variables: global hidden variables contain latent structure that potentially governs any data point; local hidden variables contain latent structure that only governs the th data point. Such models are defined by the joint,
where and . Traditional Bayesian statistics conditions on a fixed data set to obtain the posterior distribution of the hidden variables . As we discussed, this framework cannot accommodate data streams. We need a different way to use the model.
We define a new distribution, the population posterior, which enables us to consider Bayesian modeling of streams. Suppose we observe data points independently from the underlying population distribution, . This induces a posterior , which is a function of the random data. The expected value of this posterior distribution is the population posterior,
Notice that this distribution is not a function of observed data; it is a function of the population distribution and the data set size . The data set size is a parameter that can be set. This parameter controls the variance of the population posterior, and so depends on how close the model is to the true data distribution.
We have defined a new problem. Given an endless stream of data points coming from and a value for , our goal is to approximate the corresponding population posterior. We will use variational inference and stochastic optimization to approximate the population posterior. As we will show, our algorithm justifies applying a variant of stochastic variational inference  to a data stream. We used this technique to analyze several data streams with modern probabilistic models, such as latent Dirichlet allocation and Dirichlet process mixtures. With held out likelihood as a measure of model fitness, we found our method to give better models of the data than approaches based on full Bayesian inference  or Bayesian updating .
Related work. Several methods exist for performing inference on streams of data. Refs. [28, 1, 9] propose extending Markov chain Monte Carlo methods for streaming data. However, sampling-based approaches do not scale to massive datasets. The variational approximation enables more scalable inference. Ref.  propose online variational inference by exponentially forgetting the variational parameters associated with old data. Ref.  also decay parameters derived from old data, but interpret this action in the context of stochastic optimization, bringing guarantees of convergence to a local optimum. This gradient-based approach has enabled the application of more advanced probabilistic models to large-scale data sets. However, none of these methods are applicable to streaming data, because they implicitly rely on the data being of known size (even when based on subsampling data points to obtain noisy gradients).
To apply the variational approximation to streaming data, Ref.  and Ref.  both propose performing Bayesian updating to the approximating family. Their method uses the latest approximation having seen data points as a prior to be updated using the approximation of the next data point (or mini-batch) using Bayes’ rule. Ref.  adapt this framework to nonparametric mixture modelling. Here we take a different approach, by changing the overall variational objective to incorporate a population distribution and following stochastic gradients of this new objective.
Independently, Ref.  apply SVI to streaming settings by accumulating new data points into a growing window, then uniformly sampling from this window to update the variational parameters. Our method justifies that approach. Further, they propose updating parameters along a trust region, instead of following (natural) gradients, as a way of mitigating local optima. This innovation can be incorporated into our method.
2 Variational Inference for the Population Posterior
We develop population variational Bayes, a method for approximating the population posterior in Eq. 2. Our method is based on variational inference and stochastic optimization.
The F-ELBO. The idea behind variational inference is to approximate difficult-to-compute distributions through optimization [17, 27]. We introduce an approximating family of distributions over the latent variables and try to find the member of that minimizes the Kullback-Leibler (KL) divergence to the target distribution.
Population variational Bayes (VB) uses variational inference to approximate the population posterior in Eq. 2. It aims to solve the following problem,
As for the population posterior, this objective is a function of the population distribution of data points . Notice the difference to classical VB. In classical VB, we optimize the KL divergence between and a posterior, . Its objective is a function of a fixed data set ; the objective in Eq. 3 is a function of the population distribution .
We will use the mean-field variational family, where each latent variable is independent and governed by a free parameter,
The free variational parameters are the global parameters and local parameters . Though we focus on the mean-field family, extensions could consider structured families [22, 14], where there is dependence between variables.
In classical VB, where we approximate the usual posterior, we cannot compute the KL. Thus, we optimize a proxy objective called the ELBO (evidence lower bound) that is equal to the negative KL up to an additive constant. Maximizing the ELBO is equivalent to minimizing the KL divergence to the posterior.
In population VB we also optimize a proxy objective, the F-ELBO. The F-ELBO is an expectation of the ELBO under the population distribution of the data,
The F-ELBO is a lower bound on the population evidence and a lower bound on the negative KL to the population posterior. (See Appendix A.) The inner expectation is over the latent variables and , and is a function of the variational distribution . The outer expectation is over the random data points , and is a function of the population distribution . The F-ELBO is thus a function of both the variational distribution and the population distribution.
As we mentioned, classical VB maximizes the (classical) ELBO, which is equivalent to minimizing the KL. The F-ELBO, in contrast, is only a bound on the negative KL to the population posterior. Thus maximizing the F-ELBO is suggestive but is not guaranteed to minimize the KL. That said, our studies show that this is a good quantity to optimize and in Appendix A we show that the F-ELBO does minimize . As we will see, the ability to sample from is the only additional requirement for maximizing the F-ELBO, using stochastic gradients.
Conditionally conjugate models. In the next section we will develop a stochastic optimization algorithm to maximize Eq. 5. First, we describe the class of models that we will work with.
Following  we focus on conditionally conjugate models. A conditionally conjugate model is one where each complete conditional—the conditional distribution of a latent variable given all the other latent variables and the observations—is in the exponential family. This class includes many models in modern machine learning, such as mixture models, topic models, many Bayesian nonparametric models, and some hierarchical regression models. Using conditionally conjugate models simplifies many calculations in variational inference.
Under the joint in Eq. 1, we can write a conditionally conjugate model with two exponential families:
We overload notation for base measures , sufficient statistics , and log normalizers . Note that is the hyperparameter and that .
In conditionally conjugate models each complete conditional is in an exponential family, and we use these families as the factors in the variational distribution in Eq. 4. Thus indexes the same family as and indexes the same family as . For example, in latent Dirichlet allocation , the complete conditional of the topics is a Dirichlet; the complete conditional of the per-document topic mixture is a Dirichlet; and the complete conditional of the per-word topic assignment is a categorical. (See  for details.)
Population variational Bayes. We have described the ingredients of our problem. We are given a conditionally conjugate model, described in Eqs. 6 and 7, a parameterized variational family in Eq. 4, and a stream of data from an unknown population distribution . Our goal is to optimize the F-ELBO in Eq. 5 with respect to the variational parameters.
The F-ELBO is a function of the population distribution, which is an unknown quantity. To overcome this hurdle, we will use the stream of data from to form noisy gradients of the F-ELBO; we then update the variational parameters with stochastic optimization.
Before describing the algorithm, however, we acknowledge one technical detail. Mirroring , we optimize an F-ELBO that is only a function of the global variational parameters. The one-parameter population VI objective is . This implicitly optimizes the local parameter as a function of the global parameter. The resulting objective is identical to Eq. 5, but with replaced by . (Details are in Appendix B).
The next step is to form a noisy gradient of the F-ELBO so that we can use stochastic optimization to maximize it. Stochastic optimization maximizes an objective by following noisy and unbiased gradients [21, 7]. We will write the gradient of the F-ELBO as an expectation with respect to , and then use Monte Carlo estimates to form noisy gradients.
We compute the gradient of the F-ELBO by bringing the gradient operator inside the expectations of Eq. 5.111For most models of interest, this is justified by the dominated convergence theorem. This results in a population expectation of the classical VB gradient with data points.
We use this expression to compute noisy natural gradients at . We collect data points from ; for each we compute the optimal local parameters , which is a function of the sampled data point and variational parameters; we then compute the quantity inside the brackets in Eq. 8. The result is a single-sample Monte-Carlo estimate of the gradient, which we can compute from a stream of data. We follow the noisy gradient and repeat. This algorithm is summarized in Algorithm. 1. Since Equation 8 is a Monte-Carlo estimate, we are free to draw data points from (where ) and rescale the sufficient statistics by . This makes the gradient estimate faster to calculate, but more noisy. As highlighted in Ref. , this makes sense because early iterations of the algorithm have inaccurate values of so it is wasteful to pass through lots of data before making updates to .
Discussion. Thus far, we have defined the population posterior and showed how to approximate it with population variational inference. Our derivation justifies using an algorithm like stochastic variational inference (SVI)  on a stream of data. It is nearly identical to SVI, but includes an additional parameter: the number of data points in the population posterior .
Note we can recover the original SVI algorithm as an instance of population VI, thus reinterpreting it as minimizing the KL divergence to the population posterior. We recover SVI by setting equal to the number of data points in the data set and replacing the stream of data with , the empirical distribution of the observations. The “stream” in this case comes from sampling with replacement from , which results in precisely the original SVI algorithm.222This derivation of SVI is an application of Efron’s plug-in principle  applied to inference of the population posterior. The plug-in principle says that we can replace the population with the empirical distribution of the data to make population inferences. In our empirical study, however, we found that population VB often outperforms SVI. Treating the data in a true stream, and setting the number of data points different to the true number, can improve predictive accuracy.
We focused on the conditionally conjugate family for convenience, i.e., the simple gradient in Eq. 8. We emphasize, however, that by using recent tools for nonconjugate inference [18, 26, 20], we can adapt the new ideas described above—the population posterior and the F-ELBO—outside of conditionally conjugate models.
3 Empirical Evaluation
We study the performance of population variational Bayes (population VB) against SVI and SVB . With large real-world data we study two models, latent Dirichlet allocation  and Bayesian nonparametric mixture models, comparing the held-out predictive performance of the algorithms. We study the data coming in a true ordered stream, and in a permuted stream (to better match the assumptions of SVI). Across data and models, population VB usually outperforms the existing approaches.
Models. We study two models. The first is latent Dirichlet allocation (LDA) . LDA is a mixed-membership model of text collections and is frequently used to find its latent topics. LDA assumes that there are topics , each of which is a multinomial distribution over a fixed vocabulary. Documents are drawn by first choosing a distribution over topics and then drawing each word by choosing a topic assignment and finally choosing a word from the corresponding topic . The joint distribution is
Fixing hyperparameters, the inference problem is to estimate the conditional distribution of the topics given a large collection of documents.
The second model is a Dirichlet process (DP) mixture . Loosely, DP mixtures are mixture models with a potentially infinite number of components; thus choosing the number of components is part of the posterior inference problem. When using variational for DP mixtures , we take advantage of the stick breaking representation. The variables are mixture proportions , mixture components (for infinite ), mixture assignments , and observations . The joint is
The likelihood and prior on the components are general to the observations at hand. In our study of continuous data we use normal priors and normal likelihoods; in our study of text data we use Dirichlet priors and multinomial likelihoods.
For both models, we use , which corresponds to the number of data points in traditional analysis.
Datasets. With LDA we analyze three large-scale streamed corpora: 1.7M articles from the New York Times spanning 10 years, 130K Science articles written over 100 years, and 7.4M tweets collected from Twitter on Feb 2nd, 2014. We processed them all in a similar way, choosing a vocabulary based on the most frequent words in the corpus (with stop words removed): 8,000 for the New York Times, 5,855 for Science, and 13,996 for Twitter. On Twitter, we each tweet is a document, and we removed duplicate tweets and tweets that did not contain at least 2 words in the vocabulary.
With DP mixtures, we analyze human location behavior data. These data allow us to build periodic models333A simple account of periodicity is captured in the mixture model by observing the time of the week as one of the observation dimensions. of human population mobility, with applications to disaster response and urban planning. The Ivory Coast location data contains 18M discrete cell tower locations for 500K users recorded over 6 months . The Microsoft Geolife dataset contains 35K latitude-longitude GPS locations for 182 users over 5 years. For both data sets, our observations reflect down-sampling the data to ensure that each individual is seen no more than once every 15 minutes.
Results. We compare population VB with SVI  and streaming variational Bayes (SVB)  for LDA  and DP mixtures . SVB updates the variational approximation of the global parameter using sequential Bayesian updating, essentially accumulating expected sufficient statistics from minibatches of data observed in a stream. (Here we give the final results. We include the details of how we set and fit various hyperparameters below.)
We measure model fitness by evaluating the average predictive log likelihood on a set of held-out data. This involves splitting the observations of held-out data points into two equal halves, inferring the local component distribution based on the first half, and testing with the second half . For DP-mixtures, this works by predicting the location of a held-out data point by conditioning on the observed time of week.
In standard offline studies, the held-out set is randomly selected from the data. With streams, however, we test on the next 10K documents (for New York Times, Science), 500K tweets (for Twitter), or 25K locations (on Geo data). This is a valid held-out set because the data ahead of the current position in the stream have not yet been seen by the inference algorithms.
Figure 1 shows the performance of our algorithms for LDA. We looked at two types of streams: one in which the data appear in order and the other in which they have been permuted (i.e., an exchangeable stream). The time permuted stream reveals performance when each data minibatch is safely assumed to be an i.i.d. sample from ; this results in smoother improvements to predictive likelihood. On our data, we found that population VB outperformed SVI and SVB on two of the data sets and outperformed SVI on all of the data. SVB performed better than population VB on Twitter.
Figure 2 shows a similar study for DP mixtures. We analyzed the human mobility data and the New York Times. (Ref.  also analyzed the New York Times.) On these data population VB outperformed SVB and SVI in all settings.444Though our purpose is to compare algorithms, we make one note about a specific data set. The predictive accuracy for the Ivory Coast data set plummets after 14M data points. This is because of the data collection policy. For privacy reasons the data set provides the cell tower locations of a randomly selected cohort of 50K users every 2 weeks . The new cohort at 14M data points behaves differently to previous cohorts in a way that affects predictive performance. However, both algorithms steadily improve after this shock.
Hyperparameters. Our methods are based on stochastic optimization and require setting the learning rate . For all gradient-based procedures, we used a small fixed learning rate to follow noisy gradients. We note that adaptive learning rates [10, 25] are also applicable in this setting, though we did not observe an improvement using these for time-ordered streams.
Our procedures also require setting a batch size, how many data points we observe before updating the approximate posterior. In the LDA study we set the batch size to 100 documents for the larger corpora (New York Times, Science) and 5,000 for Twitter. These sizes were selected to make the average number of words per batch equal in both settings, which helps lower the variance of the gradients. In the DP mixture study we use a batch size of 5,000 locations for Ivory Coast, 500 locations for Geolife, and 100 documents for New York Times.
Unlike traditional Bayesian methods, the data set size is a hyperparameter to population VB. It helps control the posterior variance of the population posterior. Figure 3 reports sensitivity to for all studies (for the time-ordered stream). These plots indicate that the optimal setting of is often different from the true number of data points; the best performing population posterior variance is not necessarily the one implied by the data.
LDA requires additional hyperparameters. In line with , we used 100 topics, and set the hyperparameter to the global topics (which controls the word sparsity of topics) to and the hyperparameter to the word-topic asssignments (which controls the sparsity of topic membership for each word) to . (We use these hyperparameters in Eq. 7 and Eq. 6.) The DP mixture model requires a truncation hyperparameter , which we set to 100 for all three data sets and verified that the number of components used after inference was less than this limit.
4 Conclusions and Future Work
We introduced a new approach to modeling through the population posterior, a distribution over latent variables that combines traditional Bayesian inference and with the frequentist idea of the population distribution. With this idea, we derived population variational Bayes, an efficient algorithm for inference on streams. On two complex Bayesian models and several large data sets, we found that population variational Bayes usually performs better than existing approaches to streaming inference.
-  A. Ahmed, Q. Ho, C. H. Teo, J. Eisenstein, E. P. Xing, and A. J. Smola. Online inference for the infinite topic-cluster model: Storylines from streaming text. In International Conference on Artificial Intelligence and Statistics, pages 101–109, 2011.
-  S. I. Amari. Natural gradient works efficiently in learning. Neural Computation, 10(2):251–276, 1998.
-  J. M. Bernardo and A. F. Smith. Bayesian Theory, volume 405. John Wiley & Sons, 2009.
-  D. M. Blei, M. I. Jordan, et al. Variational inference for Dirichlet process mixtures. Bayesian Analysis, 1(1):121–143, 2006.
-  D. M. Blei, A. Y. Ng, and M. I. Jordan. Latent Dirichlet allocation. The Journal of Machine Learning Research, 3:993–1022, 2003.
-  V. D. Blondel, M. Esch, C. Chan, F. Clérot, P. Deville, E. Huens, F. Morlot, Z. Smoreda, and C. Ziemlicki. Data for development: the D4D challenge on mobile phone data. arXiv preprint arXiv:1210.0137, 2012.
-  L. Bottou. Online learning and stochastic approximations. Online learning in Neural Networks, 17:9, 1998.
-  T. Broderick, N. Boyd, A. Wibisono, A. C. Wilson, and M. Jordan. Streaming variational Bayes. In Advances in Neural Information Processing Systems, pages 1727–1735, 2013.
-  A. Doucet, S. Godsill, and C. Andrieu. On sequential Monte Carlo sampling methods for Bayesian filtering. Statistics and Computing, 10(3):197–208, 2000.
-  J. Duchi, E. Hazan, and Y. Singer. Adaptive subgradient methods for online learning and stochastic optimization. The Journal of Machine Learning Research, 12:2121–2159, 2011.
-  B. Efron and R. J. Tibshirani. An introduction to the bootstrap. CRC press, 1994.
-  M. D. Escobar and M. West. Bayesian density estimation and inference using mixtures. Journal of the American Statistical Association, 90(430):577–588, 1995.
-  Z. Ghahramani and H. Attias. Online variational Bayesian learning. In Slides from talk presented at NIPS 2000 Workshop on Online learning, pages 101–109, 2000.
-  M. D. Hoffman and D. M. Blei. Structured stochastic variational inference. In International Conference on Artificial Intelligence and Statistics, pages 101–109, 2015.
-  M. D. Hoffman, D. M. Blei, C. Wang, and J. Paisley. Stochastic variational inference. The Journal of Machine Learning Research, 14(1):1303–1347, 2013.
-  A. Honkela and H. Valpola. On-line variational Bayesian learning. In 4th International Symposium on Independent Component Analysis and Blind Signal Separation, pages 803–808, 2003.
-  M. I. Jordan, Z. Ghahramani, T. S. Jaakkola, and L. K. Saul. An introduction to variational methods for graphical models. Machine learning, 37(2):183–233, 1999.
-  D. P. Kingma and M. Welling. Auto-encoding variational Bayes. arXiv preprint arXiv:1312.6114, 2013.
-  A. Nemirovski, A. Juditsky, G. Lan, and A. Shapiro. Robust stochastic approximation approach to stochastic programming. SIAM Journal on Optimization, 19(4):1574–1609, 2009.
-  R. Ranganath, S. Gerrish, and D. M. Blei. Black box variational inference. In Proceedings of the Seventeenth International Conference on Artificial Intelligence and Statistics, pages 805–813, 2014.
-  H. Robbins and S. Monro. A stochastic approximation method. The Annals of Mathematical Statistics, pages 400–407, 1951.
-  L. K. Saul and M. I. Jordan. Exploiting tractable substructures in intractable networks. Advances in Neural Information Processing Systems, pages 486–492, 1996.
-  A. Tank, N. Foti, and E. Fox. Streaming variational inference for Bayesian nonparametric mixture models. In International Conference on Artificial Intelligence and Statistics, May 2015.
-  L. Theis and M. D. Hoffman. A trust-region method for stochastic variational inference with applications to streaming data. arXiv preprint arXiv:1505.07649, 2015.
-  T. Tieleman and G. Hinton. Lecture 6.5-RMSProp: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural Networks for Machine Learning, 4, 2012.
-  M. Titsias and M. Lázaro-Gredilla. Doubly stochastic variational Bayes for non-conjugate inference. In Proceedings of the 31st International Conference on Machine Learning, pages 1971–1979, 2014.
-  M. J. Wainwright and M. I. Jordan. Graphical models, exponential families, and variational inference. Foundations and Trends in Machine Learning, 1(1-2):1–305, Jan. 2008.
-  L. Yao, D. Mimno, and A. McCallum. Efficient methods for topic model inference on streaming document collections. In Conference on Knowledge Discovery and Data Mining, pages 937–946. ACM, 2009.
Appendix A Derivation and Bounds of the F-ELBO
Classic variational inference seeks to minimize using the following equivalence to show that the negative evidence lower bound (ELBO) is an appropriate surrogate objective to be minimized,
This equivalence arises from the definition of KL divergence .
To derive the F-ELBO, replace with a draw of size from the population distribution, , then apply an expectation with respect to to both sides of Eq.11,
This confirms that the negative F-ELBO is a surrogate objective for because does not appear on the left hand side of Eq. 12.
Now use the fact that logarithm is a concave function and apply Jensen’s inequality to Eq. 12 to show that the F-ELBO is a lower bound on the population evidence,
Additionally, Jensen’s inequality applied to Eq. 12 in a different way shows that maximizing the F-ELBO minimizes an upper bound on the KL divergence between and the population posterior,
where we have exchanged expectations with respect to and .
Appendix B One-Parameter F-ELBO
The F-ELBO for conditionally conjugate exponential families is as follows
This can be rewritten in terms of just the global variational parameters. We define the one parameter population variational inference objective as . We can write this more compactly if we let be the value of that maximizes the F-ELBO given .555The optimal local variational parameter can be computed using gradient ascent or coordinate ascent as done in . Formally, this gives
where we have moved the expectation with respect to inside the expectation with respect to .