Month: October 2014

Different from Topic Modeling (which analyzes the topic of documents), Linked Documents Analysis (or Topic Modeling with Links) changes the problem setting by considering the links among documents. The goal is still similar, which is to analyze the topic of documents, expect that sometime we may also want to predict the presence of some queried link. The basic idea behind Linked Document Analysis is that, on one hand, link existence can provide some useful information on the topic distribution, on the other hand, topic distribution can also provide useful information on link existence; in other words, they are correlated. In this post, I am going to review some existing work on topic modeling with links. Basically they can be categorized into generative approaches and discriminative approaches, while former tries to explain why link existing or non-existing by topic/membership distributions of nodes, and the latter tries to utilize existing links in a discriminative way to better model topic/membership distributions.

Generative Approaches

Citation Influence Model [1]: The basic idea is that if a document has cited others, the way it generates the topics for word occurrences is either (1) draw from the topic distribution of its cited documents, or (2) draw from its own topic distribution. Other similar models that utilize the citation as a pathway of drawing topic assignments: [2].

PHITS+PLSA [3, 4]: it treats each document as “words” when performing link generation, it is like PLSA twice, once on document-word, once on document-document. This method was later extended into “Link-LDA“, which puts a prior on topic distribution extending PLSA to LDA. Both models suffer from not (explicitly) utilizing word topical information for link analysis, link analysis is purely based on the information of link co-occurrence, and also fails to model the topical dependence between the cited and citing documents explicitly.

Link-PLSA-LDA[4]: overcoming the difficulties in PHITS+PLSA and “Link-LDA” by connecting word in topic-word and document topic-document by symmetric parametrization of merged cited documents.

LDA+MMSB[5]: this may be the most natural generative process for both words and links, it doesn’t treat documents as some kind of dictionaries as in PHITS+PLSA and Link-PLSA-LDA, and thus can be generalized easily to new documents without previously seen links. However, due to the generative process, this model may not be scale-friendly (though some subsampling techniques might help alleviate the computational complexity).

LDA+ZAlign (RTM[6]): defining link probability according to the alignment of latent variables Z. the alignment is quantified by dot production, and the transformation from alignment to probability is through either a Sigmoid function or an Exponential function. The authors pointed out an common weakness of previous models (PHITS+PLSA, Link-PLSA-LDA, LDA+MMSB) that due to their underlying exchangeability assumptions, they might divide the topics into two independent subsets, and allow for links to be explained by one subset of topics, and the words to be explained by the other; to improve over this, they enforce the word and link are draw from the same set of topic assignments. In terms of scalability, since it also has to consider both existing and non-existing links, it is also not scale-friendly.

Discriminative Approaches

PLSA+Reg (NetPLSA[8]): adding regularization loss, acts like smoothing, on to original PLSA (log-)likelihood. This model can easily deal weighted links.

PLSA+Cond (iTopicModel[9]): defining a condition of given its neighbors, which leads to an likelihood of configuration given network of documents, then add this conditioned log-likelihood as a smoothing to original PLSA log-likelihood. Compared with PLSA+Reg, samely this model can also easily deal weighted links, differently this model can fit directed networks more naturally, and also it has a closed form solution of so it is much friendly for optimization compared with PLSA+Reg.

Mixed Membership Stochastic Blockmodels (MMSB)[1] is a generative model for links in a network. Simply put, give an adjacency matrix , MMSB assume is governed by the memberships/topics of each nodes. Since the original paper[1] only introduced the Variational Inference, this post derives a Gibbs Sampling method for the purpose of parameter estimation in MMSB (actually the MMSB presented in this post is slightly different from[1], as I put a prior on interaction matrix ).

The generative process of MMSB is given below:

For each node :

Draw a membership distribution vector

For each entry in :

Draw

For each pair of nodes :

Draw a membership

Draw a membership

Draw

Here is a simple explanation for the notations:

is (number of topics) dimensional hyperparameter for membership/topic distribution.

are two scalar hyperparameters for .

