Pointwise Mutual Information › Visualizing PMI

Michael BrenndoerferUpdated March 21, 20266 min read
Language AI HandbookAll chapters
Part 3 of 67Distributional Semantics
Chapter 17Pointwise Mutual Information › Visualizing PMI
Reading section 8 of 13 · Visualizing PMI · 6 minSection 8 of 13 · 6 min

Book contents

Section 8 of 13 · 6 min read

Pointwise Mutual Information › Visualizing PMIOne section · Sections in this chapter8 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Visualizations make the effect of PMI normalization immediately clear in ways that tables cannot. The following plots examine the PPMI matrix structure, compare PMI against raw counts for a set of context words, and illustrate how different PMI shift values affect the resulting distribution.

PMI Heatmap for Selected Words

A heatmap of the PPMI matrix for a focused subset of words reveals the association structure directly. By selecting words from different semantic domains, we can see whether PMI recovers the domain boundaries from raw text.

Out[19]:
Visualization
Heatmap of PPMI scores between selected words, showing semantic clustering by domain.
PPMI association matrix for a selected set of semantically related words. Brighter cells indicate stronger positive association between a target word (row) and context word (column). Clusters of high PPMI values reveal semantic groupings: animal words associate with each other, financial terms cluster together, and geographic terms form their own group. The word ''bank'' shows associations in both the financial and geographic clusters, which reflects its polysemy in this corpus.

The heatmap clearly shows that words from the same semantic domain share high PPMI scores with each other. Animal-domain words ("cat," "dog," "mouse") show mutual associations, while financial words ("bank," "fees," "loan") form their own cluster. The word "bank" shows some crossover. This reflects its use in both financial and geographic contexts in the corpus.

PMI Score Distribution Across Shift Values

Shifted PPMI with different values of kk changes the distribution of positive associations. Larger kk raises the threshold, retaining only the strongest associations and pruning pairs whose PMI exceeds independence only by a small margin.

Out[20]:
Visualization
Histogram of positive PPMI values showing right-skewed distribution concentrated near zero.
Distribution of positive PPMI values at k=1 (standard PPMI). Most associations cluster near zero, with a long tail of high-value specific associations. The right-skewed distribution is typical: many word pairs have weak positive association, while only a few pairs show strong, specific co-occurrence.
Histogram of shifted PPMI values showing fewer non-zero entries and a tighter distribution of strong associations.
Distribution of positive PPMI values at k=5 (shifted PPMI). The shift discards weaker associations, retaining only pairs with strong, specific co-occurrence evidence. The resulting distribution has fewer entries but represents more reliable associations.

Standard PPMI (k=1k=1) retains all positive associations, including weakly associated pairs near zero. Shifted PPMI (k=5k=5) discards these borderline pairs, retaining only word combinations with strong, reliable co-occurrence evidence. The trade-off is coverage versus precision: k=1k=1 covers more pairs but includes more noise; larger kk is more conservative but more reliable.

In practice, choosing kk depends on the downstream task. For collocation extraction, where precision matters more than recall, a larger shift is appropriate. For constructing word vectors for a downstream similarity task, a smaller shift preserves more information about the distributional structure.

PMI vs. Raw Counts: Ranking Comparison

This visualization makes the ranking shift from raw counts to PPMI concrete for a set of target context words, confirming the analytical argument with an empirical comparison.

Out[21]:
Visualization
Bar chart showing top context words for 'cat' by raw count, with function words dominating.
Top context words for 'cat' ranked by raw co-occurrence count. High-frequency function words like 'the' and common words dominate, obscuring the meaningful content word associations that reflect specific semantic relationships.
Bar chart showing top context words for 'cat' by PPMI, with semantically relevant words at the top.
Top context words for 'cat' ranked by PPMI. The normalization suppresses ubiquitous function words and surfaces words with specific association to 'cat', revealing the words that are truly distinctive of 'cat' usage.

The contrast between the two rankings is striking. Raw counts prominently feature function words that appear near everything. PPMI suppresses these and surfaces words with direct semantic relevance to "cat," such as the animals it interacts with and the verbs that describe its behavior. This is the normalization effect that makes PPMI useful for downstream NLP tasks.