Nested Hierarchical Dirichlet Processes

10/25/2012 ∙ by John Paisley, et al. ∙ 0

We develop a nested hierarchical Dirichlet process (nHDP) for hierarchical topic modeling. The nHDP is a generalization of the nested Chinese restaurant process (nCRP) that allows each word to follow its own path to a topic node according to a document-specific distribution on a shared tree. This alleviates the rigid, single-path formulation of the nCRP, allowing a document to more easily express thematic borrowings as a random effect. We derive a stochastic variational inference algorithm for the model, in addition to a greedy subtree selection method for each document, which allows for efficient inference using massive collections of text documents. We demonstrate our algorithm on 1.8 million documents from The New York Times and 3.3 million documents from Wikipedia.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 15

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Organizing things hierarchically is a natural aspect of human activity. Walking into a large department store, one might first find the men’s section, followed by men’s casual, and then see the t-shirts hanging along the wall. Or being hungry, one might choose to eat Italian food, decide whether to spring for the better, more authentic version or go to one of the cheaper chain options, and then end up at the Olive Garden. Similarly with data analysis, a hierarchical tree-structured representation of data can provide an illuminating means for understanding and reasoning about the information it contains.

In this paper, we focus on developing hierarchical topic models to construct tree-structured representations for text data. Hierarchical topic models use a structured prior on the topics underlying a corpus of documents, with the aim of bringing more order to an unstructured set of thematic concepts [1][2][3]. They do this by learning a tree structure for the underlying topics, with the inferential goal being that topics closer to the root are more general, and gradually become more specific in thematic content when following a path down the tree.

Fig. 1:

An example of path structures for the nested Chinese restaurant process (nCRP) and the nested hierarchical Dirichlet process (nHDP) for hierarchical topic modeling. With the nCRP, the topics for a document are restricted to lying along a single path. With the nHDP, each document has access to the entire tree, but a document-specific distribution on paths will place high probability on a particular subtree. In both models a word follows a path to its topic. This path is deterministic in the case of the nCRP, and drawn from a highly probable document-specific subset of paths in the case of the nHDP.

Our work builds on the nested Chinese restaurant process (nCRP) [4]. The nCRP is a Bayesian nonparametric prior for hierarchical topic models, but is limited in that it assumes each document selects topics from one path in the tree. We illustrate this limitation in Figure 1. This assumption has practical drawbacks; for trees truncated to a small number of levels this does not allow for many topics per document, and for trees of many levels there are too many nodes to infer.

The nCRP also has drawbacks from a modeling standpoint. As a simple example, consider an article on ESPN.com about an injured player, compared with an article in a sports medicine journal about a specific type of athletic injury. Both documents will contain words about medicine and words about sports. These areas are different enough, however, that one cannot be considered to be a subset of the other. Yet the single-path structure of the nCRP will require this to be the case in order to model the relevant words in the documents, or it will learn a new “sports/medicine” topic rather than a mixture of separate sports and medicine topics. Continuing this analogy, other documents may only be about sports or medicine. As a result, medical terms in the nCRP will need to appear in multiple places within the tree: in its own subtree separate from sports, and also affiliated with sports, perhaps as a child of the general sports topic (in the case of the ESPN article). A similar fractionation of sports-related terms results from the sports medicine article, where the medical terms dominate and sports can be considered a topic underneath the main medicine topic. The result is a tree where topics appear in multiple places, and so the full statistical power within the corpus is not being used to model each topic; the tree will not be as compact as it could be.

Though the nCRP is a Bayesian nonparametric prior, it performs nonparametric clustering of document-specific paths, which reduces the number of topics available to a document by restricting them to lie on a single path, leading to drawbacks as illustrated above. Our goal is to develop a related Bayesian nonparametric prior that performs word-specific path clustering. We illustrate this objective in Figure 1. In this case, each word has access to the entire tree, but with document-specific distributions on the paths within the tree. To this end, we make use of the hierarchical Dirichlet process [5], developing a novel prior that we refer to as the nested hierarchical Dirichlet process (nHDP). The HDP can be viewed as a nonparametric elaboration of the classical topic model, latent Dirichlet allocation (LDA) [6], providing a mechanism whereby a global Dirichlet process defines a base distribution for a collection of local Dirichlet processes, one for each document. With the nHDP, we extend this idea by letting a global nCRP become a base distribution for a collection of local nCRPs, one for each document. As illustrated in Figure 1, the nested HDP provides the opportunity for cross-thematic borrowing while keeping general topic areas in separate subtrees, which is not possible with the nCRP.

Hierarchical topic models have thus far been applied to corpora of small size. A significant issue, not just with topic models but with Bayesian models in general, is to scale up inference to massive data sets [7]. Recent developments in stochastic variational inference methods have shown promising results for LDA and the HDP topic model [8][9][10]. We continue this development for hierarchical topic modeling with the nested HDP. Using stochastic variational inference, we demonstrate an ability to efficiently handle very large corpora. This is a major benefit to complex models such as tree-structured topic models, which require significant amounts of data to support their large size.

We organize the paper as follows: In Section 2 we review the Bayesian nonparametric priors that we incorporate in our model—the Dirichlet process, nested Chinese restaurant process and hierarchical Dirichlet process. In Section 3 we present our proposed nested HDP model for hierarchical topic modeling. In Section 4 we review stochastic variational inference and present an inference algorithm for nHDPs that scales well to massive data sets. We present empirical results in Section 5. We first compare the nHDP with the nCRP on three relatively small data sets. We then evaluate our stochastic algorithm on 1.8 million documents from The New York Times and 2.7 million documents from Wikipedia, comparing performance with stochastic LDA and HDP.

2 Background: Bayesian nonparametric priors for topic models

The nested hierarchical Dirichlet process (nHDP) builds on a collection of existing Bayesian nonparametric priors. In this section, we review these priors: the Dirichlet process, nested Chinese restaurant process and hierarchical Dirichlet process. We also review constructive representations for these processes that we will use for posterior inference of the nHDP topic model.

2.1 Dirichlet processes

