Majid Al-RaimiPointwise mutual information and PPMI

ICS 582Lecture 04Part 06

Pointwise mutual information and PPMI

Measuring whether two words co-occur more than chance with PMI, clipping negatives to get PPMI, computing it step by step on a term-context matrix, and correcting PMI's bias toward rare words with alpha-weighted context probabilities.

Concepts
6
Slides
53-60
Reading
36 min
Understood
0/6 concepts

Why this part matters

Part 05 fixed raw counts on the term-document side with tf-idf. Term-context matrices have the same disease: the biggest numbers belong to frequent words such as information and data, which sit next to almost everything. A raw count cannot tell you whether two words genuinely belong together or merely happen to be common.

Positive pointwise mutual information is the standard cure. It rescales every cell of a term-context matrix by what chance alone would predict, keeping only above-chance association, and it turns that matrix into meaningful sparse word vectors. It is also the bridge to the rest of this lecture: skip-gram with negative sampling turns out to factorize a shifted PMI matrix, and the magic number 0.75 you will meet in word2vec first appears here. Outside embeddings, PMI drives collocation extraction, lexicography and feature selection, so it will show up in your research. Exams almost always ask for one PPMI cell by hand.

By the end you can

  1. Explain PMI as observed versus chance co-occurrence, measured in bits.
  2. Justify clipping negative PMI to zero to obtain PPMI.
  3. Compute joint and marginal probabilities from a term-context count matrix.
  4. Compute any single PPMI cell by hand from counts.
  5. Explain PMI's bias toward rare contexts and two standard fixes.
  6. Apply alpha = 0.75 context smoothing and predict its effect on each cell.

Start with numbers. In the small Term-context matrix used throughout this part, the word information accounts for 7703 of the N = 11716 counted word-context pairs, and the context data for 5673 of them. If the two words had nothing to do with each other, how often would you expect to see them together? The full table, with every row and column sum, is in the counts-to-probabilities section below.

Independence answers that. If knowing one word tells you nothing about the other, the probability of the pair is just the product of the separate probabilities: P(information) × P(data) = .6575 × .4842 = .3184. So about 31.8% of all pairs should be (information, data) by chance alone. The observed share is 3982 / 11716 = .3399. The ratio of observed to expected is 1.0676: the pair occurs only 6.8% more often than chance, and log2 1.0676 = .0944 bits. Compare cherry and pie: there the ratio is 20.8, and the log is 4.38 bits. That number is pointwise mutual information.

PMI⁡(x,y)=log⁡2P(x,y)P(x) P(y)\operatorname{PMI}(x, y) = \log_2 \frac{P(x, y)}{P(x)\,P(y)}
Generic form, for any two events x and y
PMI⁡(w,c)=log⁡2P(w,c)P(w) P(c)\operatorname{PMI}(w, c) = \log_2 \frac{P(w, c)}{P(w)\,P(c)}
Word form: target word w and context word c

Read the fraction one piece at a time. The numerator is what actually happened: how often the pair appeared together. The denominator is what independence predicts, because under independence P(x, y) = P(x) P(y). The ratio therefore says how many times more often the pair occurs than chance, and the base-2 logarithm turns that ratio into bits. A ratio of 1 gives 0 bits (independent), a ratio above 1 gives a positive score (attraction), and a ratio below 1 gives a negative score (avoidance). Each extra bit means the pair is twice as over-represented.

Two circles stand for P(x) and P(y). The dashed ring marks where the second circle would sit if the words were independent, so their overlap equals P(x)P(y). When active, the second circle slides in, the overlap grows past the chance amount, and the PMI turns positive.

Where the measure comes from

Church and Hanks (1989, journal version 1990) brought the measure to lexicography. They estimated P(x, y) by counting how often x is followed by y within a window of w = 5 words, and they read the score exactly as above: well above zero for genuine association, near zero for no relation, well below zero for words in complementary distribution. Their rough rule of thumb was that pairs with a score above 3 tend to be interesting, and they ignored pairs seen 5 times or fewer because the ratio was unstable, an early sign of the rare-event problem later in this part. One subtlety a PhD reader should notice: because their count encoded word order (x before y), their association ratio was not symmetric. The term-context version on these slides counts a symmetric window, so PMI(w, c) depends only on which pair you pick.

