Evaluating Topic Models

How to tell whether a topic model is good, and how many topics to use. Held-out likelihood and perplexity, human judgments of interpretability, automatic coherence measures such as NPMI, and how perplexity and coherence disagreed about the number of topics in Reuters.

A topic model is judged by three kinds of intrinsic evidence: held-out perplexity, $\exp(-\sum_d \log p(\mathbf{w}_d) / \sum_d N_d)$; human judgments by word and topic intrusion (Chang and colleagues, 2009); and coherence measures such as NPMI that stand in for those judgments. They can disagree. For LDA on Reuters (7,769 training and 3,019 test stories), held-out perplexity by document completion fell at every step from $K = 5$ to $K = 80$, from 1,517 to 1,066. The mean NPMI of each topic's ten top words peaked at 0.251 at $K = 20$ and fell to 0.122 at $K = 80$. scikit-learn's reported perplexity rose with $K$, because its bound includes a term for the topic-word distributions. Topic by topic, NPMI flagged the one junk topic, at −0.329.

Among the twenty Reuters topics of latent Dirichlet allocation was one that no person would call a subject: department, dutch, guilders, credit, hughes. We found it by reading. A number can flag it as well: its coherence score, defined below, is the only negative one among the twenty. No number settles whether twenty topics was the right count. How, then, can we tell whether a topic model is any good?

Not by checking it against a right answer, since a topic model, like a clustering, has none. Yet a model must be judged somehow: to choose the number of topics, to compare algorithms, and to decide whether the topics found are worth reading. Three kinds of evidence are used:

  • how well the model predicts text it has not seen;
  • how interpretable people find its topics;
  • automatic scores designed to stand in for those people.

They do not always agree, and the disagreement is instructive. First we derive perplexity and compute it on the six documents. Then we see how people judge topics, and how coherence measures imitate them, scoring two Reuters topics by hand. Finally we evaluate Reuters with five numbers of topics, where the measures disagree, and set out how the number is chosen in practice.

All three kinds are intrinsic: they judge the model by its own predictions and topics. A fourth kind is extrinsic, judging the topics by how much they help a task such as classification or retrieval. Blei, Ng, and Jordan (2003, §7.2) evaluated LDA that way, using topic proportions as features for classifying Reuters stories. This article's experiments are intrinsic only. They measure held-out perplexity and coherence on Reuters, and the human judgments are quoted from the literature. No experiment on this site measures LDA by a downstream task. The task-based results in this topic are of other kinds: latent semantic indexing is tested by retrieval on Cranfield, and topic models beyond LDA works LDA-based smoothing on the six documents and reports what Wei and Croft (2006) measured on TREC collections.

Held-out likelihood and perplexity

A probabilistic topic model assigns a probability to any document. A good model should assign high probability to new documents from the same source, ones it was not fitted to. That is why the test documents are held out. The standard summary is perplexity, the inverse of the geometric mean probability per word on a held-out set of documents:

$$\mathrm{perplexity} = \exp\left( - \frac{\sum_d \log p(\mathbf{w}_d)}{\sum_d N_d} \right),$$

where $\mathbf{w}_d$ is the sequence of words in held-out document $d$ and $N_d$ its length. Lower is better. A perplexity of 2,000 means the model is, on average, as uncertain about each word as if it were choosing uniformly among 2,000 equally likely words. Blei, Ng, and Jordan (2003, §7.1) used this definition to compare LDA with pLSI and simpler models. Perplexity and Source Coding is the site's home for perplexity: it proves its properties and connects it to the length of a code.

Where the formula comes from