The Dirichlet process (DP) [11] is the foundation for a large collection of Bayesian nonparametric models that rely on mixtures to represent distributions on data. Mixture models work by partitioning a data set according to statistical traits shared by members of the same cell. Dirichlet process priors are effective in learning a suitable number of traits for representing the data, in addition to the parameters of the mixture. The basic form of a Dirichlet process mixture model is

(1)

With this representation, data are distributed according to a family of distributions with respective parameters . These parameters are drawn from the distribution , which is discrete and potentially infinite, as the DP allows it to be. This discreteness induces a partition of the data according to the sharing of the atoms among the parameters that are selected.

The Dirichlet process is a stochastic process for generating . To briefly review, let be a measurable space, a probability measure on it and . Ferguson [11] proved the existence of a stochastic process where, for all measurable partitions of , with ,

abbreviated as . It has been shown that is discrete (with probability one) even when is non-atomic [12][13]. Thus the DP prior is a good candidate for in Eq. (1) since it generates discrete distributions on continuous parameter spaces. For most applications is diffuse, and so representations of at the granularity of the atoms are necessary for inference; we next review two of these approaches to working with this infinite-dimensional distribution.

2.1.1 Chinese restaurant processes

The Chinese restaurant process (CRP) avoids directly working with by integrating it out [12][14]. In doing so, the values of become dependent, with the value of given distributed as

(2)

That is, takes the value of one of the previously observed with probability , and a value drawn from with probability , which will be unique when is continuous. This displays the clustering property of the CRP and also gives insight into the impact of , since it is evident that the number of unique grows like . In the limit , the distribution in Eq. (2) converges to a random measure distributed according to a Dirichlet process [12]. The CRP is so-called because of an analogy to a Chinese restaurant, where a new customer (datum) sits at a table (selects a parameter) with probability proportional to the number of previous customers at that table, or selects a new table with probability proportional to .

2.1.2 A stick-breaking construction

Where the Chinese restaurant process works with implicitly through , a stick-breaking construction allows one to directly construct before drawing any . Sethuraman [13] showed that if is constructed as follows:

(3)

then . The variable can be interpreted as the proportion broken from the remainder of a unit length stick, . As the index

increases, more random variables in

are multiplied, and thus the weights decrease to zero exponentially. The expectation gives a sense of the impact of on these weights. This explicit construction of maintains the independence among as written in Eq. (1), which is a significant advantage of this representation for mean-field variational inference that is not present in the CRP.

2.2 Nested Chinese restaurant processes

Nested Chinese restaurant processes (nCRP) are a tree-structured extension of the CRP that are useful for hierarchical topic modeling [4]. They extend the CRP analogy to a nesting of restaurants in the following way: After selecting a table (parameter) according to a CRP, the customer departs for another restaurant uniquely indicated by that table. Upon arrival, the customer acts according to the CRP for the new restaurant, and again departs for a restaurant only accessible through the table selected. This occurs for a potentially infinite sequence of restaurants, which generates a sequence of parameters for the customer according to the selected tables.

A natural interpretation of the nCRP is as a tree where each parent has an infinite number of children. Starting from the root node, a path is traversed down the tree. Given the current node, a child node is selected with probability proportional to the previous number of times it was selected among its siblings, or a new child is selected with probability proportional to . As with the CRP, the underlying mixing measure of the nCRP also has a constructive representation useful for variational inference, which we will use in our nHDP construction.

2.2.1 Constructing the nCRP

The nesting of Dirichlet processes that leads to the nCRP gives rise to a stick-breaking construction [2]. We develop the notation for this construction here and use it later in our construction of the nested HDP. Let be a path to a node at level of the tree.111That is, from the root node first select the child with index ; from node , select the child with index ; from node select the child with index , and so on to level with each . We ignore the root , which is shared by all paths. According to the stick-breaking version of the nCRP, the children of node are countably infinite, with the probability of transitioning to child equal to the th break of a stick-breaking construction. Each child corresponds to a parameter drawn independently from . Letting the index of the parameter identify the index of the child, this results in the following DP for the children of node ,

(4)

If the next node is child , then the nCRP transitions to DP , where has index appended to , that is . A path down the tree givens a sequence of parameters , where the parameter correspond to an atom at level . Hierarchical topic models use these sequences of parameters to give the topics for generating documents. Other nested DPs have been considered as well, such as a two-leveled nDP where all parameters are selected from the leaves [15].

2.2.2 Nested CRP topic models

Hierarchical topic models based on the nested CRP use a globally shared tree to generate a corpus of documents. Starting with the construction of nested Dirichlet processes as described above, each document selects a path down the tree according to a Markov process, which produces a sequence of topics used to generate the th document. As with other topic models, each word in a document, , is represented by an index in the set and the topics appearing in are

-dimensional probability vectors with Dirichlet prior

.

For each document , an additional stick-breaking process provides a distribution on the topics in ,

(5)

Since this is not a DP, has two free parameters, and . Following the standard method, words for document are generated by first drawing a topic i.i.d. from , and then drawing the word index from the discrete distribution with the selected topic.

2.2.3 Issues with the nCRP

As discussed in the introduction, a significant drawback of the nCRP for topic modeling is that each document follows one path down the tree. Therefore, all thematic content of a document must be contained within that single sequence of topics. Since the nCRP is meant to characterize the thematic content of a corpus in increasing levels of specificity, this creates a combinatorial problem, where similar topics will appear in many parts of the tree to account for the possibility that they appear as a topic of the document (e.g., the sport/medicine example given in the introduction). In practice, nCRP trees are typically truncated at three levels [2][4], since learning deeper levels becomes difficult due to the exponential increase in nodes.222This includes a root node topic, which is shared by all documents and is intended to collect stop words. In this situation each document has three topics for modeling its entire thematic content, which is likely insufficient, and so a blending of multiple topics is bound to occur during inference.