Recall

In one sentence, what does PMI(w, c) = 0 mean?

The pair co-occurs exactly as often as independence predicts, P(w, c) = P(w) P(c), so the ratio is 1 and log2 1 = 0.

Suppose two words each have probability 10^-6, which is typical of most of the vocabulary. Independence predicts that they appear together with probability 10^-12. To say with confidence that they appear together less than that, you must be able to estimate probabilities well below 10^-12, which takes a corpus on the order of trillions of pairs. With a corpus of a few million tokens you will simply never see them together, and you cannot tell "these words avoid each other" apart from "these words never happened to meet".

That is the first reason negative PMI is unreliable: the evidence needed to estimate below-chance co-occurrence grows with the rarity of the words, and for most word pairs it is never available. The second reason is about evaluation: it is not clear that people can even judge "unrelatedness" reliably, so there is no good gold standard to check negative scores against. The practical answer, used since Church and Hanks and later Dagan and colleagues (1993) and Niwa and Nitta (1994), is to keep only the positive side.

PPMI⁡(w,c)=max⁡ ⁣(log⁡2P(w,c)P(w) P(c), 0)\operatorname{PPMI}(w, c) = \max\!\left(\log_2 \frac{P(w, c)}{P(w)\,P(c)},\ 0\right)
Positive PMI: negative and undefined values become 0

Positive PMI keeps the attraction signal and floors everything else at zero. It has a welcome side effect. A pair that never co-occurs has P(w, c) = 0, so its Pointwise mutual information is log2 0 = -∞, a value that would wreck any later arithmetic. Clipping maps it cleanly to 0. In the slide table this is exactly what happens to strawberry/computer and strawberry/data, both with count 0. The result is a sparse vector per word: long, mostly zero, with a few positive entries for the contexts that really characterise it.

PMI bars for the cherry and information rows sit around a zero baseline, several of them far below it. When active, the negative bars collapse onto the baseline and the positive bars stay, in teal: PPMI is max(PMI, 0).
PMIPPMI
Range-∞ to +∞ (asymptotically)0 to +∞
Unseen pair (count 0)log2 0 = -∞0
What a value saysAttraction (positive) or avoidance (negative)Strength of attraction only; 0 means no evidence of it
ReliabilityNegative side needs enormous corporaKeeps only the side small corpora can estimate
Matrix shapeDense, with many large negative entriesSparse: most entries are exactly 0
PMI and PPMI side by side

Empirically the choice pays off. Levy, Goldberg and Dagan (2015) report that Bullinaria and Levy (2007) found PPMI outperforms plain PMI on semantic similarity tasks, and PPMI became the default count-based baseline against which neural embeddings were later compared.

Recall

Give two reasons PPMI discards negative PMI.

First, negative estimates need enormous corpora: for words with P = 10^-6 each you must resolve P(w, c) well below 10^-12. Second, humans cannot reliably judge "unrelatedness", so negative scores have no gold standard. As a bonus, zero counts give log 0 = -∞, which clipping turns into 0.

Quick check

Why does PPMI replace negative PMI values with zero?

Everything so far needs three probabilities per cell: the joint P(w, c) and the two marginals P(w) and P(c). All three come from one count matrix F. Here is the matrix the slides use, taken from SLP3, whose counts come from Wikipedia: four target words as rows, five context words as columns, with the row and column sums added.

computerdataresultpiesugarrow sum
cherry28944225486
strawberry001601980
digital1670168385543447
information332539823785137703
column sum4997567347351261N = 11716
p(c).4265.4842.0404.0437.00521
Co-occurrence counts f_ij with margins (SLP3 Fig. 6.10)

Add every cell and you get the grand total N = 11716. Each probability is then a share of that one total. The joint probability of a cell is the cell divided by N. The marginal probability of a target word is its row sum divided by N, and the marginal probability of a context is its column sum divided by N.

pij=fijN,pi∗=∑jfijN,p∗j=∑ifijN,N=∑i∑jfij\begin{gathered} p_{ij} = \frac{f_{ij}}{N}, \qquad p_{i*} = \frac{\sum_j f_{ij}}{N}, \\ p_{*j} = \frac{\sum_i f_{ij}}{N}, \qquad N = \sum_i \sum_j f_{ij} \end{gathered}
Joint, row marginal and column marginal, all over the same N