is the membership/topic distribution for node .

is the interaction probability matrix of memberships.

is the membership of node when it interacts with node (the link can be treated as directional, as well as unidirectional). Note that is abbreviated for .

is the adjacency matrix, each entry is either one or zero.

Later on, I am also going to use the following notations:

is the count of node assigning to membership when it interacts with the rest nodes in the network. For directional network, it can be divided into two sets: and (), the former is the assignment of node when it links to other nodes, the latter is the assignment of node when other nodes link to it.

is the count of linked node pairs with membership assignments and (sum up and if don’t consider direction).

is the count of un-linked node pairs with membership assignment and (sum up and if don’t consider direction).

To perform Gibbs Sampling, we need to find the posterior for joint probability of both data and latent variables . Well, here it is:

(1)

Now that we obtained the joint probability of data and latent variables, we can start to derive the conditioned probability of latent variable as following:

(2)

(3)

Given samples of generated from Gibbs Sampling, parameters can be estimated in the following ways:

For , we have

(4)

E.q. 4 is a Dirichlet p.d.f, using Dirichlet variable property, we get the expectation(mean) of :

For , we have

(5)

E.q. 5 is a Beta p.d.f, using Beta variable property, we get the expectation(mean) of :

One may want to sample multiple de-correlated samples of to calculate the above parameters.

Likelihood and perplexity

Until now, I didn’t mention the formula for calculating the likelihood of data , which can be important some time for testing of convergence (or using ). In [2], the authors mentioned an approximation technique for computing , it is the harmonic mean of a set of values of from samples, where is sampled from the posterior . So that is:

Where

Using the previous derivation, we can easily compute that:

(6)

Where is a constant:

Now with , we can compute in the way:

(7)

Where , is introduced to make log-sum-exp computed correctly, usually we can set .

The likelihood of hold out data sometime is also an useful quantity, it reflects generalized predictive power of the model, and usually it is measured by perplexity, essentially it is the inverse of the geometric mean per-link likelihood. It is defined by:

This term can be evaluated by first hold out some subset of links and non-links, and evaluated by computing:

(8)

Where and are estimated in the training data.

Discussions

The Mixed Membership Stochastic Blockmodels is not scalable as it requires to examining edges (this is a lot even for medium size network with only thousands of nodes!), in sharp contrast to sparse networks as arise more often in real datasets. But in practice, for those non-existing edges, instead of using them all, we can sample a small portion of them, this could effectively reduce the computational complexity, especially for sparse networks where we expect the sample ratio of non-existing edges to be even fewer. However, it is still remained to be examined that the relationship between the loss of performance and sampling ratio of non-existing links.

Also due to the scalability issue, one may consider the MMSB without prior for each document topic distribution, which can be also by EM rather than Gibbs Sampling. Also, one can derive Gibbs Sampling for combined LDA and MMSB [3] in similar ways to Gibbs Sampling for LDA (see here) and MMSB individually (basically key is to derive , where ).

Today Prof Andrew McCallum came Northeastern to give a talk, his topic is probabilistic knowledge base construction, which I am not very familiar with. So instead of learning something from his topics, most inspirations about his talk are actually in research methodology side (which he didn’t talk about much, but I think about a lot).

Proposal of new methodologies/trick for bounding/solving existing problems in existing settings.

Although certain people would have different preferences, but in my point of view, they should be equally treated in the sense of contributions. But in terms of the research style, a research should have certain healthy proportion of their combinations. For application driven research style, very easily, people spend “too many” effort for proposing new real world problems or demands, such that some of the proposed problems are not really contributed in the sense that the real demands are not really that much as claimed and the problem setting are equivalent to some classic problem setting has been proposed at least for a while. For theory driven research, it may run some risks being far away from the real problems/demands; and since they are purely based on a fixed setting of problem, once the setting changed, the theory may be useless for the new settings. So in a short words, application driven research tends to focus more on innovation 1, while theory driven research tends to focus more on innovation 3. But actually in some sense they can be unified or proposing together, which may be called applied theory driven research. This is my favorite one. You don’t want to propose new real problems all the time but using some classic methods on classic settings to solve them, and not a lot of people want to always focus on classic problem settings and find new solutions. A mixed proportion (align theories with real problems and their abstracted settings) of these three levels of innovations are better for certain people, like me..