The nCRP is a Bayesian nonparametric (BNP) prior, but it performs nonparametric clustering of the paths selected at the document level, rather than at the word level. Though the same distribution on a tree is shared by a corpus, each document can differentiate itself only by the path it choses, as well as the distribution on topics in that path. The key issue with the nCRP is the restrictiveness of this single path allowed to a document. However, if instead each word were allowed to follow its own path according to an nCRP, the distribution on paths would be the same for all documents, which is clearly not desired. Our goal is to develop a hierarchical topic model that does not prohibit a document from using topics in different parts of the tree. Our solution to this problem is to employ the hierarchical Dirichlet process (HDP).

2.3 Hierarchical Dirichlet processes

The HDP is a multi-level version of the Dirichlet process [5]. It makes use of the idea that the base distribution on the continuous space

can be discrete, which is useful because a discrete distribution allows for multiple draws from the DP prior to place probability mass on the same subset of atoms. Hence different groups of data can share the same atoms, but have different probability distributions on them. A discrete base is needed, but the atoms are unknown in advance. The HDP models these atoms by drawing the base from a DP prior. This leads to the hierarchical process

(6)

for groups . This prior has been used to great effect in topic modeling as a nonparametric extension of LDA [6] and related LDA-based models [16][17][18].

As with the DP, explicit representations of the HDP are necessary for inference. The representation we use relies on two levels of Sethuraman’s stick breaking construction. For this construction, first sample as in Eq. (3), and then sample in the same way,

(7)

This form is identical to Eq. (3), with the key difference that is discrete, and so atoms will repeat. An advantage of this representation is that all random variables are i.i.d., which aids variational inference strategies.

3 Nested hierarchical Dirichlet processes for topic modeling

In building on the nCRP framework, our goal is to allow for each document to have access to the entire tree, while still learning document-specific distributions on topics that are thematically coherent. Ideally, each document will still exhibit a dominant path corresponding to its main themes, but with off-shoots allowing for other topics. Our two major changes to the nCRP formulation toward this end are that () each word follows its own path to a topic, and () each document has its own distribution on paths in a shared tree. The BNP tools discussed above make this a straightforward task.

In the proposed nested hierarchical Dirichlet process (nHDP), we split the process of generating a document’s distribution on topics into two parts: first, generating a document’s distribution on paths down the tree, and second, generating a word’s distribution on terminating at a particular node within those paths.

3.1 Constructing a distribution on paths

With the nHDP, all documents share a global nCRP drawn according to the stick-breaking construction in Section 2.2.1. Denote this tree by . As discussed, is simply an infinite collection of Dirichlet processes with a continuous base distribution and a transition rule between DPs. According to this rule, from a root Dirichlet process , a path is followed by drawing for , where is a constant root index, and indexes the DP associated with the topic . With the nested HDP, instead of following paths according to the global , we use each Dirichlet process in as a base distribution for a local DP drawn independently for each document.

That is, for document we construct a tree where, for each , we draw a corresponding according to the Dirichlet process

(8)

As discussed in Section 2.3, will have the same atoms as , but with different probability weights on them. Therefore, the tree will have the same nodes as , but the probability of a path in will vary with , giving each document its own distribution on the tree.

We represent this document-specific DP with a stick-breaking construction as in Section 2.3,

(9)

This representation retains full independence among random variables, and will lead to a simpler stochastic variational inference algorithm. We note that the atoms from the global DP are randomly permuted and copied with this construction; does not correspond to the node with parameter . To find the probability mass that places on , one can calculate

Using this nesting of HDPs to construct , each document has a tree with transition probabilities defined over the same subset of nodes since is discrete, but with values for these probabilities that are document specific. To see how this allows each word to follow its own path while still producing a thematically coherent document, consider each when is small. In this case, most of the probability will be placed on one atom selected from since the first proportion will be large with high probability. This will leave little probability remaining for other atoms, a feature shared by all DPs in . Starting from the root node of , each word in the document will have high probability of transitioning to the same node when moving down the tree, with some small probability of diverging into a different topic. In the limit , each will be a delta function on a , and the same path will be selected by each word with probability one, thus recovering the nCRP.

  1. Generate a global tree by constructing an nCRP as in Section 2.2.1.

  2. Generate document tree and switching probabilities . For document ,
    a) For each DP in , draw a DP with this as a
    base distribution (Equation 8).
    b) For each node in , draw a beta random
    variable (Equation 10).

  3. Generate a document. For word in document ,
    a) Sample atom (Equation 11).
    b) Sample word from topic .

Algorithm 1 Generating documents with the nHDP

3.2 Generating a document

With the tree for document we have a method for selecting word-specific paths that are thematically coherent, meaning they tend to reuse the same path while allowing for off-shoots. We next discuss how to generate a document with this tree. As discussed in Section 2.2.2, with the nCRP the atoms selected for a document by its path through have a unique stick-breaking distribution that determines which level any particular word comes from. We generalize this idea to the tree with an overlapping stick-breaking construction as follows.

For each node , we draw a document-specific beta random variable that acts as a stochastic switch. Given a pointer that is currently at node , the beta random variable determines the probability that we draw from the topic at that node or continue further down the tree. That is, given that the path for word is at node , stop with probability , where

(10)

If we don’t select topic , then continue by selecting node according to . We observe the stick-breaking construction implied by this construction; for word in document , the probability that its topic is

(11)

Here it is implied that equals the first values in for . The leftmost term in this expression is the probability of path , the right term is the probability that the word does not select the first topics, but does select the th. Since all random variables are independent, a simple product form results that will significantly aid the development of a posterior inference algorithm. The overlapping nature of this stick-breaking construction on the levels of a sequence is evident from the fact that the random variables are shared for the first values by all paths along the subtree starting at node . A similar tree-structured prior distribution was presented by Adams, et al. [19] in which all groups shared the same distribution on a tree and entire objects (e.g., images or documents) were clustered within a single node. We summarize our model for generating documents with the nHDP in Algorithm 1.

4 Stochastic variational inference for the Nested HDP

Many text corpora can be viewed as “Big Data”—they are large data sets for which standard inference algorithms can be prohibitively slow. For example, Wikipedia currently indexes several million entries and The New York Times

has published almost two million articles in the last 20 years. With so much data, fast inference algorithms are essential. Stochastic variational inference is a development in this direction for hierarchical Bayesian models in which ideas from stochastic optimization are applied to approximate Bayesian inference using mean-field variational Bayes (VB)