Worked example

Three probabilities for (information, data)

  1. Find the total

    Sum all twenty cells, or equivalently the four row sums: 486 + 80 + 3447 + 7703 = 11716.
  2. Joint

    The cell count is 3982, so p(information, data) = 3982 / 11716 = .3399.
  3. Row marginal

    The information row sums to 7703, so p(information) = 7703 / 11716 = .6575.
  4. Column marginal

    The data column sums to 5673, so p(data) = 5673 / 11716 = .4842.
  5. Result

    Joint p(information, data)
    3982 / 11716 = .3399
    Marginal p(information)
    7703 / 11716 = .6575
    Marginal p(data)
    5673 / 11716 = .4842
    Chance prediction p(information) p(data)
    .6575 × .4842 = .3184

Because the joint and both marginals come from the same matrix and the same N, they are consistent: each row of joint probabilities sums to its row marginal, each column to its column marginal, and everything sums to 1. SLP3 is candid that this "pretends" the five listed contexts are the only ones in the world. In a real system the matrix has tens of thousands of columns and the same recipe applies unchanged.

Recall

From the count table, compute p(strawberry) and p(sugar).

p(strawberry) = 80 / 11716 = .0068 and p(sugar) = 61 / 11716 = .0052, both over the same matrix total N.

With the three probabilities in hand, one cell of the Pointwise mutual information matrix is a division and a log. Work it once by hand for information/data, then notice a shortcut that skips the rounding entirely.

Worked example

PPMI(information, data) by hand

  1. Ratio of observed to expected

    .3399 / (.6575 × .4842) = .3399 / .3184 = 1.0675.
  2. Same ratio straight from counts

    The Ns cancel into one: f × N / (row × col) = 3982 × 11716 / (7703 × 5673) = 1.0676. This route avoids rounding the probabilities first.
  3. Take log base 2

    Most calculators lack log2, so use log2 x = ln x / ln 2: ln 1.0676 / 0.6931 = 0.0654 / 0.6931 = .0944.
  4. Clip

    .0944 > 0, so the clip changes nothing.
  5. Result

    PPMI(information, data) = .09, matching the slide.
PMI⁡ij=log⁡2fij Nfi∗ f∗j\operatorname{PMI}_{ij} = \log_2 \frac{f_{ij}\, N}{f_{i*}\, f_{*j}}
Shortcut from raw counts: cell times total over row sum times column sum

Repeat for every cell and you get the full PMI matrix below. Every Positive PMI value on slide 58 is this matrix after clipping; SLP3 quotes PMI(cherry, computer) = -6.7 in its figure caption as an example of a large negative value that PPMI discards.

computerdataresultpiesugar
cherry-6.70-4.88-1.124.383.30
strawberry-∞-∞-1.694.105.51
digital0.180.01-0.71-4.91-2.17
information0.020.090.28-6.07-1.63
Full PMI matrix before clipping
computerdataresultpiesugar
cherry0004.383.30
strawberry0004.105.51
digital0.180.01000
information0.020.090.2800
PPMI matrix after clipping (slide 58, SLP3 Fig. 6.12)

Now read the PPMI matrix as a set of word vectors. The fruit rows light up only on pie and sugar; the technology rows only on computer, data and result. The two groups share no non-zero dimension, so the cosine similarity between cherry and digital is exactly 0, while cherry and strawberry have a cosine of about 0.96. The raw counts were noisier: cherry co-occurs with computer and data a few times, and in a full-size matrix such incidental counts, scaled by frequent contexts, blur every row. PPMI vectors are still long and sparse; the second half of this lecture learns short dense vectors instead.

The 4 by 5 grid of PPMI values, dim at rest. When active, only the nine non-zero cells fill, with strength proportional to their PPMI, and the fruit block and technology block appear as two separate islands.

Recall

Compute PPMI(cherry, pie) from count 442, row sum 486, column sum 512 and N = 11716.

442 × 11716 / (486 × 512) = 20.81, and log2 20.81 = 4.38. It is positive, so PPMI = 4.38.