Here is the idea in one sentence: perplexity converts the model's average surprise per word into the number of equally likely words that would be just as surprising. The formula is easier to trust once its steps are separated.

  1. Score the held-out text. The model's log-likelihood of the test set is $\sum_d \log p(\mathbf{w}_d)$. It is negative, and it grows more negative with every additional word, so it cannot be compared between test sets of different sizes.
  2. Average per word. Dividing by the number of words, $\sum_d N_d$, gives the average log-probability per word. If the model gave every word the same probability $p$, this average would be $\log p$.
  3. Undo the logarithm. Exponentiating the average gives the geometric mean probability per word, $\bar{p}$.
  4. Invert. Perplexity is $1/\bar{p}$. For a model that spreads its probability evenly over $m$ words, $\bar{p} = 1/m$ and the perplexity is exactly $m$: perplexity is the size of the uniform choice that would be equally hard to predict.

Two reference points follow. A model that ignores the data and spreads probability evenly over the vocabulary has perplexity $V$. A model that knows each word's overall frequency but nothing about documents, the unigram model, does better. A topic model must beat it to be learning anything about documents.

A worked example

Back to the six documents of latent semantic indexing, with ten word occurrences: ship twice, boat once, ocean twice, voyage three times, trip twice.

Example (the perplexity of a uniform model). A model that gives each of the five words probability $1/5$, whatever the document, has perplexity exactly 5 on these ten words, by step 4: a uniform choice among five words. The first row of the table confirms it. The table scores the same words the models were fitted to:

Model Log-likelihood Perplexity
Uniform over the 5 words $10 \log \tfrac{1}{5} = -16.094$ 5.000
Unigram, $P(w)$ = overall frequency $-15.571$ 4.745
pLSA with 2 topics (best fit) $-10.549$ 2.872
Each document its own word distribution $-6.068$ 1.835

For the unigram row, the probabilities are 0.2, 0.1, 0.2, 0.3, and 0.2. The log-likelihood is $2 \log 0.2 + \log 0.1 + 2 \log 0.2 + 3 \log 0.3 + 2 \log 0.2 = -15.571$, and the perplexity is $e^{15.571/10} = 4.745$. The pLSA row is the fitted model of probabilistic latent semantic analysis. Knowing that a document is about the sea narrows each of its words to about three equally likely choices.

Example (the lowest perplexity is not the best model). The last row gives each document a distribution equal to its own word frequencies, and it has the lowest perplexity of all. It is not the best model. It has learned nothing that would help predict a new document: it gives every word a document did not use probability zero. That is the reason perplexity must be measured on held-out text. On the training words, more parameters always look better. The numbers are from plsa_trace.py in tools/experiments/topics/.

Computing $p(\mathbf{w}_d)$

pLSA's probabilities on the six documents were simple to compute. For LDA, computing $p(\mathbf{w}_d)$ is itself hard, since it requires averaging over all possible topic proportions for the document:

$$p(\mathbf{w}_d) = \int p(\theta \mid \alpha) \prod_{i=1}^{N_d} \sum_k \theta_k\, \phi_{k, w_{d,i}}\, d\theta.$$

The integral cannot be computed for documents of ordinary length. Multiplying out the product of sums gives one term for each assignment of topics to the document's words, $K^{N_d}$ terms in all. Each term has a closed form, by the Dirichlet integral of the LDA article: with $n_k$ the number of words the assignment gives to topic $k$,

$$p(\mathbf{w}_d) = \sum_{z} \frac{B(n_{\cdot} + \alpha)}{B(\alpha)} \prod_{i=1}^{N_d} \phi_{z_i, w_{d,i}}.$$

For the six documents, none longer than three words, the sum can be carried out, and it shows what an approximation costs. With $K = 2$, $\alpha = 0.1$ and the two topics that variational EM fitted in variational inference for LDA, the exact log-probability of the ten words is $-14.766$, a perplexity of $e^{1.4766} = 4.378$. The variational lower bound on the same quantity is $-15.217$, which gives $4.580$. A bound below the log-probability gives a perplexity above the true one. Both are well above pLSA's 2.872 in the table. The topics differ, but that is not the reason: with pLSA's own two topics the LDA log-probability is $-16.151$, against pLSA's $-10.549$. The reason is that LDA averages over the mixtures a document might have had, while pLSA fits one mixture to each training document. For a story of 171 words and 20 topics the sum has $20^{171}$ terms, and it must be estimated. Wallach, Murray, Salakhutdinov, and Mimno (2009) compared methods for estimating it. They found that those in common use, the harmonic mean method most of all, were inaccurate enough to change the outcome of model comparisons. Many implementations, including scikit-learn's, report perplexity computed from a variational lower bound on the likelihood. That gives an upper bound on the true perplexity rather than the value itself. scikit-learn's bound also includes a corpus-wide term for the topic-word distributions, with consequences shown below.