[20][8]. Stochastic inference algorithms have provided a significant speed-up in inference for probabilistic topic models [9][10][21]. In this section, after reviewing the ideas behind stochastic variational inference, we present a stochastic variational inference algorithm for the nHDP topic model.

4.1 Stochastic variational inference

Stochastic variational inference exploits the difference between local variables, or those associated with a single unit of data, and global variables, which are shared over an entire data set. In brief, stochastic VB works by splitting a large data set into smaller groups, processing the local variables of one group, updating the global variables, and then moving to another group. This is in contrast to batch inference, which processes all local variables at once before updating the global variables. In the context of probabilistic topic models, the unit of data is a document, and the global variables include the topics (among other possible variables), while the local variables relate to the distribution on these topics for each document. We next briefly review the relevant ideas from variational inference and its stochastic variant.

4.1.1 The batch set-up

Mean-field variational inference is a method for approximate posterior inference in Bayesian models [22]. It approximates the full posterior of a set of model parameters with a factorized distribution

. It does this by searching the space of variational approximations for one that is close to the posterior according to their Kullback-Leibler divergence. Algorithmically, this is done by maximizing a variational objective function

with respect to the variational parameters of , where

(12)

We are interested in conjugate exponential models, where the prior and likelihood of all nodes of the model fall within the conjugate exponential family. In this case, variational inference has a simple optimization procedure [23], which we illustrate with the following example—this generic example gives the general form exploited by the stochastic variational inference algorithm that we apply to the nHDP.

Consider independent samples from an exponential family distribution , where is the natural parameter vector. The likelihood under this model has the generic form

The sum of vectors

forms the sufficient statistics of the likelihood. The conjugate prior on

has a similar form

Conjugacy between these two distributions motivates selecting a distribution in this same family to approximate the posterior of ,

The variational parameters and are free and are modified to maximize the lower bound in Eq. (12).333A closed form expression for the lower bound is readily derived for this example. Inference proceeds by taking the gradient of with respect to the variational parameters of a particular , in this case the vector , and setting to zero to find their updated values. For the conjugate exponential example we are considering, this gradient is

(13)

Setting this to zero, one can immediately read off the variational parameter updates from the rightmost vector. In this case and , which are the sufficient statistics calculated from the data.

4.1.2 A stochastic extension

Stochastic optimization of the variational lower bound modifies batch inference by forming a noisy gradient of at each iteration. The variational parameters for a random subset of the data are optimized first, followed by a step in the direction of the noisy gradient of the global variational parameters. Let index a subset of the data at step . Also let be the hidden local variables associated with observation and let be the global variables shared among all observations. The stochastic variational objective function is the noisy version of formed by selecting a subset of the data,

(14)

Optimizing optimizes in expectation; since each subset is equally probable, with , and since for of the possible subsets, it follows that

Stochastic variational inference proceeds by optimizing the objective in (14) with respect to for , followed by an update to that blends the new information with the old. The update of a global variational parameter at step is , where the matrix is a positive definite preconditioning matrix and is a step size satisfying and to ensure convergence [20].

The gradient has a similar form as Eq. (13), with the exception that the sum is taken over a subset of the data. Though the matrix in Eq. (13) is often very complicated, it is superfluous to batch variational inference for conjugate exponential family models. In the stochastic optimization of Eq. (12), however, this matrix cannot be ignored. The key for conjugate exponential models is in selecting the preconditioning matrix . Since the gradient of has the same form as Eq. (13), can be set to the inverse of the matrix in (13) to allow for cancellation. An interesting observation is that this matrix is

(15)

which is the inverse Fisher information of the variational distribution . Using this setting for , the step direction is the natural gradient of the lower bound, and therefore gives an efficient step direction in addition to simplifying the algorithm [24]. The resulting variational update is a weighted combination of the old sufficient statistics for with the new ones calculated over data indexed by .

  1. Randomly subsample documents from the corpus.

  2. For each document in the subsample,
    a) Select a subtree according to a greedy
    process on the variational objective (Eq. 16).
    b) Optimize distributions for subtree.
    Iterate between word allocation (Eq. 17)
    and topic distribution updates (Eqs. 1921).

  3. Collect the sufficient statistics for the topics and base distribution and step in the direction of the natural gradient (Eqs. 2227).

  4. Return to Step 1.

Algorithm 2 Variational inference for the nHDP

4.2 The inference algorithm

We develop a stochastic variational inference algorithm for approximate posterior inference of the nHDP topic model. As discussed in our general review of stochastic inference, this entails optimizing the local variational parameters for a subset of documents, followed by a step along the natural gradient of the global variational parameters. We distinguish between local and global variables for the nHDP in Table II. In Table II we also give the variational distributions selected for each variable. In almost all cases we select this distribution to be in the same family as the prior. We point out two additional latent indicator variables for inference: , which indicates the topic of word , and , which points to the atom in associated with the th break in using the construction given in Eq. (9).

Since we wish to consider large trees, and because there is slightly more overhead in calculating the distribution for each document than in models such as LDA and the HDP, the word allocation step is more time consuming for the nHDP. Additionally, we seek an efficient means for learning the indicators . Since each document will use a small subset of topics, which translates to a small subtree of the entire tree, our goal is to pick out a subtree in advance for the document to work with. This will reduce the number of topics to do inference over for each document, speeding up the algorithm, and determine the delta-function indicators for , which point to the “activated” nodes.

To this end, we introduce a third aspect to our inference algorithm in which we pick a small subtree for each document in advance. By this we mean that we only allow words in a document to be allocated to the subtree selected for that document and fix the probability that the indicator corresponds to topics outside this subtree to zero. As we will show, by selecting a subtree we are in effect learning a truncated stick-breaking construction of the tree for each document. If a node has two children in the subtree, then algorithmically we will have a two-node truncated construction for that DP of the specific document we are considering.

We select the subtree from for each document using a greedy algorithm. This greedy algorithm is performed with respect to maximizing the variational objective function. Being an optimization method with one requirement (that we maximize a fixed objective), variational inference has considerable freedom in this regard. We discuss this greedy algorithm below, followed by the variational parameter updates for the local and global distributions. Algorithm 2 gives an outline.