Quick check

Using the slide counts, what is PMI(information, data)?

PMI's bias toward rare events

Add one more row and one more column to the slide table: a word w and a context c, each seen exactly once, and that once together. The shortcut gives PMI = log2(1 × 11716 / (1 × 1)) = log2 11716 = 13.5 bits. That is more than double strawberry/sugar (5.51), from a single observation that may be a typo or a coincidence. One accident beats thousands of genuine co-occurrences.

The mechanism is the denominator. When a context is rare, P(c) is tiny, so even one co-occurrence produces a large ratio. Levy, Goldberg and Dagan (2015) call this Pointwise mutual information's Achilles' heel, citing Turney and Pantel (2010): a word's highest-scoring dimensions become obscure contexts it met once or twice, and since similar words rarely share those accidents, their vectors look less alike under cosine than they should. Clipping does not help, because Positive PMI only touches negative values and this bias inflates positive ones.

Two fixes

  1. Give rare contexts a little more probability. If P(c) for a rare context is nudged upward, its PMI falls. This is the alpha weighting of the next concept.
  2. Add-k smoothing. Add a small constant k to every count before computing probabilities, exactly as in the n-gram language models of Lecture 03. Slide 59 names the simplest case, add-one smoothing, which is k = 1 and lowers strawberry/sugar from 5.51 to 5.41. SLP3 gives k = 0.1 to 3 as common choices, and notes that the larger the k, the more the non-zero counts are discounted. A count of 1 becomes 3 with k = 2, tripling, while a count of 442 barely moves. On the slide table, add-2 lowers strawberry/sugar from 5.51 to 5.31 and leaves the overall pattern intact.

The oldest fix is the bluntest. Church and Hanks simply discarded pairs seen 5 times or fewer. Frequency cut-offs of that kind are still common in collocation tools.

Add-k smoothingContext alpha
What changesEvery count gets + k before probabilities are computedOnly the context distribution P(c) is reshaped
Which counts move mostSmall counts, proportionally (1 becomes 3 with k = 2)Rare contexts gain probability, frequent ones lose a little
Typical valuek from 0.1 to 3alpha = 0.75
strawberry/sugar5.51 → 5.31 (k = 2)5.51 → 4.01
OriginLaplace smoothing, as in n-gram language modelsword2vec negative sampling, carried over by Levy et al. (2015)
The two smoothing fixes for rare-event bias

Recall

Why does clipping to PPMI not remove PMI's bias toward rare contexts?

The bias inflates positive values through a tiny P(c) in the denominator, and clipping only touches negative values, so the inflated scores pass through unchanged.

Raising context counts to alpha = 0.75

Take two contexts with P(a) = .99 and P(b) = .01. Raising both to 0.75 and renormalising roughly triples the rare one, so every Pointwise mutual information involving b falls by about 1.6 bits. The worked example below shows each step.

PPMI⁡α(w,c)=max⁡ ⁣(log⁡2P(w,c)P(w) Pα(c), 0),Pα(c)=count⁡(c)α∑c′count⁡(c′)α\begin{aligned} &\operatorname{PPMI}_\alpha(w, c) \\ &\quad = \max\!\left(\log_2 \frac{P(w, c)}{P(w)\,P_\alpha(c)},\ 0\right), \\ &P_\alpha(c) = \frac{\operatorname{count}(c)^\alpha}{\sum_{c'} \operatorname{count}(c')^\alpha} \end{aligned}
Alpha-weighted PPMI; the slides and SLP3 use alpha = 0.75

The exponent Alpha-weighted context probability flattens the context distribution. Because 0 < α < 1 shrinks large counts proportionally more than small ones, after renormalising P_alpha(c) > P(c) for rare contexts and P_alpha(c) < P(c) for frequent ones. A larger denominator means a lower PMI, so rare contexts lose exactly the inflated advantage the previous concept described, and Positive PMI computed with P_alpha(c) keeps fewer spurious rare dimensions. Only P(c) changes; P(w, c) and P(w) stay as before.

The five context probabilities on a log scale, with dashed outlines at the original P(c). When active, the bars morph to their alpha = 0.75 values: computer and data dip slightly, while sugar, the rarest context with 61 counts, rises to almost three times its old probability.

