Latent Dirichlet allocation


In natural language processing, the latent Dirichlet allocation is a generative statistical model that allows sets of observations to be explained by unobserved groups that explain why some parts of the data are similar. For example, if observations are words collected into documents, it posits that each document is a mixture of a small number of topics and that each word's presence is attributable to one of the document's topics. LDA is an example of a topic model and belongs to the machine learning toolbox and in wider sense to the artificial intelligence toolbox.

History

In the context of population genetics, LDA was proposed by J. K. Pritchard, M. Stephens and P. Donnelly in 2000.
LDA was applied in machine learning by David Blei, Andrew Ng and Michael I. Jordan in 2003.

Overview

Evolutionary biology and bio-medicine

In evolutionary biology and bio-medicine, the model is used to detect the presence of structured genetic variation in a group of individuals. The model assumes that alleles carried by individuals under study have origin in various extant or past populations. The model and various inference algorithms allow scientists to estimate the allele frequencies in those source populations and the origin of alleles carried by individuals under study. The source populations can be interpreted ex-post in terms of various evolutionary scenarios.
In association studies, detecting the presence of genetic structure is considered a necessary preliminary step to avoid confounding.

Engineering

One example of LDA in engineering is to automatically classify documents and estimate their relevance to various topics.
In LDA, each document may be viewed as a mixture of various topics where each document is considered to have a set of topics that are assigned to it via LDA. This is identical to probabilistic latent semantic analysis, except that in LDA the topic distribution is assumed to have a sparse Dirichlet prior. The sparse Dirichlet priors encode the intuition that documents cover only a small set of topics and that topics use only a small set of words frequently. In practice, this results in a better disambiguation of words and a more precise assignment of documents to topics. LDA is a generalization of the pLSA model, which is equivalent to LDA under a uniform Dirichlet prior distribution.
For example, an LDA model might have topics that can be classified as CAT_related and DOG_related. A topic has probabilities of generating various words, such as milk, meow, and kitten, which can be classified and interpreted by the viewer as "CAT_related". Naturally, the word cat itself will have high probability given this topic. The DOG_related topic likewise has probabilities of generating each word: puppy, bark, and bone might have high probability. Words without special relevance, such as "the", will have roughly even probability between classes. A topic is neither semantically nor epistemologically strongly defined. It is identified on the basis of automatic detection of the likelihood of term co-occurrence. A lexical word may occur in several topics with a different probability, however, with a different typical set of neighboring words in each topic.
Each document is assumed to be characterized by a particular set of topics. This is similar to the standard bag of words model assumption, and makes the individual words exchangeable.

Model

With plate notation, which is often used to represent probabilistic graphical models, the dependencies among the many variables can be captured concisely. The boxes are "plates" representing replicates, which are repeated entities. The outer plate represents documents, while the inner plate represents the repeated word positions in a given document; each position is associated with a choice of topic and word. The variable names are defined as follows:
The fact that W is grayed out means that words are the only observable variables, and the other variables are latent variables.
As proposed in the original paper, a sparse Dirichlet prior can be used to model the topic-word distribution, following the intuition that the probability distribution over words in a topic is skewed, so that only a small set of words have high probability. The resulting model is the most widely applied variant of LDA today. The plate notation for this model is shown on the right, where denotes the number of topics and are -dimensional vectors storing the parameters of the Dirichlet-distributed topic-word distributions.
It is helpful to think of the entities represented by and as matrices created by decomposing the original document-word matrix that represents the corpus of documents being modeled. In this view, consists of rows defined by documents and columns defined by topics, while consists of rows defined by topics and columns defined by words. Thus, refers to a set of rows, or vectors, each of which is a distribution over words, and refers to a set of rows, each of which is a distribution over topics.

Generative process

To actually infer the topics in a corpus, we imagine a generative process whereby the documents are created, so that we may infer, or reverse engineer, it. We imagine the generative process as follows. Documents are represented as random mixtures over latent topics, where each topic is characterized by a distribution over all the words. LDA assumes the following generative process for a corpus consisting of documents each of length :
1. Choose, where and
is a Dirichlet distribution with a symmetric parameter which typically is sparse
2. Choose, where and typically is sparse
3. For each of the word positions, where, and
The lengths are treated as independent of all the other data generating variables. The subscript is often dropped, as in the plate diagrams shown here.

Definition

A formal description of LDA is as follows:
VariableTypeMeaning
integernumber of topics
integernumber of words in the vocabulary
integernumber of documents
integernumber of words in document d
integertotal number of words in all documents; sum of all values, i.e.
positive realprior weight of topic k in a document; usually the same for all topics; normally a number less than 1, e.g. 0.1, to prefer sparse topic distributions, i.e. few topics per document
K-dimensional vector of positive realscollection of all values, viewed as a single vector
positive realprior weight of word w in a topic; usually the same for all words; normally a number much less than 1, e.g. 0.001, to strongly prefer sparse word distributions, i.e. few words per topic
V-dimensional vector of positive realscollection of all values, viewed as a single vector
probability probability of word w occurring in topic k
V-dimensional vector of probabilities, which must sum to 1distribution of words in topic k
probability probability of topic k occurring in document d
K-dimensional vector of probabilities, which must sum to 1distribution of topics in document d
integer between 1 and Kidentity of topic of word w in document d
N-dimensional vector of integers between 1 and Kidentity of topic of all words in all documents
integer between 1 and Videntity of word w in document d
N-dimensional vector of integers between 1 and Videntity of all words in all documents

We can then mathematically describe the random variables as follows:

Inference

Learning the various distributions is a problem of statistical inference.

Monte Carlo simulation