A simpler alternative, used in the Reuters experiment below, is document completion. Split each test document's words in two, and infer the document's topic proportions $\hat{\theta}$ from the first half. Then score the second half with $p(w) = \sum_k \hat{\theta}_k \phi_{k,w}$, which needs no integral. For example, the Reuters test story test/14826 is about Asian exporters' fears of damage from trade friction between the United States and Japan. It has 342 words after preprocessing. Of these, 171 chosen at random, among them japan eight times and trade six times, are used to infer its mixture, and the other 171 are scored.

Perplexity also measures prediction, not meaning. A model can predict words well with topics no person would find sensible. The next section describes how people judge topics.

What people think of the topics

Chang, Boyd-Graber, Gerrish, Wang, and Blei (2009) measured interpretability directly, with two tasks given to people through a crowdsourcing service:

  • Word intrusion. Show the five most probable words of a topic plus one intruder, a word that is probable in another topic but not this one. If the topic is coherent, people readily spot the word that does not belong. If it is a jumble, they guess.
  • Topic intrusion. Show a document's title and opening, three topics prominent in it, and one that is not. People who can spot the intruding topic find the document's assigned topics meaningful.

Building and scoring an item

The construction is precise (Chang and colleagues, 2009, §3). For word intrusion, the intruder is drawn from words with two properties:

  • low probability in the topic, so that it is unlikely to belong to the same subject;
  • high probability in some other topic, so that it cannot be rejected merely for being rare.

The six words are shuffled.

Example (a word-intrusion item). Here is an item built from the Reuters "Oil markets" topic of the LDA article: crude, dividend, gulf, oil, bpd, opec. The intruder is dividend, and most readers would pick it at once. The topic's top five words are oil, opec, bpd, crude, and gulf. Dividend is in the bottom half of the oil topic's words and among the ten most probable words of the dividend and stock-split topics, so it is a valid intruder. Spotting it so easily is evidence that the other five form a subject. For the incoherent topic whose top words are department, dutch, guilders, credit, and hughes, no such choice is obvious.

Each item is shown to several people (eight in the original study). If $\omega$ is the true intruder and $i_s$ the word chosen by person $s$, the topic's model precision is the fraction who found it:

$$\mathrm{MP} = \frac{1}{S} \sum_{s=1}^{S} \mathbf{1}(i_s = \omega).$$

As an illustration of the arithmetic, not a measurement: if seven of eight readers chose dividend, the oil topic would score $7/8 = 0.875$. A topic where readers guess at random among six words would score about $1/6$. No readers were recruited for this article.

Topic intrusion is scored by the topic log odds, the average over people of $\log \hat{\theta}_{d, j^*} - \log \hat{\theta}_{d, j_s}$. Here $j^*$ is the true intruding topic and $j_s$ the one person $s$ chose. The score is 0 when everyone finds the intruder, and more negative the more probable the topics people mistook for it (Chang and colleagues, 2009, eq. 2; model precision is their eq. 1).

What they found

They fitted pLSI, LDA, and the correlated topic model with 50, 100, and 150 topics to New York Times and Wikipedia articles. Their central finding was that held-out likelihood did not predict interpretability and could run against it. The correlated topic model had the best predictive likelihood in most cases, but its topics fared worst with people. Plots of the human scores against likelihood showed no gain, and often a loss, as likelihood improved. A model tuned only for perplexity is not tuned for what most users of topic models want.