Global variables: : topic probability vector for node i
: stick proportion for the global DP for node i
Local variables: : stick proportion for local DP for node i
: index pointer to atom in for th break in ,

: beta distributed switch probability for node

i
: topic indicator for word in document
TABLE I: A list of the local and global variables and their respective distributions for the nHDP topic model.

4.2.1 Greedy subtree selection

As mentioned, we perform a greedy algorithm with respect to the variational objective function to determine a subtree from for each document. We first describe the algorithm followed by a mathematical representation. Starting from the root node, we sequentially add nodes from , selecting from those currently “activated.” An activated node is one whose parent is contained within the subtree but which is not itself in the subtree.

To determine which node to add, we look at which node will give the greatest increase in the variational objective when the distributions for the document-specific beta distributions are fixed to their priors and the variational distribution for each word’s topic indicator distribution ( in Table II) is zero on the remaining unactivated nodes. That is, we then ask the question: Which of the activated nodes not currently in the subtree will lead to the greatest increase in the variational objective under this restricted distribution?

The reason we consider this restricted distribution is that there is a closed form calculation for each node, and so no iterations are required in this step and the algorithm is much faster. Calculating this score only involves optimizing the variational parameter for each word over the current subtree plus the candidate node. We continue adding the maximizing node until the marginal increase in the objective falls below a threshold. We give a more formal description of this below.

Coordinate update for

As defined in Table II, is the variable that indicates the index of the atom from the global DP pointed to by the th stick-breaking weight in . We select a delta distribution for this variable, meaning we make a hard assignment for this value. These values also define the subtree for document . Starting with an empty tree, all atoms in constitute the activated set. Adding the first node is equivalent to determining the value for ; in general, creating a subtree for , which we denote as , is equivalent to determining which to include in and the atoms to which they point.

For a subtree of size corresponding to document , let the set contain the index values of the included nodes, let be the set of candidate nodes to add to . Then provided the marginal increase in the variational objective is above a preset threshold, we increment the subtree by letting , where

(16)

We let denote the discussed conditions, that for all and that is fixed to the prior for all other distributions. The optimal values for are given below in Eq. (17).

We note two aspects of this greedy algorithm. First, though the stick-breaking construction of the document-level DP given in Eq. (9) allows for atoms to repeat, in this algorithm each additional atom is new, since there is no advantage in duplicating atoms. Therefore, the algorithm approximates each by selecting and reordering a subset of atoms from for its stick-breaking construction. (The subtree may also contain zero atoms or one atom from a .) The second aspect we point out is the changing prior on the same node in . If the atom is a candidate for addition, then it remains a candidate until it is either selected by a , or the algorithm terminates. The prior on selecting this atom changes, however, depending on whether it is a candidate for or . Therefore, incorporating a sibling of impacts the prior on incorporating .

4.2.2 Coordinate updates for document variables

Given the subtree selected for document , we optimize the variational parameters for the distributions on , and over that subtree.

Coordinate update for

The variational distribution on the path for word is

(17)

where the prior term is the tree-structured prior of the nHDP,

(18)

We use the notation to indicate the subsequences of i starting from the first value. The expectation , where is the digamma function. Also, for a general random variable , and . The corresponding values of and for and are given in their respective updates below.

We note that this has a familiar feel as LDA, but where LDA uses a flat Dirichlet prior on , the nHDP uses a prior that is a tree-structured product of beta random variables. Though the form of the prior is more complicated, the independence results in simple closed-form updates for these beta variables that only depend on .

Coordinate update for

The variational parameter updates for the document-level stick-breaking proportions are

(19)

In words, the statistic for the first parameter is the expected number of words in document that pass through or stop at node . The statistic for the second parameter is the expected number of words from document whose paths pass through the same parent i, but then transition to a node with index greater than according to the indicators from the document-level stick-breaking construction of .

Coordinate update for

The variational parameter updates for the switching probabilities are similar to those of the document-level stick-breaking process, but collect the statistics from in a slightly different way,

(20)
(21)

In words, the statistic for the first parameter is the expected number of words that use the topic at node i. The statistic for the second parameter is the expected number of words that pass through node i but do not terminate there.

4.2.3 Stochastic updates for corpus variables

After selecting the subtrees and updating the local document-specific variational parameters for each document in sub-batch , we take a step in the direction of the natural gradient of the parameters of the distributions on the global variables. These include the topics and the global stick-breaking proportions .

Stochastic update for

For the stochastic update of the Dirichlet distributions on each topic , first form the vector of sufficient statistics using the data in sub-batch ,

(22)

for This vector contains the expected number of words with index that originate from topic over documents indexed by . According to the discussion on stochastic inference in Section 4.1.2, we scale this to a corpus of size . The update for the associated distribution is

(23)

We see a blending of the old statistics with the new in this update. Since as increases, the algorithm uses less and less information from new sub-groups of documents, which reflects the increasing confidence in this parameter value as more data is seen.

Stochastic update for

As with , we first collect the sufficient statistics for the distribution on from the documents in sub-batch ,

(24)
(25)

The first value scales up the number of documents in sub-batch that include atom in their subtree; the second value scales up the number of times an atom of higher index value in the same DP is used by a document in sub-batch . The update to the global variational parameters are

(26)
(27)

Again, we see a blending of old information with new.

MethodDataset JACM Psych. Review PNAS
Variational nHDP -5.405 0.012 -5.674 0.019 -6.304 0.003
Variational nCRP (Wang, et al. [2]) -5.433 0.010 -5.843 0.015 -6.574 0.005
Gibbs nCRP (Wang, et al. [2]) -5.392 0.005 -5.783 0.015 -6.496 0.007
TABLE II: Comparison of the nHDP with the nCRP in the batch inference setting using the predictive log likelihood.

5 Experiments

