Pointwise Mutual Information › Deriving the PMI Formula
Language AI HandbookAll chapters Pointwise Mutual Information › Deriving the PMI FormulaOne section · Sections in this chapter3 / 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
PMI comes from information theory, specifically from the concept of mutual information between random variables. Mutual information asks how much knowing one variable tells you about another. It quantifies the reduction in uncertainty about one variable when you know the value of another. Pointwise mutual information applies this question to a specific pair of outcomes rather than to entire distributions.
Think of each word occurrence as a random event. When you sample a position in the corpus at random, you draw a word. Define:
- : the probability of randomly sampling word from the corpus
- : the probability of randomly sampling context word
- : the probability of observing the word pair together in a co-occurrence event
If and were completely independent, we would expect their joint probability to equal the product of their marginal probabilities:
This is simply the definition of statistical independence. Two events are independent if and only if their joint probability factors into the product of the marginals. If you know that "bank" and "deposit" are independent, then knowing "bank" appeared tells you nothing about whether "deposit" appeared nearby.
PMI measures the log-ratio of the observed joint probability to this independent baseline:
where:
- : the observed probability of word appearing with context
- : the marginal probability of word across all contexts
- : the marginal probability of context across all co-occurrences
- : logarithm base 2, so PMI values are expressed in bits
When the observed probability equals the expected probability under independence, the ratio is 1 and . When the words co-occur more than chance predicts, the ratio exceeds 1 and PMI is positive. When words co-occur less than chance predicts, the ratio falls below 1 and PMI is negative.
The logarithm serves several important roles. First, it converts the ratio from a multiplicative scale to an additive one, which is easier to work with mathematically and algorithmically. Second, it gives PMI a natural interpretation in information theory: a PMI of 1 bit means that observing doubles your probability estimate for . Third, the logarithm makes PMI symmetric in the sense that , which you can verify algebraically since the joint probability and the product of marginals are both symmetric.
PMI quantifies the association between a word and a context by comparing their observed co-occurrence probability against the probability expected if they were statistically independent:
PMI equals zero when the words are independent, is positive when they associate more than chance, and is negative when they co-occur less than chance.
Estimating Probabilities from Counts
In practice, we estimate these probabilities from a co-occurrence matrix. Given a corpus with total co-occurrence events:
- , where is the total number of co-occurrence events involving word
- , where is the total number of co-occurrence events involving context
- , where is the number of times and co-occur within the context window
Substituting these into the PMI formula and simplifying:
This final form is what you implement in code: multiply the raw co-occurrence count by the total event count , then divide by the product of the two marginal counts. The logarithm converts this ratio into an additive scale where zero means independence. Notice that cancels from the marginal probabilities but remains in the joint probability, which is why it appears in the numerator of the count-based formula. The ratio in the numerator can be understood as the observed count scaled up to match the units of the denominator .
Interpreting PMI Values
PMI values have clear, intuitive meanings that map directly onto the concept of statistical association:
- PMI = 0: The words appear together exactly as often as chance predicts. No evidence of association beyond their individual frequencies.
- PMI > 0: The words appear together more than chance predicts. Higher values mean stronger, more specific association. A PMI of 2 bits means the pair co-occurs four times more often than chance.
- PMI < 0: The words appear together less than chance predicts. They tend to avoid each other, though this is often an artifact of data sparsity rather than actual repulsion.
- PMI approaching : Occurs when two words almost always appear together but one or both are very rare. This can happen with highly specialized terminology or named entities in small corpora.
- PMI : Occurs when . The words never co-occur, making the log of zero undefined.
The case is a serious practical problem. Many word pairs never co-occur, especially in large vocabularies with limited data. A vocabulary of 50,000 words yields a matrix with 2.5 billion cells, but even a large corpus might only fill a small fraction of them. This leads directly to the concept of Positive PMI.
A caveat is that PMI values for rare words can be very high even when based on flimsy evidence. If two words each appear only twice in the corpus but always together, their PMI is very high. That sounds like strong evidence, but two observations are not enough to establish an association. This statistical fragility for low-frequency pairs is one of PMI's main practical weaknesses and motivates the smoothing and thresholding strategies discussed later.
The Information-Theoretic Connection
PMI is grounded in mutual information rather than being an ad hoc normalization. It has a direct connection to mutual information, one of the foundational quantities in information theory. Mutual information between two random variables and is defined as:
This is exactly a weighted average of PMI values, where the weights are the joint probabilities . Mutual information measures the total statistical dependency between and across all possible word and context pairs. Pointwise mutual information zooms in on a single pair and reports the contribution of that specific combination to the overall mutual information.
This connection matters for two reasons. First, it means PMI has a well-founded theoretical interpretation, rather than a purely heuristic one. Second, it means that maximizing PMI for specific pairs is related to, though not identical to, maximizing mutual information across all pairs, which is the objective of many representation learning algorithms.