Coherence measures

Human evaluation is slow and expensive, so automatic coherence measures were developed to approximate it. Most score a topic by how often its top words occur together in documents. The reasoning is that a coherent topic's words belong to the same subject, and so co-occur.

  • UMass coherence (Mimno, Wallach, Talley, Leenders, and McCallum, 2011) uses co-document frequencies from the collection the model was fitted to. It sums $\log \frac{D(w_i, w_j) + 1}{D(w_j)}$ over ordered pairs of top words with $w_j$ ranked above $w_i$, where $D$ counts documents. The measure is asymmetric.
  • PMI coherence (Newman, Lau, Grieser, and Baldwin, 2010) averages (or takes the median of) the pointwise mutual information between pairs of top words, $\mathrm{PMI}(w_i, w_j) = \log \frac{P(w_i, w_j)}{P(w_i)\,P(w_j)}$, estimated from co-occurrence within a sliding window of ten words over a large external corpus, English Wikipedia. The hand computations below use a different estimate, co-occurrence in the same training story. (Mutual Information defines the pointwise quantity in general; mutual information is its expected value.)
  • NPMI coherence normalizes each pair's PMI by $-\log P(w_i, w_j)$ (Bouma, 2009). It ranges from −1, for words that never appear together, through 0, for independence, to 1, for words that always appear together. Lau, Newman, and Baldwin (2014) found it among the measures that best matched human judgments.

For a topic with top words $w_1, \dots, w_n$, NPMI coherence is the average over pairs:

$$\mathrm{NPMI}(w_i, w_j) = \frac{\log \dfrac{P(w_i, w_j)}{P(w_i)\,P(w_j)}}{-\log P(w_i, w_j)}.$$

Each piece has a reading:

  • The ratio inside the logarithm compares how often the two words share a document with how often they would if they were independent. Its logarithm, the PMI, is positive for words that attract each other.
  • PMI has no fixed scale, since rare pairs can reach large values. So NPMI divides by $-\log P(w_i, w_j)$, the largest value PMI can take for a pair with that joint probability (reached when each word appears only with the other).
  • In the UMass score, $(D(w_i, w_j) + 1) / D(w_j)$ estimates the conditional probability of $w_i$ given $w_j$: the share of documents with the higher-ranked word that also contain the lower-ranked one. The 1 is added so that a pair that never co-occurs gives a finite logarithm.

The formulas are easiest to see on real topics.

Two topics scored by hand

Take the top five words of two topics from the twenty-topic Reuters model in the LDA article. Probabilities are estimated from the 7,769 training stories, by counting the stories that contain each word and each pair (natural logarithms throughout). First, the "Energy production" topic, whose document frequencies are oil 730, gas 275, energy 237, reserves 274, and production 515:

Pair $w_j$, $w_i$ $D(w_j)$, $D(w_i)$ $D(w_i, w_j)$ UMass term PMI NPMI
oil, gas 730, 275 207 −1.256 2.081 0.574
oil, energy 730, 237 147 −1.596 1.887 0.476
gas, energy 275, 237 84 −1.174 2.304 0.509
oil, reserves 730, 274 74 −2.276 1.056 0.227
gas, reserves 275, 274 51 −1.666 1.660 0.330
energy, reserves 237, 274 22 −2.333 0.968 0.165
oil, production 730, 515 169 −1.457 1.251 0.327
gas, production 275, 515 74 −1.299 1.401 0.301
energy, production 237, 515 76 −1.124 1.576 0.341
reserves, production 274, 515 49 −1.701 0.992 0.196