We present an empirical evaluation of the nested HDP topic model in the stochastic and the batch inference settings. We first present batch results on three smaller data sets to verify that our multi-path approach gives an improvement over the single-path nested CRP. We then move to the stochastic inference setting, where we perform experiments on 1.8 million documents from The New York Times and 2.7 million documents from Wikipedia. We compare with other recent stochastic inference algorithms for topic models: stochastic LDA [9] and the stochastic HDP [10]. As is fairly standard with the optimization-based variational inference, we use truncated stick-breaking processes for all DPs [25][26]. With this method, we truncate the posterior approximation by not allowing words to come from topics beyond the truncation index (i.e., fixing for all ). The truncation is set to something reasonably large, and the posterior inference procedure then shrinks the number of used topics to something smaller than the number provided. In our large-scale experiments, we truncate to first level nodes, children for each of these nodes and children of each of these second level nodes. We consider three level trees, corresponding intuitively to “general”, “specific” and “specialized” levels of words. Though the nHDP is nonparametric in level as well, we are more interested in the nonparametric aspect of the Dirichlet process here.

5.1 Initialization

Before presenting our results, we discuss our method for initializing the topic distributions of the tree. As with most Bayesian models, inference for hierarchical topic models can benefit greatly from a good initialization. Our goal is to find a method for quickly centering the posterior mean of each topic so that they contain some information about their hierarchical relationships. We briefly discuss our approach for initializing the global variational topic parameters of the nHDP.

Using a small set of documents (e.g, 10,000) from the training set, we form the empirical distribution for each document on the vocabulary. We then perform k-means clustering of these probability vectors using the

distance measure (i.e., total variation). At the top level, we partition the data into groups, corresponding to children of the root node from the truncated stick-breaking process. We then subtract the mean of a group (a probability vector) from all data within that group, set any negative values to zero and renormalize. We loosely think of this as the “probability of what remains”—a distribution on words not captured by the parent distributions. Within each group we again perform k-means clustering, obtaining probability vectors for each of the groups, and again subtracting, setting negative values to zero and renormalizing the remainder of each probability vector for a document.

Through this hierarchical k-means clustering, we obtain probability vectors at the top level, probability vectors beneath each top-level vector for the second level, probability vectors beneath each of these second-level vectors, etc. The vectors obtained from any sub-group of data are refinements of an already coherent sub-group of data, since that sub-group is itself a cluster from a larger group. Therefore, the resulting tree will have some thematic coherence. The clusters from this algorithm are used to initialize the nodes within the nHDP tree. For a mean probability vector obtained from this algorithm, we set the corresponding variational parameter for the topic Dirichlet distribution to for , a scaling factor and . This initializes the mean of to be slightly peaked around , while the uniform vector and

help determine the variance and

provides some randomness. In our algorithms we set and equal to the number of documents.

5.2 A batch comparison

Before comparing our stochastic inference algorithm for the nHDP with similar algorithms for LDA and the HDP, we compare a batch version with the nCRP on three smaller data sets. This will verify the advantage of giving each document access to the entire tree versus forcing each document to follow one path. We compare the variational nHDP topic model with both the variational nCRP [2] and the Gibbs sampling nCRP [4], using the parameter settings in those papers to facilitate comparison. We consider three corpora for our experiments: () The Journal of the ACM, a collection of 536 abstracts from the years 1987–2004 with vocabulary size 1,539; () The Psychological Review, a collection of 1,272 abstracts from the years 1967–2003 with vocabulary size 1,971; and () The Proceedings of the National Academy of Science, a collection of 5,000 abstracts from the years 1991–2001 with a vocabulary size of 7,762. The average number of words per document for the three corpora are 45, 108 and 179, respectively.

As mentioned, variational inference for Dirichlet process priors uses a truncation of the variational distribution, which limits the number of topics that are learned [25][26]. This truncation is set to a number larger than the anticipated number of topics necessary for modeling the data set, but can be increased if more are needed [27]. We use a truncated tree of for modeling these corpora, where 10 children of the root node each have 7 children, which themselves each have 5 children for a total of 420 nodes. Because these three data sets contain stop words, we follow [2] and [4] by including a root node shared by all documents for this batch problem only. Following [2], we perform five-fold cross validation to evaluate performance on each corpus.

We present our results in Table II, where we show the predictive log likelihood on a held-out test set. We see that for all data sets, the variational nHDP outperforms the variational nCRP. For the two larger data sets, the variational nHDP also outperforms Gibbs sampling for the nCRP. Given the relative sizes of these corpora, we see that the benefit of learning a per-document distribution on the full tree rather than a shared distribution on paths appears to increase as the corpus size and document size increase. Since we are interested in the “Big Data” regime, this strongly hints at an advantage of our nHDP approach over the nCRP. We omit a comparison with Gibbs nHDP since MCMC methods are not amenable to large data sets for this problem.

Fig. 2: The New York Times: Average predictive log likelihood on a held-out test set as a function of training documents seen.
Fig. 4: The New York Times: Per-document statistics from the test set using the tree at the final step of the algorithm. (left) The average number of words per tree level. (right) The average number of nodes per level with more than one expected observation.
Fig. 3: New York Times: The total size of the tree as a function of documents seen. We show the smallest number of nodes containing 95%, 99% and 99.9% of the posterior mass.
Fig. 4: The New York Times: Per-document statistics from the test set using the tree at the final step of the algorithm. (left) The average number of words per tree level. (right) The average number of nodes per level with more than one expected observation.
Fig. 5: New York Times: The adaptively learned step size.
Fig. 3: New York Times: The total size of the tree as a function of documents seen. We show the smallest number of nodes containing 95%, 99% and 99.9% of the posterior mass.

5.3 Stochastic inference for large corpora

We next present an evaluation of our stochastic variational inference algorithm on The New York Times and Wikipedia. These are both very large data sets, with The New York Times containing roughly 1.8 million articles and Wikipedia roughly 2.7 million web pages. The average document size is somewhat larger than those considered in our batch experiments as well, with an article from The New York Times containing 254 words on average taken from a vocabulary size of 8,000, and Wikipedia 164 words on average taken from a vocabulary size of 7,702. For this problem we remove stop words and rare words.