To further illustrate idea above, I am listing the examples in Andrew’s talk. He is doing many NLP work such as named entity recognition, coreference resolution, etc., these are classical problems with some classical settings, researchers who work on this topic usually need innovation 3, thus they proposed CRF, and other variants. But sometimes the problem settings can also change, when they are faced with the problem of extracting entity relationships, a real demand for building knowledge base, instead of following traditional setting of the problem, which is to first define some schema of the relationship and then learn those relationships for entities, they let the words (mostly verb.) automatically form such relationships, but the learning algorithms need to group them otherwise they are not very useful (e.g. president(Obama, U.S.) and leader(Obama, U.S.) are actually same or similar); by changing the problem settings, the real demands can be better delivered (eventually we need some abstraction from real world to form solvable problem settings, once defined one may not always be reasonable or optimal). Andrew also mentioned something about probabilistic programming languages, maybe this is not his idea, but think of this demand is actually a innovation 1, in which you found that building, debugging over graphical models using “regular” programming language (such as C++, Java, etc.) can be difficult, and demands for designing programming languages to address this issue arises naturally.

Machine Learning and data mining are getting more and more hot in recent year, under the background, many of machine learning classes now are available online. People who are interested in the topics found a lot of lectures cover similar things, but maybe in different level, focus or point of view. So it may not be a bad idea to make a collection of such classes and sort things out a little bit. (Noted that most of the courses listed below have video online, and links attached may not be the newest version of the classes as time goes by; this post will keep updating if I find something more)

Latent Dirichlet Allocation, originally proposed in [1], is a generative graphical model for mining latent topics of texts or any data with similar underlying statistical structures.

The Generative Model

The generative process of words in a document are as following:

For each of the topic:

Choose

For each document in the corpus:

Choose topic distribution .

For each of the word occurrences in the document:

Choose a topic .

Choose a word

Here presents a simple explanation of the notations:

is (number of topics) dimensional hyperparameter for topic distribution.

is (number of words) dimensional hyperparameter for word distribution over a given topic.

is the probability of choosing word given its drawn from topic .

is the topic distribution for document .

is the corresponding topic for the -th word in document .

Later on, I am also going to use the following notations:

, , are the observed words.

, , are the topic assignments for word occurrence.

is a dimensional vector, in which is the count of word in the corpus assigned to topic .

is without counting information at word occurrence at position .

is a dimensional vector, in which is the count of words in document been assigned for topic .

is without counting information at word occurrence at position .

The graphical representation of above generative process is as following (each node represents a random variable, filled with gray when observed, links denote dependences, and rectangle plates mean repetition, i.e. the big plate indicates there are documents like that, the small plate indicates there are occurrences words in each document):

To keep (writing) this note simple, I am not going to explain the generative process in details here.

The Likelihood

What we are interested in this model are random variables , , and maybe . But before going to inferences of these latent random variables, we may first follow the routine and write down the likelihood of the data, i.e.:

(1)

Where

Gibbs Sampling Learning

Gibbs sampling learning for LDA was first proposed in [2]. The learning problem or inference problem targeted by [2] is to estimate and . I didn’t find any good justification yet for using Gibbs sampling for LDA, one justification is that given the valid sample , we estimate , by either maximizing it or getting its expectation/mean (since this expression is a Dirichlet p.d.f., getting its expectation/mean is easy, and in literature this is often the common practice rather than using mode obtained by maximum likelihood) can give us an estimation of , similar procedures hold for as well. However, this justification is not satisfying in the sense that it didn’t consider the distribution of rather than just a sample of it, and it shows nothing about why a sample of will be good enough. By considering the distribution of (which is intractable thus requires sampling methods), one can derive that

(2)