In each pair the first word is the higher-ranked one, the $w_j$ of the UMass definition, whose frequency $D(w_j)$ goes in the UMass denominator. PMI and NPMI do not depend on the order. For the first row:

  • $P(\text{oil}) = 730/7769 = 0.0940$, $P(\text{gas}) = 275/7769 = 0.0354$, and $P(\text{oil}, \text{gas}) = 207/7769 = 0.0266$.
  • The words share a document $0.0266 / (0.0940 \times 0.0354) = 8.0$ times as often as independence would predict, so the PMI is $\log 8.0 = 2.081$.
  • Dividing by $-\log 0.0266 = 3.625$ gives NPMI 0.574.
  • The UMass term is $\log \frac{D(w_i, w_j) + 1}{D(w_j)} = \log(208/730) = -1.256$, with oil as $w_j$.

Over the ten pairs, UMass coherence is the sum, $-15.88$, and NPMI coherence the mean, $0.344$.

Second, the incoherent topic, with top words department (430 stories), dutch (97), guilders (37), credit (342), and hughes (19). Four of its ten pairs never occur in the same story: department with guilders, and hughes with dutch, guilders, and credit.

Example (a pair that never co-occurs). A pair of words that never share a story gets NPMI −1, the bottom of the scale. (Its PMI is the logarithm of zero, and NPMI is defined as −1 in that case, the limit as the joint probability falls to zero.) Such a pair gets a UMass term of $\log(1/D(w_j))$, as low as $\log(1/430) = -6.06$ here. Only dutch and guilders go together (29 shared stories, NPMI 0.740). The topic's UMass coherence is $-37.50$ and its NPMI coherence $-0.282$. Both measures separate the two topics by a wide margin, and they agree on the order. The UMass score, though, has no fixed scale on which to say how good $-15.88$ is.

NPMI for every pair among the top ten words of the two topics. In "Energy production" every pair is positive, most between 0.2 and 0.7. In the incoherent topic 21 of the 45 pairs are −1, words that never share a story. Notice the few strong positive cells, pairs such as "dutch" and "guilders" or "hughes" and "baker" that do belong together, while the common words "department" and "credit" are weakly positive with many others: the topic is several unrelated fragments.
NPMI for every pair among the top ten words of the two topics. In "Energy production" every pair is positive, most between 0.2 and 0.7. In the incoherent topic 21 of the 45 pairs are −1, words that never share a story. Notice the few strong positive cells, pairs such as "dutch" and "guilders" or "hughes" and "baker" that do belong together, while the common words "department" and "credit" are weakly positive with many others: the topic is several unrelated fragments.

With all ten top words, as in the rest of this article, the two topics score 0.391 and −0.329. The pair matrix shows why the second is junk in a way the single number does not. It is not a weak subject but a few strong word pairs, such as dutch and guilders, hughes and baker, and bonus and ccc, that almost never share a story with each other.

Coherence measures are proxies too. Hoyle and colleagues (2021) found that automatic coherence had rarely been validated for newer neural topic models and could disagree with human ratings of them. They recommended that claims of better topics be checked with people.

With perplexity and coherence in hand, both can be run on the whole Reuters collection.

On Reuters

The LDA model of Reuters was fitted with five values of $K$ to the 7,769 training stories, and evaluated on the 3,019 test stories. Held-out perplexity was measured by document completion (Rosen-Zvi, Griffiths, Steyvers, and Smyth, 2004; Wallach, Murray, Salakhutdinov, and Mimno, 2009):

  • each test story's words were split in half at random;
  • the story's topic proportions were inferred from the first half;
  • the second half was scored with the fitted topics, 78,587 words in all from the 3,017 stories long enough to split.

The inferred proportions serve as a point estimate. That is a simpler approximation than the estimators Wallach and colleagues recommend, but one that scores only the held-out words. Coherence is the average NPMI of each topic's ten most probable words, with probabilities estimated from document co-occurrence in the training stories.

Topics $K$ Held-out perplexity (document completion) scikit-learn's reported test perplexity Mean NPMI
5 1,517 2,158 0.203
10 1,339 2,240 0.242
20 1,174 2,376 0.251
40 1,096 2,916 0.208
80 1,066 4,319 0.122