Fig. 6: Tree-structured topics from The New York Times. The shaded node is the top-level node and lines indicate dependencies within the tree. In general, topics are learning in increasing levels of specificity. For clarity, we have removed grammatical variations of the same word, such as “scientist” and “scientists.”

5.3.1 Setup

We use the algorithm discussed in Section 5.1 to initialize a three-level tree with child nodes per level, giving a total of 1,220 initial topics. For the Dirichlet processes, we set all top-level DP concentration parameters to and the second-level DP concentration parameters to . For the switching probabilities

, we set the beta distribution hyperparameters for the tree level prior to

and , slightly encouraging a word to continue down the tree. We set the base Dirichlet parameter . For our greedy subtree selection algorithm, we stop adding nodes to the subtree when the marginal improvement to the lower bound falls below . When optimizing the local variational parameters of a document given its subtree, we continue iterating until the fractional change in the distance of the empirical distribution of words falls below .

We hold out a data set for each corpus for testing, 14,268 documents for testing The New York Times and 8,704 documents for testing Wikipedia. To quantitatively assess the performance, at various points in the learning process we calculate the predictive log likelihood on a fraction of the test set as follows: Holding the top-level variational parameters fixed, for each test document we randomly partition the words into a 90/10 percent split. We then learn document-specific variational parameters for the 90% portion. Following [28][2], we use the mean of each distribution to form a predictive distribution for the remaining words of that document. With this distribution, we calculate the average predictive log likelihood of the 10% portion to assess performance. For comparison, we evaluate stochastic inference algorithms for LDA and the HDP in the same manner. In all algorithms, we use an algorithm for adaptively learning the step size as presented by Ranganath, et al. [29].

Fig. 7: Wikipedia: Average predictive log likelihood on a held-out test set as a function of training documents seen.
Fig. 9: Wikipedia: Per-document statistics from the test set using the tree at the final step of the algorithm. (left) The average number of words per tree level. (right) The average number of nodes per level with more than one expected observation.
Fig. 8: Wikipedia: The total size of the tree as a function of documents seen. We show the smallest number of nodes containing 95%, 99% and 99.9% of the posterior mass.
Fig. 9: Wikipedia: Per-document statistics from the test set using the tree at the final step of the algorithm. (left) The average number of words per tree level. (right) The average number of nodes per level with more than one expected observation.
Fig. 10: Wikipedia: The adaptively learned step size.
Fig. 8: Wikipedia: The total size of the tree as a function of documents seen. We show the smallest number of nodes containing 95%, 99% and 99.9% of the posterior mass.
Fig. 11: Examples of subtrees for three articles from Wikipedia. The three sizes of font indicate differentiate the more probable topics from the less probable.

5.3.2 The New York Times

We first present our results for The New York Times. In Figure 2 we show the average predictive log likelihood on unseen words as a function of the number of documents processed during model learning. We see an improvement in performance as the amount of data processed increases. We also note an improvement in the performance of the nHDP compared with LDA and the HDP. In Figure 5 we give a sense of the size of the tree as a function of documents seen. Since all topics aren’t used equally, we show the minimum number of nodes containing , and of all data in the posterior. In Figure 5 we show document-level statistics from the test set at the final step of the algorithm. These include the word allocations by level and the number of topics used per level. We note that while the tree has three levels, roughly 12 topics are being used (in varying degrees) per document. This is in contrast to the three topics that would be available to any document with the nCRP. Thus there is a clear advantage in allowing each document to have access to the entire tree. We show the adaptively learned step size in Figure 5.

In Figure 6 we show example topics from the model and their relative structure. For each node we show the most probable words according to the approximate posterior distribution of the topic. We show four topics from the top level of the tree (shaded), and connect topics according to parent/child relationship. The model learns a meaningful hierarchical structure; for example, the sports subtree branches into the various sports, which themselves appear to branch by teams. In the foreign affairs subtree, children tend to group by major subregion and then branch out into subregion or issue. If a sports document incorporated topics on foreign affairs, the nHDP would allow words to split into both parts of the tree, but with the nCRP a document would have to pick one or the other, and so a tree could not be learned that distinguished topics with this level of precision.

The algorithm took roughly 20 hours to make one pass through the data set using a single desktop computer, which was sufficient for the model to converge to a set of topics. Runtime for Wikipedia was comparable.

5.3.3 Wikipedia

We show similar results for Wikipedia as for The New York Times. In Figures 7, 10, 10 and 10 we show results corresponding to Figures 2, 5, 5 and 5, respectively for The New York Times. We again see an improvement in performance for the nHDP over LDA and the HDP, as well as the increased usage of the tree with the nHDP than would be available in the nCRP.

In Figure 11, we see example subtrees used by three documents. We note that the topics contain many more function words than for The New York Times, but an underlying hierarchical structure is uncovered that would be unlikely to arise along one path, as the nCRP would require. As with The New York Times, we see the nonparametric nature of the model in Figure 10. Though the model has an 1,220 initial nodes, a small subset are ultimately used by the data.

5.3.4 Sensitivity analysis

We present a brief sensitivity analysis of some parameters of the nHDP topic model using the Wikipedia corpus. In general, we find that the results were not sensitive to the parameter of the base Dirichlet distribution, which is consistent with [8]. We note that this is typically not the case for topic models, but because of the massive quantity of data we are working with, the data overwhelms the prior in this case. This was similarly found with the global DP parameter .

The document-specific variables have a more significant impact since they only use the data from a single document in their posteriors. In Figures 1214 we show the sensitivity of the model to the parameters and . We consider several values for these parameters, holding . As can be seen, the model structure is fairly robust to these values. The tree structure does respond as would be expected from the prior, but there is no major change. The quantitative results in Figure 14 indicate that the quality of the model is robust as well. We note that this relative insensitivity is within a parameter range that we believe a priori to be reasonable.

Fig. 12: Wikipedia: Sensitivity to parameter vector for the stochastic switches. We show the results from Figure 10 for different settings with .
Fig. 13: Wikipedia: Sensitivity to parameter vector for the local DPs. We show the results from Figure 10 for different settings and .
Fig. 14: Wikipedia: Sensitivity to with (left), and with (right). We show the predictive log likelihood on the test set.