Where each sample is drawn from distribution . Here the expectation/mean is easier to obtain than the mode by maximum likelihood because we have a summation over p.d.f. and the p.d.f. is of Dirichlet distribution. The expectation of a Dirichlet variable from one sample of can be found in book or Wiki, and the expectation of the same variable over a set of samples is just an average of expectations of each sample. Technically, we need to obtain multiple de-correlated samples of as according to E.q. 2, however, one sample may be good enough depends on the data (for example, it can be shown that for , even one sample of , it could contain many times of samples given the same word ).

I think E.q. 2 gives us enough motivation and justification for doing Gibbs sampling on LDA. Basically we need to be able to generate samples from , which is an intractable distribution, one popular way for this purpose is Gibbs sampling, which generates samples from each variable once at a time while others fixed.

Preparing for derivation of Gibbs sampling for LDA, let me first lightlight some important functions (as for the mathematics behind MCMC and Gibbs Sampling, readers can refer to some good tutorials on the Internet):

Dirichlet Distribution:

Multinomial Beta function:

Gamma function:

Multinomial distribution:

Noted that in LDA or many of other bayesian statistical models, people use conjugate distribution for likelihood and prior, e.g., Multinomial and Dirichlet. The trick behind this is that posterior will be the same distribution as the prior, so that we can easily find a closed form for the integration of the posterior. In the case of Multinomial and Dirichlet, we have

Since

i.e.:

This piece of formula is extremely useful for deriving the following learning algorithm. (One more note would be: although people call it multinomial distribution in the generative process above, but actually it is one time multinomial, which has already degenerated into discrete distribution, however, this doesn’t affect much for the learning, as we see the formula here will also hold for a sequence of discrete distribution.)

Then let’s derive the joint distribution of and which will be useful just one step later (notations are explained in the beginning of the post):

(3)

Now we can start to derive key formula for Gibbs sampling, which is , here means the topic assignments for all word occurrences other than the one at position , without loss of generality, we assume here that the position is in document and associated with the observed word , since

We have:

(4)

The above E.q. 4 gives us a very clear picture for implementing Gibbs sampling, basically, one just needs to initialize , setting counter for three terms in final of E.q. 4, and each time when sample a word, decrease the corresponding counters, sample according to normalized E.q. 4, than increase corresponding counters according to the sampling result. After “burn-in”, one can read out (de-correlated) samples and start estimation of parameters. By E.q. 2, bayes’ rule and expectation of Dirichlet Distribution, we obtain the expectation of and given a sample of as following:

(5)

(6)

As mentioned above, one might also want to average parameters over multiple de-correlated samples according to E.q. 2.

Likelihood and perplexity

Until now, I didn’t mention the formula for calculating the likelihood of data , which can be important some time for testing of convergence (or using ). In [2], the authors mentioned an approximation technique for computing , it is the harmonic mean of a set of values of from samples, where is sampled from the posterior . So that is:

Where

Using the previous derivation, we can easily compute that:

(7)

Where we have assumed a symmetric . However, the E.q. 7 can easily lead to numerical underflow/overflow if directly computed (due to the large factorial terms). Here we can take a log of it and see what we got:

(8)

Where is constant:

The log gamma function should be built in the programming language so you can use it directly. But now since we only have , and it can be quite “negatively large” (maybe depending on the corpus), this again create a computational difficulty when we compute the Harmonic average of . Again we are going to log , and using some trick below enable us to compute it accurately:

(9)

Here , is introduced to make log-sum-exp computed correctly, usually we can set . Now, even the corpus contains millions of documents, the above likelihood calculation should still work as the scale is under the range of floating point number.

The likelihood of hold out data sometime is also an useful quantity, it reflects generalized predictive power of the model, and usually it is measured by perplexity, essentially it is the inverse of the geometric mean per-link likelihood. It is defined by:

This term can be evaluated by: first hold out some documents, and then sample topic assignment for words in those documents given a point estimate , then the likelihood (there go the perplexity) of hold out documents can be calculated as stated above.