For scale, the same 78,587 held-out words have perplexity 6,855 under the uniform distribution over the vocabulary. Under the unigram distribution of the training stories (with 1 added to each count) they have 2,238. Even five topics cut the unigram perplexity by a third; twenty cut it nearly in half.

Example (the best perplexity is not the best choice of $K$). Held-out perplexity falls at every step of the table, but that does not make 80 topics the best choice for reading the topics. Mean NPMI peaked at 20 topics and fell to 0.122 at 80. A model can keep predicting words better while its topics grow less coherent.

Left: held-out perplexity by number of topics, by document completion (circles) and as reported by scikit-learn (squares), on a log scale of K. Notice that the two measures move in opposite directions. Right: mean NPMI coherence of the top ten words, which rises to a peak at 20 topics and then falls.
Left: held-out perplexity by number of topics, by document completion (circles) and as reported by scikit-learn (squares), on a log scale of K. Notice that the two measures move in opposite directions. Right: mean NPMI coherence of the top ten words, which rises to a peak at 20 topics and then falls.

Three things stand out:

  • Held-out perplexity improved at every step, quickly up to 20 topics and slowly after that. More topics let the model predict new stories' words better, with diminishing returns.
  • scikit-learn's own figure pointed the opposite way. Its perplexity method uses the variational bound on the likelihood of the whole model, which includes a term for the topic-word distributions themselves. That term does not depend on the documents scored and grows with the number of topics. It is divided by the number of words in the test set, so the reported value rises with $K$ for reasons that have nothing to do with prediction. Read naively, it would suggest that five topics is best and that the model overfits. From 10 topics on it is no better than the unigram model's 2,238, a model with no topics at all. (scikit-learn scores the whole test stories rather than their second halves, so the comparison is approximate.) The document-completion measure puts every one of these models well below the unigram model, and shows neither problem.
  • Coherence peaked at 20 topics. With five or ten topics, each topic must cover several subjects, and its top words co-occur less. With 40 or 80, topics fragment into narrow, sometimes accidental word groups.

So the measures disagree much as Chang and colleagues found, with coherence standing in for human judgment. Prediction kept improving as topics were added, while coherence fell after 20. Five topics are too few for a collection with dozens of subjects, so each must combine several. Twenty topics give the readable list in the LDA article. For exploring a collection, which is what most topic models are used for, coherence and inspection pointed to the more useful choice.

The episode also shows why an evaluation number should be understood before it is trusted. The convenient figure from the library would have led to the wrong conclusion.

Scoring individual topics

Back to the junk topic the article opened with, and the claim that a number flags it. Coherence is useful topic by topic, to flag ones not worth reading. Apart from one topic, scores among the twenty ranged from 0.391 for energy production (oil, gas, energy, reserves, production) down to 0.076 for the mixed topic of metals and European currencies. One topic scored −0.329: department, dutch, guilders, credit, hughes, court, baker, bonus, ccc, turkey. These words rarely occur in the same stories, and no person would call them a subject. Coherence flagged exactly the topic that inspection does.

The same measure was applied to LSI on the same stories, scoring the ten terms with the largest positive weight in each of 20 dimensions. It gave a mean of 0.097, against 0.251 for LDA with 20 topics. LSI's dimensions are contrasts between groups of words, not groups of words in their own right. Their top terms are not meant to form a subject, and the score reflects that.

The opening's other claim, that no number settles whether twenty was the right count, is the subject of the last section.

Choosing the number of topics

No method settles $K$. In practice it is chosen by:

  • fitting several values and comparing coherence, held-out likelihood, or both, while expecting them to disagree;
  • reading the topics, since a model with a few junk topics or with obviously merged subjects needs a different $K$;
  • checking stability, refitting with different random starts and seeing whether the same topics reappear, since topics that appear only in some runs should not be trusted (a check this article recommends but did not run on Reuters);
  • letting the purpose decide, since a browsing interface needs few broad topics and a fine-grained analysis many narrow ones.