The original paper by Pritchard et al. used approximation of the posterior distribution by Monte Carlo simulation.
Alternative proposal of inference techniques include Gibbs sampling.

Variational Bayes

The original ML paper used a variational Bayes approximation of the posterior distribution;

Likelihood maximization

A direct optimization of the likelihood with a block relaxation algorithm proves to a fast alternative to MCMC.

Unknown number of populations/topics

In practice, the most adequate number of populations or topics is not known beforehand. It can be estimated by estimation of the posterior distribution with

Alternative approaches

Alternative approaches include expectation propagation.
Recent research has been focused on speeding up the inference of latent Dirichlet Allocation to support the capture of a massive number of topics in a large number of documents. The update equation of the collapsed Gibbs sampler mentioned in the earlier section has a natural sparsity within it that can be taken advantage of. Intuitively, since each document only contains a subset of topics, and a word also only appears in a subset of topics, the above update equation could be rewritten to take advantage of this sparsity.
In this equation, we have three terms, out of which two of them are sparse, and the other is small. We call these terms and respectively. Now, if we normalize each term by summing over all the topics, we get:
Here, we can see that is a summation of the topics that appear in document, and is also a sparse summation of the topics that a word is assigned to across the whole corpus. on the other hand, is dense but because of the small values of &, the value is very small compared to the two other terms.
Now, while sampling a topic, if we sample a random variable uniformly from, we can check which bucket our sample lands in. Since is small, we are very unlikely to fall into this bucket; however, if we do fall into this bucket, sampling a topic takes time. However, if we fall into the other two buckets, we only need to check a subset of topics if we keep a record of the sparse topics. A topic can be sampled from the bucket in time, and a topic can be sampled from the bucket in time where and denotes the number of topics assigned to the current document and current word type respectively.
Notice that after sampling each topic, updating these buckets is all basic arithmetic operations.

Aspects of computational details

Following is the derivation of the equations for collapsed Gibbs sampling, which means s and s will be integrated out. For simplicity, in this derivation the documents are all assumed to have the same length. The derivation is equally valid if the document lengths vary.
According to the model, the total probability of the model is:
where the bold-font variables denote the vector version of the variables. First, and need to be integrated out.
All the s are independent to each other and the same to all the s. So we can treat each and each separately. We now focus only on the part.
We can further focus on only one as the following:
Actually, it is the hidden part of the model for the document. Now we replace the probabilities in the above equation by the true distribution expression to write out the explicit equation.
Let be the number of word tokens in the document with the same word symbol assigned to the topic. So, is three dimensional. If any of the three dimensions is not limited to a specific value, we use a parenthesized point to
denote. For example, denotes the number of word tokens in the document assigned to the topic. Thus, the right most part of the above equation can be rewritten as:
So the integration formula can be changed to:
Clearly, the equation inside the integration has the same form as the Dirichlet distribution. According to the Dirichlet distribution,
Thus,
Now we turn our attention to the part. Actually, the derivation of the part is very similar to the part. Here we only list the steps of the derivation:
For clarity, here we write down the final equation with both and integrated out:
The goal of Gibbs Sampling here is to approximate the distribution of. Since is invariable for any of Z, Gibbs Sampling equations can be derived from directly. The key point is to derive the following conditional probability:
where denotes the hidden variable of the word token in the document. And further we assume that the word
symbol of it is the word in the vocabulary. denotes all the s but. Note that Gibbs Sampling needs only to sample a value for, according to the above probability, we do not need the exact value of
but the ratios among the probabilities that can take value. So, the above equation can be simplified as:
Finally, let be the same meaning as but with the excluded. The above equation can be further simplified leveraging the property of gamma function. We first split the summation and then merge it back to obtain a -independent summation, which could be dropped:
Note that the same formula is derived in the article on the, as part of a more general discussion of integrating Dirichlet distribution priors out of a Bayesian network.

Related problems

Related models

Topic modeling is a classic solution to the problem of information retrieval using linked data and semantic web technology. Related models and techniques are, among others, latent semantic indexing, independent component analysis, probabilistic latent semantic indexing, non-negative matrix factorization, and Gamma-Poisson distribution.
The LDA model is highly modular and can therefore be easily extended. The main field of interest is modeling relations between topics. This is achieved by using another distribution on the simplex instead of the Dirichlet. The Correlated Topic Model follows this approach, inducing a correlation structure between topics by using the logistic normal distribution instead of the Dirichlet. Another extension is the hierarchical LDA, where topics are joined together in a hierarchy by using the nested Chinese restaurant process, whose structure is learnt from data. LDA can also be extended to a corpus in which a document includes two types of information, as in the LDA-dual model.
Nonparametric extensions of LDA include the hierarchical Dirichlet process mixture model, which allows the number of topics to be unbounded and learnt from data.
As noted earlier, pLSA is similar to LDA. The LDA model is essentially the Bayesian version of pLSA model. The Bayesian formulation tends to perform better on small datasets because Bayesian methods can avoid overfitting the data. For very large datasets, the results of the two models tend to converge. One difference is that pLSA uses a variable to represent a document in the training set. So in pLSA, when presented with a document the model hasn't seen before, we fix —the probability of words under topics—to be that learned from the training set and use the same EM algorithm to infer —the topic distribution under. Blei argues that this step is cheating because you are essentially refitting the model to the new data.

Spatial models

In evolutionary biology, it is often natural to assume that the geographic locations of the individuals observed bring some information about their ancestry. This is the rational of various models for geo-referenced genetic data
Variations on LDA have been used to automatically put natural images into categories, such as "bedroom" or "forest", by treating an image as a document, and small patches of the image as words; one of the variations is called Spatial Latent Dirichlet Allocation.