6 Conclusion

We have presented the nested hierarchical Dirichlet process (nHDP), an extension of the nested Chinese restaurant process (nCRP) that allows each observation to follow its own path to a topic in the tree. Starting with a stick-breaking construction for the nCRP, the new model samples document-specific path distributions for a shared tree using a nested hierarchy of Dirichlet processes. By giving a document access to the entire tree, we are able to borrow thematic content from various parts of the tree in constructing a document. We developed a stochastic variational inference algorithm that is scalable to very large data sets. We compared the stochastic nHDP topic model with stochastic LDA and HDP and showed how the nHDP can learn meaningful topic hierarchies.

References

  • [1] D. Blei, T. Griffiths, and M. Jordan, “Hierarchical topic models and the nested Chinese restaurant process,” in Advances in Neural Information Processing Systems, 2003.
  • [2] C. Wang and D. Blei, “Variational inference for the nested Chinese restaurant process,” in Advances in Neural Information Processing Systems, 2009.
  • [3] J. H. Kim, D. Kim, S. Kim, and A. Oh, “Modeling topic hierarchies with the recursive Chinese restaurant process,” in International Conference on Information and Knowledge Management (CIKM), 2012.
  • [4] D. Blei, T. Griffiths, and M. Jordan, “The nested Chinese restaurant process and Bayesian nonparametric inference of topic hierarchies,” Journal of the ACM, vol. 57, no. 2, pp. 7:1–30, 2010.
  • [5] Y. Teh, M. Jordan, M. Beal, and D. Blei, “Hierarchical Dirichlet processes,” Journal of the American Statistical Association, vol. 101, no. 476, pp. 1566–1581, 2006.
  • [6] D. Blei, A. Ng, and M. Jordan, “Latent Dirichlet allocation,”

    Journal of Machine Learning Research

    , vol. 3, pp. 993–1022, 2003.
  • [7] M. Jordan, “Message from the President: The era of Big Data,” ISBA Bulletin, vol. 18, no. 2, pp. 1–3, 2011.
  • [8] M. Hoffman, D. Blei, C. Wang, and J. Paisley, “Stochastic variational inference,” Journal of Machine Learning Research, vol. 14, pp. 1303–1347, 2013.
  • [9] M. Hoffman, D. Blei, and F. Bach, “Online learning for latent Dirichlet allocation,” in Advances in Neural Information Processing Systems, 2010.
  • [10] C. Wang, J. Paisley, and D. Blei, “Online learning for the hierarchical Dirichlet process,” in

    Proceedings of the 14th International Conference on Artificial Intelligence and Statistics (AISTATS)

    , vol. 15, 2011, pp. 752–760.
  • [11] T. Ferguson, “A Bayesian analysis of some nonparametric problems,” The Annals of Statistics, vol. 1, pp. 209–230, 1973.
  • [12] D. Blackwell and J. MacQueen, “Ferguson distributions via Pólya urn schemes,” Annals of Statistics, vol. 1, no. 2, pp. 353–355, 1973.
  • [13] J. Sethuraman, “A constructive definition of Dirichlet priors,” Statistica Sinica, vol. 4, pp. 639–650, 1994.
  • [14] D. Aldous, Exchangeability and Related Topics, ser. Ecole d’Eté de Probabilités de Saint-Flour XIII-1983 pages 1-198.   Springer, 1985.
  • [15] A. Rodriguez, D. Dunson, and A. Gelfand, “The nested Dirichlet process,” Journal of the American Statistical Association, vol. 103, pp. 1131–1154, 2008.
  • [16] L. Ren, L. Carin, and D. Dunson, “The dynamic hierarchical Dirichlet process,” in International Conference on Machine Learning, 2008.
  • [17] E. Airoldi, D. Blei, S. Fienberg, and E. Xing, “Mixed membership stochastic blockmodels,” Journal of Machine Learning Research, vol. 9, pp. 1981–2014, 2008.
  • [18] E. Fox, E. Sudderth, M. Jordan, and A. Willsky, “A sticky HDP-HMM with application to speaker diarization,” Annals of Applied Statistics, vol. 5, no. 2A, pp. 1020–1056, 2011.
  • [19] R. Adams, Z. Ghahramani, and M. Jordan, “Tree-structured stick breaking for hierarchical data,” in Advances in Neural Information Processing Systems, 2010.
  • [20] M. Sato, “Online model selection based on the variational Bayes,” Neural Computation, vol. 13, no. 7, pp. 1649–1681, 2001.
  • [21]

    J. Paisley, C. Wang, and D. Blei, “The discrete infinite logistic normal distribution,”

    Bayesian Analysis, vol. 7, no. 2, pp. 235–272, 2012.
  • [22] M. Jordan, Z. Ghahramani, T. Jaakkola, and L. Saul, “An introduction to variational methods for graphical models,” Machine Learning, vol. 37, pp. 183–233, 1999.
  • [23] J. Winn and C. Bishop, “Variational message passing,” Journal of Machine Learning Research, vol. 6, pp. 661–694, 2005.
  • [24] S. Amari, “Natural gradient works efficiently in learning,” Neural Computation, vol. 10, no. 2, pp. 251–276, 1998.
  • [25] D. Blei and M. Jordan, “Variational inference for Dirichlet process mixtures,” Bayesian Analysis, vol. 1, no. 1, pp. 121–144, 2005.
  • [26] K. Kurihara, M. Welling, and N. Vlassis, “Accelerated variational DP mixture models,” in Advances in Neural Information Processing Systems 19, 2006, pp. 761–768.
  • [27] C. Wang and D. Blei, “Truncation-free online variational inference for Bayesian nonparametric models,” in Advances in Neural Information Processing Systems, 2012.
  • [28] Y. Teh, K. Kurihara, and M. Welling, “Collapsed variational inference for HDP,” in Advances in Neural Information Processing Systems, 2008.
  • [29] R. Ranganath, C. Wang, D. Blei, and E. Xing, “An adaptive learning rate for stochastic variational inference,” in International Conference on Machine Learning, 2013.