Nonparametric models, described in topic models beyond LDA, infer the number of topics from the data. They have parameters of their own, though, that influence how many they find.

The experiments are reuters_lda.py, reuters_perplexity.py, reuters_perplexity_baselines.py, and reuters_coherence_hand.py in tools/experiments/topics/ in the site repository, and the figures are drawn by tools/figures/evaluating-topic-models.py. The exact LDA log-probabilities of the six documents are computed in variational-inference-for-lda.py.

Worked problems

The course had no assignment for this topic, and the course text has no exercises on the evaluation of topic models. These four problems are posed on the six documents and on the Reuters counts printed in this article. Their arithmetic is checked in plsa_trace.py.

Problem 1 (document completion by hand). Use the best pLSA fit of the six documents (sea: ship 0.4, boat 0.2, ocean 0.4; travel: voyage 0.6, trip 0.4) to score two held-out documents by document completion, taking the first word as the observed half and the second as the half to be predicted: ship boat, and ship trip.

The perplexity is 5 for ship boat and infinite for ship trip. In both, the observed half is ship. Folding it in with the topics fixed gives a mixture that is entirely sea: ship has probability 0 in the travel topic, so its posterior is 1 for the sea topic whatever the starting mixture, and the mixture becomes $(1, 0)$.

For ship boat, the held-out word has probability $P(\text{boat}) = 1 \times 0.2 + 0 \times 0 = 0.2$. With one held-out word the perplexity is the inverse of its probability, $1/0.2 = 5$, no better than the uniform model.

For ship trip, $P(\text{trip}) = 1 \times 0 + 0 \times 0.4 = 0$. The log-probability is $-\infty$ and the perplexity is infinite. One impossible word is enough to make the held-out score of the whole test set infinite. This is the overfitting of the pLSA article seen through the evaluation measure, and it is the practical reason held-out comparisons need a model that gives no word probability zero, as LDA's pseudo-counts ensure.

Problem 2 (one pair of the incoherent topic). In the 7,769 training stories, dutch occurs in 97, guilders in 37, and both in 29. dutch is the higher-ranked word in the topic. Compute the pair's PMI, NPMI and UMass term, and the UMass term of department (430 stories) with guilders, which never share a story.

The probabilities are $P(\text{dutch}) = 97/7769 = 0.01249$, $P(\text{guilders}) = 37/7769 = 0.00476$ and $P(\text{dutch}, \text{guilders}) = 29/7769 = 0.00373$. The ratio to independence is

$$\frac{29/7769}{(97/7769)(37/7769)} = \frac{29 \times 7769}{97 \times 37} = 62.8,$$

so the two words share a story 63 times as often as chance would have it, and the PMI is $\log 62.8 = 4.140$. The normalizer is $-\log(29/7769) = 5.591$, so $\mathrm{NPMI} = 4.140 / 5.591 = 0.740$, the value quoted above. The UMass term has the higher-ranked word's count in the denominator: $\log \frac{29 + 1}{97} = -1.174$.

For department and guilders the co-document count is 0. The NPMI is $-1$, and the UMass term is $\log \frac{0 + 1}{430} = -6.06$, the lowest term in the topic. One pair of the topic is more strongly associated than any pair in the "Energy production" table, whose largest NPMI is 0.574, and another never co-occurs at all. That is the pattern of fragments that the figure shows.

Problem 3 (scoring the two intrusion tasks). These panels are invented to show the arithmetic; no readers were recruited. Eight readers see a word-intrusion item and six pick the true intruder. Eight readers see a topic-intrusion item for a story whose three shown topics have weights 0.35, 0.33 and 0.19, with an intruding topic of weight 0.002; six pick the intruder and two pick the topic with weight 0.19. Compute the model precision and the topic log odds.

