Algorithm Search⌘K

Definitioncore

Positive pointwise mutual information

Also called PPMI.

PPMI(w, c) = max(PMI(w, c), 0), which drops unreliable negative values and makes a sparse word-context weighting that works well for similarity.

Positive pointwise mutual information is PMI with every negative value replaced by 0: PPMI⁡(w,c)=max⁡(PMI⁡(w,c),0)\operatorname{PPMI}(w, c) = \max(\operatorname{PMI}(w, c), 0). It is the usual weighting of a word-context matrix before the rows are compared as word vectors. The cut keeps the information that a word and a context occur together more often than chance, and drops the claim that they occur together less often, which needs far more data to estimate. It also removes the −∞-\infty of the pairs never seen, so the matrix stays as sparse as the counts. That PPMI with the cosine works well for word similarity is a measurement: Bullinaria and Levy 2007 found it the best of the weightings they compared, and Levy, Goldberg and Dagan 2015 found it competitive with learned embeddings when its settings are tuned.

Definition

Let MM be a word-context matrix with total NN, row sums M[w,∗]M[w, *] and column sums M[∗,c]M[*, c]. The PPMI matrix has the entries

PPMI⁡(w,c)=max⁡(log⁡2M[w,c]⋅NM[w,∗]⋅M[∗,c], 0),\operatorname{PPMI}(w, c) = \max\Big( \log_2 \frac{M[w, c] \cdot N}{M[w, *] \cdot M[*, c]},\ 0 \Big),

with the value 0 when M[w,c]=0M[w, c] = 0. Any base of the logarithm can be used, and the page or paper states it. The base scales every entry by the same factor, so it does not change cosines.

Since the cut is at 0, these facts hold at once.

  • PPMI⁡(w,c)≥0\operatorname{PPMI}(w, c) \ge 0, and PPMI⁡(w,c)=0\operatorname{PPMI}(w, c) = 0 whenever M[w,c]=0M[w, c] = 0. So the PPMI matrix has no more nonzero entries than MM.
  • All rows are nonnegative vectors, so the cosine of two rows is in [0,1][0, 1], and it is 0 exactly when the two words share no context with positive PMI.
  • A pair keeps its PMI value when it is positive, so the upper bound of PMI holds: PPMI⁡(w,c)≤min⁡(−log⁡P(w),−log⁡P(c))\operatorname{PPMI}(w, c) \le \min(-\log P(w), -\log P(c)).

Context distribution smoothing. Levy, Goldberg and Dagan 2015 replace P(c)P(c) by

Pα(c)=M[∗,c]α∑c′M[∗,c′]α,α=0.75,P_\alpha(c) = \frac{M[*, c]^\alpha}{\sum_{c'} M[*, c']^\alpha}, \qquad \alpha = 0.75,

and use max⁡(log⁡P(w,c)P(w)Pα(c),0)\max(\log \frac{P(w, c)}{P(w) P_\alpha(c)}, 0). Since α<1\alpha < 1, rare contexts get a larger probability and frequent contexts a smaller one, which lowers the PMI of rare contexts and raises that of frequent ones. The exponent comes from the sampling distribution of negative samples in word2vec.

Shifted PPMI. max⁡(PMI⁡(w,c)−log⁡k,0)\max(\operatorname{PMI}(w, c) - \log k, 0) for an integer k≥1k \ge 1 keeps only the pairs with a ratio above kk. The shifted PMI matrix is, under some assumptions, the matrix that skip-gram with kk negative samples factorizes (see the factorization theorem).

Examples and non-examples

A small matrix. The counts, written for this page, with N=40N = 40, are cat (pet 4, fur 3, road 0, the 5), dog (5, 2, 1, 6) and car (0, 0, 6, 8). The PMI values in bits are on the PMI page. PPMI keeps the positive ones:

word pet fur road the
cat 0.5670 1.0000 0 0
dog 0.6666 0.1926 0 0
car 0 0 1.2922 0.2666

The cosines of the rows, raw counts against PPMI:

pair raw counts PPMI
cat, dog 0.9748 0.7154
cat, car 0.5657 0
dog, car 0.6647 0

With raw counts, "car" looks fairly close to "cat" and "dog", because all three occur often with "the". PPMI gives "the" no weight in the rows of "cat" and "dog", and the animals and the car no longer share anything.

With smoothing. With α=0.75\alpha = 0.75, the context probabilities change from (0.225,0.125,0.175,0.475)(0.225, 0.125, 0.175, 0.475) to about (0.2368,0.1524,0.1961,0.4147)(0.2368, 0.1524, 0.1961, 0.4147) for pet, fur, road and the. The rows become cat (0.4933,0.7143,0,0.0068)(0.4933, 0.7143, 0, 0.0068), dog (0.5929,0,0,0.0474)(0.5929, 0, 0, 0.0474) and car (0,0,1.1278,0.4624)(0, 0, 1.1278, 0.4624). The rare context "fur" loses weight, and "dog" and "fur" drop to 0, while the frequent context "the" gets a small positive weight in all three rows.

Why negative values are dropped. Take two words with probability 10−610^{-6} each. If they are independent, they occur together with probability 10−1210^{-12}, so a corpus must have far more than 101210^{12} pairs before a count of 0 shows that they avoid each other. In a corpus of usual size, almost all pairs of rare words have the count 0, and a negative or −∞-\infty PMI for them is an artifact of the sample size. This is the heuristic reason for the cut.

Not: a fix for rare events. PPMI keeps the high positive PMI of a pair seen once with two rare words. The bias of PMI toward rare events remains, and smoothing or a minimum count is needed for it.

Not: the absolute value. ∣PMI⁡∣|\operatorname{PMI}| would give pairs that avoid each other a large weight, together with the −∞-\infty of the pairs never seen. PPMI gives them 0.

  • PMI. Pointwise mutual information is the value before the cut. Its average under the joint distribution is the mutual information, which is at least 0. PPMI values are nonnegative one by one.
  • Word-context matrix. PPMI is a weighting of the counts of a word-context matrix. The choice of window and context changes the counts, and so the PPMI values.
  • Low-rank vectors. A truncated singular value decomposition of the PPMI matrix gives dense vectors, as latent semantic analysis does for a term-document matrix.
  • Learned embeddings. The skip-gram model and GloVe learn dense vectors whose dot products approximate a shifted PMI and a log count, so they are close relatives of a factorized PPMI matrix.
  • Sparse storage. The PPMI matrix has the same zero pattern as the counts or a smaller one, so it is stored as a sparse matrix.

References

  1. Bullinaria and Levy 2007, the comparison of weightings and distance measures for word-context vectors, in which positive PMI with the cosine did best
  2. Levy, Goldberg and Dagan 2015, PPMI, shifted PPMI max(PMI - log k, 0), and context distribution smoothing with the exponent 0.75
  3. Daniel Jurafsky and James H. Martin, Speech and Language Processing, third edition draft, the chapter on vector semantics and embeddings, the section on PPMI and the reason for dropping negative values

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/J6ZPMC/text.yaml