On the slide table the effect is easy to predict. Sugar, with only 61 counts, goes from P = .0052 to .0148, so strawberry/sugar drops from 5.51 to 4.01 and cherry/sugar from 3.30 to 1.80. The frequent context computer goes from .4265 to .4019, so digital/computer actually rises from 0.18 to 0.27. Result goes from .0404 to .0686, which pushes information/result from 0.28 to a PMI of -0.48, so its PPMI becomes 0.

computerpiesugar
P(c).4265 → .4019.0437 → .0728.0052 → .0148
cherry-6.70 → -6.614.38 → 3.643.30 → 1.80
strawberry-∞ → -∞4.10 → 3.375.51 → 4.01
digital0.18 → 0.27-4.91 → -5.65-2.17 → -3.67
information0.02 → 0.10-6.07 → -6.81-1.63 → -3.13
PMI before and after alpha = 0.75 for three contexts (alpha = 1 → alpha = 0.75)

Worked example

Slide 60's two-context example

  1. Raise to alpha

    .99^.75 = .9925 and .01^.75 = .0316.
  2. Find the shared normaliser

    .9925 + .0316 = 1.0241. Both contexts are divided by this same sum.
  3. Renormalise

    P_alpha(a) = .9925 / 1.0241 = .97 and P_alpha(b) = .0316 / 1.0241 = .03.
  4. Result

    The rare context's probability rises from .01 to .03; the frequent one falls from .99 to .97.

Why 0.75, and the road to word2vec

The number is borrowed. Mikolov and colleagues (2013) found that drawing negative samples for word2vec from the unigram distribution raised to the 3/4 power, U(w)^(3/4) / Z, worked significantly better than either the plain unigram or the uniform distribution. Levy, Goldberg and Dagan (2015) carried the trick over to count-based PMI as "context distribution smoothing", tested α ∈ {1, 0.75}, and found that it alleviates PMI's bias toward rare words and consistently improves performance across tasks, methods and configurations.

The connection runs deeper than a shared constant. Levy and Goldberg (2014) showed that Skip-gram with negative sampling with k negative samples implicitly factorizes a word-context matrix whose cells are PMI(w, c) - log k. The sparse analogue is shifted PPMI, max(PMI(w, c) - log k, 0), which they found competitive on word similarity. So PPMI and word2vec are close relatives: Negative sampling is, in a precise sense, a smoothed and compressed way of estimating the same quantity you just computed by hand. Keep this in mind for the skip-gram parts that follow.

Recall

Why does raising context counts to 0.75 lower the PMI of rare contexts?

It flattens the context distribution, so after renormalising a rare context gets P_alpha(c) > P(c). A bigger denominator means a smaller ratio and a lower PMI.

Recall

Why is "raise the probabilities" the same as "raise the counts" to alpha?

P(c)^α = count(c)^α / N^α, and the N^α cancels when you renormalise.

Quick check

With P(a) = .99, P(b) = .01 and alpha = 0.75, what is P_alpha(b)?

Quick check

Applying alpha = 0.75 to the slide's context counts does what to PPMI(strawberry, sugar)?

Recap

If you remember nothing else

  • PMI(w, c) = log2 P(w, c) / (P(w)P(c)) measures how far a pair sits above or below chance, in bits. Zero means independent.
  • Negative PMI is unreliable without enormous corpora, so PPMI = max(PMI, 0). Clipping also maps unseen pairs from minus infinity to 0.
  • All probabilities come from one matrix total N: the joint is the cell over N, the marginals are the row and column sums over N.
  • Shortcut: PMI = log2(f_ij × N / (row_i × col_j)). In the slide example, information/data = 0.09 and strawberry/sugar = 5.51.
  • PMI favours rare events: one co-occurrence with a rare context can outscore thousands of genuine ones. PPMI does not fix this.
  • Fixes: add-k smoothing (add-one on slide 59 is k = 1; SLP3 uses k from 0.1 to 3), or P_alpha(c) with alpha = 0.75, which raises rare-context probabilities and lowers their PMI.
  • alpha = 0.75 comes from word2vec negative sampling, and SGNS itself approximates a PMI matrix shifted by log k.

Sources