The model precision is the share who found the intruder, $6/8 = 0.75$. For the topic log odds, each reader contributes $\log \hat\theta_{d,j^*} - \log \hat\theta_{d,j_s}$, the log weight of the true intruder minus the log weight of the topic that reader chose. The six who chose the intruder contribute 0. Each of the two who chose the 0.19 topic contributes $\log 0.002 - \log 0.19 = -4.554$. The average over the eight readers is $2 \times (-4.554) / 8 = -1.138$. Had the two chosen the topic with weight 0.35, the score would have been lower still, since mistaking a more prominent topic for the intruder is the worse error.

Problem 4 (from perplexity back to log-probability). In the Reuters table, the 20-topic model has held-out perplexity 1,174 on 78,587 words, and the unigram model has 2,238. Find the average log-probability per word under each, the total held-out log-likelihood of the 20-topic model, and the factor by which the topic model raises the geometric mean probability of a word.

Perplexity is the exponential of minus the average log-probability, so the averages are $-\log 1174 = -7.068$ and $-\log 2238 = -7.713$ nats per word. The total for the topic model is $-7.068 \times 78{,}587$, about $-555{,}500$ (the perplexity is rounded to four figures, so the last digits are not meaningful). The difference of the averages is $0.645$ nats per word, and the geometric mean probability per word is $2238 / 1174 = 1.91$ times the unigram model's. For comparison, the uniform model's average is $-\log 6855 = -8.833$.

What we have learned

Perplexity measures how well a model predicts held-out words; on training words, a model that memorizes each document wins. People judge topics by spotting intruders, and coherence measures stand in for them by counting how often top words share documents. On Reuters, held-out perplexity improved with every added topic while coherence peaked at 20, and coherence singled out the junk topic that reading found. scikit-learn's reported perplexity pointed the wrong way. All of this is intrinsic evidence; LDA was not tested here on a downstream task.

None of these measures removes the need for judgment, and LDA is not the only model they can judge. Topic models beyond LDA describes what came after it, and reports the retrieval experiments in which topic models were used to smooth document models.

References

  • Blei, D. M., Ng, A. Y., and Jordan, M. I. (2003). Latent Dirichlet allocation. Journal of Machine Learning Research, 3, 993–1022. record · 6 pages
  • Bouma, G. (2009). Normalized (pointwise) mutual information in collocation extraction. In Proceedings of the Biennial GSCL Conference, 31–40. record
  • Chang, J., Boyd-Graber, J., Gerrish, S., Wang, C., and Blei, D. M. (2009). Reading tea leaves: How humans interpret topic models. In Advances in Neural Information Processing Systems 22 (NIPS 2009), 288–296. record
  • Hoyle, A., Goel, P., Hian-Cheong, A., Peskov, D., Boyd-Graber, J., and Resnik, P. (2021). Is automated topic model evaluation broken? The incoherence of coherence. In Advances in Neural Information Processing Systems 34 (NeurIPS 2021), 2018–2033. record · 2 pages
  • Lau, J. H., Newman, D., and Baldwin, T. (2014). Machine reading tea leaves: Automatically evaluating topic coherence and topic model quality. In Proceedings of EACL 2014, 530–539. record
  • Mimno, D., Wallach, H. M., Talley, E., Leenders, M., and McCallum, A. (2011). Optimizing semantic coherence in topic models. In Proceedings of EMNLP 2011, 262–272. record
  • Newman, D., Lau, J. H., Grieser, K., and Baldwin, T. (2010). Automatic evaluation of topic coherence. In Proceedings of NAACL-HLT 2010, 100–108. record
  • Rosen-Zvi, M., Griffiths, T., Steyvers, M., and Smyth, P. (2004). The author-topic model for authors and documents. In Proceedings of UAI 2004, 487–494. record · 2 pages
  • Wallach, H. M., Murray, I., Salakhutdinov, R., and Mimno, D. (2009). Evaluation methods for topic models. In Proceedings of ICML 2009, 1105–1112. record
  • Wei, X., and Croft, W. B. (2006). LDA-based document models for ad-hoc retrieval. In Proceedings of SIGIR 2006, 178–185. record · 2 pages

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 11 revisions