intermediate representations 40 min read

Distributional Semantics: PPMI and Truncated SVD

Know a word by the company it keeps: pointwise mutual information subtracts the background every count row shares, a truncated SVD keeps its best low-rank picture, and the context, not the method, decides whether that picture shows topic or polarity

Overview & Motivation

Count, for every word in the finance corpus, which words appear within two positions of it. Then compare words by their counts after one reweighting, the pointwise mutual information that this topic is about. The word whose neighbors look most like those of strong is improved. Next come stronger, healthy, and then weak. Soft, confident, and weaker follow. Four of the seven are words of the same polarity, and three are its antonyms.

That is the distributional hypothesis at work, and its limit in one list. Harris (1954) and Firth (1957) proposed that words with similar meanings occur in similar contexts; Firth’s phrase is that you know a word by the company it keeps. The company of strong in an earnings call is which management described as and revenue rose six percent, and weak keeps exactly the same company. A matrix of co-occurrence counts measures substitutability. Meaning is something more.

This topic builds the classical recipe, a co-occurrence matrix, a reweighting by pointwise mutual information (PMI), and a truncated singular value decomposition (SVD), and proves what each step does.

  1. PMI removes the background. Every raw count row shares the corpus’s own word frequencies, so rows of different words point almost the same way. PMI subtracts that background in log coordinates.
  2. Counts cannot tell association from frequency on rare pairs. A pair seen once has a PMI determined by frequency alone, and under independence rare pairs produce large false positives. Most of a corpus’s PMI matrix is such pairs.
  3. The eigenvalue weight decides what an SVD embedding measures. Word vectors’ dot products approximate a power of the matrix’s Gram matrix, not the matrix itself, and a symmetric window produces large negative eigenvalues that the usual half-power weighting misreads.
  4. Low rank means two different things. A latent-class model makes the ratio P(w,c)/(P(w)P(c))P(w, c)/(P(w)P(c)) low rank, while embeddings assume its logarithm, the PMI, is low rank. The two hypotheses agree only for weak associations.

The finance corpus lets us check everything against a known answer. Its generator draws every content noun from its document’s sector vocabulary or from a vocabulary all six sectors share, so we can ask whether a method puts nouns of the same sector together, choosing settings on half of the nouns and scoring on the other half. The finance case study then asks what distribution cannot see, starting with polarity.


Words as points

The vocabulary-statistics topic counted words. Here we count pairs. The training text is the n-gram topic’s training split: 6,1306{,}130 sentences and 63,18263{,}182 word tokens over 3,4253{,}425 word types, which are the rows and columns of every matrix below.

Definition 1 (Co-occurrence matrix).

Fix a context type: a symmetric window of L∈{1,2,4,8}L \in \lbrace 1, 2, 4, 8 \rbrace positions inside a sentence, the whole sentence, or the whole document. The co-occurrence matrix CC counts, for words ww and cc, the ordered pairs of token positions (i,j)(i, j), i≠ji \ne j, in one sentence (or one document) with ww at position ii, cc at position jj, and, for a window, ∣i−j∣≤L\lvert i - j \rvert \le L. Write N=∑w,cC[w,c]N = \sum_{w, c} C[w, c] and nw=∑cC[w,c]n_w = \sum_c C[w, c].

CC is symmetric, since every pair is counted in both orders, and a word co-occurs with its own other tokens. With a two-word window there are 215,948215{,}948 pair occurrences spread over 53,29353{,}293 distinct pairs; with whole sentences, 661,904661{,}904 over 158,054158{,}054. A word is now a point: its row of CC, a vector with one coordinate per context word.

Definition 2 (PMI, PPMI, and shifted PPMI).

Let P(w,c)=C[w,c]/NP(w, c) = C[w, c]/N and P(w)=nw/NP(w) = n_w / N, and for 0<α≤10 \lt \alpha \le 1 let the smoothed context distribution be Pα(c)=ncα/∑c′nc′αP_\alpha(c) = n_c^{\alpha} / \sum_{c'} n_{c'}^{\alpha}. The pointwise mutual information is

PMI⁡α(w,c)=log⁡P(w,c)P(w) Pα(c),\operatorname{PMI}_\alpha(w, c) = \log \frac{P(w, c)}{P(w)\, P_\alpha(c)},

which is −∞-\infty when C[w,c]=0C[w, c] = 0. Positive PMI is PPMI⁡α=max⁡(PMI⁡α,0)\operatorname{PPMI}_\alpha = \max(\operatorname{PMI}_\alpha, 0), and for k≥1k \ge 1 the shifted positive PMI is SPPMI⁡α,k=max⁡(PMI⁡α−log⁡k,0)\operatorname{SPPMI}_{\alpha, k} = \max(\operatorname{PMI}_\alpha - \log k, 0). Without subscripts, α=1\alpha = 1 and k=1k = 1.

PMI compares how often two words occur together with how often they would if they were independent (Church and Hanks 1990). Clipping at zero replaces the −∞-\infty of unseen pairs by “no association”. The shifted version of Levy and Goldberg (2014) is the one to remember: before clipping, PMI⁡α−log⁡k\operatorname{PMI}_\alpha - \log k is the matrix that the word2vec topic will show skip-gram with kk negative samples drawn from PαP_\alpha fits at its optimum, on observed pairs and under the conditions that topic states. The smoothing exponent α=0.75\alpha = 0.75 is the one word2vec uses for its negative samples (Levy, Goldberg, and Dagan 2015).

What kind of coordinates are PMI rows? Write PCP_C for the distribution of contexts and P(⋅∣w)P(\cdot \mid w) for the contexts of ww.

Proposition 1 (Log-ratio coordinates).

For a joint distribution of words and contexts whose marginals have full support:

  1. P(c∣w)=PC(c) ePMI⁡(w,c)P(c \mid w) = P_C(c)\, e^{\operatorname{PMI}(w, c)}, so a PMI row and the context distribution determine each other.
  2. ∑cP(c∣w)PMI⁡(w,c)=KL⁡(P(⋅∣w) ∥ PC)≥0\sum_c P(c \mid w) \operatorname{PMI}(w, c) = \operatorname{KL}\bigl(P(\cdot \mid w) \,\Vert\, P_C\bigr) \ge 0, with equality exactly when ww is independent of its contexts.
  3. ∑wP(w) KL⁡(P(⋅∣w) ∥ PC)=I(W;C)\sum_w P(w)\, \operatorname{KL}\bigl(P(\cdot \mid w) \,\Vert\, P_C\bigr) = I(W; C), the mutual information of words and contexts.
Proof.

Part 1 is the definition rewritten. Substituting it into the Kullback–Leibler divergence gives part 2, and Gibbs’ inequality gives the sign (formalML, KL Divergence). Part 3 is the definition of mutual information as the divergence of the joint distribution from the product of its marginals, the identity formalRAG’s pointwise mutual information topic proves (its Theorem 1) for answers and retrieved documents.

∎

So a PMI row is the context distribution written in log-ratio coordinates relative to the corpus background, and its weighted average says how far the word is from that background. The next theorem says what this buys over raw counts.

Theorem 1 (PMI removes the background).

Let PP be a context distribution with full support, and let two words have context distributions P(⋅∣w)=(1−εw)P+εwqwP(\cdot \mid w) = (1 - \varepsilon_w) P + \varepsilon_w q_w and P(⋅∣w′)=(1−εw′)P+εw′qw′P(\cdot \mid w') = (1 - \varepsilon_{w'}) P + \varepsilon_{w'} q_{w'}, with qw,qw′≠Pq_w, q_{w'} \ne P. Write fw=qw/P−1f_w = q_w / P - \mathbf{1}, entrywise. As εw,εw′→0\varepsilon_w, \varepsilon_{w'} \to 0:

  1. the cosine of the two words’ count rows tends to 11, with 1−cos⁡=O(ε2)1 - \cos = O(\varepsilon^2);
  2. PMI⁡w/εw→fw\operatorname{PMI}_w / \varepsilon_w \to f_w, so the cosine of their PMI rows tends to cos⁡(fw,fw′)\cos(f_w, f_{w'}), with error O(ε)O(\varepsilon);
  3. ∑cP(c) fw(c)=0\sum_c P(c)\, f_w(c) = 0.
Proof.

A count row is nw(P+εw(qw−P))n_w \bigl(P + \varepsilon_w (q_w - P)\bigr), so its angle to PP is O(εw)O(\varepsilon_w). The angle θ\theta between the two rows is then O(ε)O(\varepsilon), and 1−cos⁡θ≤θ2/21 - \cos\theta \le \theta^2/2. For the PMI row, PMI⁡w(c)=log⁡(1+εwfw(c))\operatorname{PMI}_w(c) = \log\bigl(1 + \varepsilon_w f_w(c)\bigr). Once εw∥fw∥∞≤12\varepsilon_w \lVert f_w \rVert_\infty \le \tfrac12, the series of the logarithm gives ∣log⁡(1+x)−x∣≤x2\lvert \log(1 + x) - x \rvert \le x^2 (formalCalculus, Power Series & Taylor Series), so PMI⁡w=εwfw+O(εw2∥fw∥∞2)\operatorname{PMI}_w = \varepsilon_w f_w + O(\varepsilon_w^2 \lVert f_w \rVert_\infty^2) uniformly. Cosine does not depend on scale and is continuous away from zero, which gives part 2. For part 3, ∑cP(c)(qw(c)/P(c)−1)=1−1\sum_c P(c)\bigl(q_w(c)/P(c) - 1\bigr) = 1 - 1.

∎

Every count row contains the corpus background, so near the background all count rows point the same way, and a count cosine measures mostly how corpus-like two words are. PMI subtracts the background, and what remains, fwf_w, is the part of the word’s contexts that is its own. The theorem is a statement about words near the background, not a claim that real words are. The corpus shows the effect anyway. Take the 115115 test nouns of the benchmark below. With a two-word window, raw count rows of nouns from the same sector have mean cosine 0.6480.648, and nouns from different sectors 0.6380.638. Counts can barely tell the sectors apart. Under PPMI the cosines are 0.0560.056 and 0.0290.029: smaller, because the shared background is gone, and twice as large within a sector as across.


What counts cannot tell

PMI is a ratio of estimated probabilities, and estimates from small counts are unreliable. How unreliable depends on how rare the pair is, and by Zipf’s law most pairs are rare.

Proposition 2 (The ceiling, and the singleton artifact).

  1. PMI⁡(w,c)≤min⁡(−log⁡P(w), −log⁡P(c))\operatorname{PMI}(w, c) \le \min\bigl(-\log P(w),\, -\log P(c)\bigr), with equality in the first argument exactly when cc occurs only with ww. Under smoothing, PMI⁡α(w,c)≤−log⁡Pα(c)\operatorname{PMI}_\alpha(w, c) \le -\log P_\alpha(c).
  2. For a pair seen exactly once, the plug-in estimate is PMI⁡α(w,c)=−log⁡nw−log⁡Pα(c)\operatorname{PMI}_\alpha(w, c) = -\log n_w - \log P_\alpha(c). For α=1\alpha = 1 this is log⁡N−log⁡nw−log⁡nc\log N - \log n_w - \log n_c, a function of the two frequencies alone.
Proof.

P(w,c)≤P(c)P(w, c) \le P(c) and P(w,c)≤P(w)P(w, c) \le P(w) give the two ceilings. Substituting C[w,c]=1C[w, c] = 1 into Definition 2 gives part 2.

∎

Rare words have the highest ceilings, and on a pair seen once the estimate says nothing about association at all. How much of the matrix is that? Apply the vocabulary-statistics topic’s frequency spectrum to pair counts instead of word counts. With the two-word window, 38,67438{,}674 of the 53,29353{,}293 distinct pairs, 72.6%72.6\%, are seen exactly once, and they make up 73.3%73.3\% of the PPMI matrix’s positive entries. The largest PPMI on the row of a word seen once is 10.4910.49. For words seen 22 to 44 times it is 9.809.80, then 8.888.88, 7.387.38, and, for words seen at least 100100 times, 5.735.73.

Are these positive entries association, or noise? Suppose words and contexts were independent. With the margins fixed, the count of a pair is then close to a Poisson variable with mean μ=nwnc/N\mu = n_w n_c / N (formalStatistics, Discrete Distributions), and its true PMI is zero.

Proposition 3 (PPMI under independence).

Let X∼Poisson⁡(μ)X \sim \operatorname{Poisson}(\mu) and PPMI⁡=max⁡(log⁡(X/μ),0)\operatorname{PPMI} = \max\bigl(\log(X/\mu), 0\bigr). Then

  1. Pr⁡(PPMI⁡>0)=Pr⁡(X>μ)\Pr(\operatorname{PPMI} \gt 0) = \Pr(X \gt \mu);
  2. if μ<1\mu \lt 1, then Pr⁡(PPMI⁡>0)=1−e−μ\Pr(\operatorname{PPMI} \gt 0) = 1 - e^{-\mu}, every positive value is at least log⁡(1/μ)\log(1/\mu), and E[PPMI⁡]≥(1−e−μ)log⁡(1/μ)\mathbb{E}[\operatorname{PPMI}] \ge (1 - e^{-\mu}) \log(1/\mu).
Proof.

log⁡(X/μ)>0\log(X/\mu) \gt 0 exactly when X>μX \gt \mu. When μ<1\mu \lt 1, X>μX \gt \mu exactly when X≥1X \ge 1, which has probability 1−e−μ1 - e^{-\mu}, and then log⁡(X/μ)≥log⁡(1/μ)\log(X/\mu) \ge \log(1/\mu). The expectation is at least that value times that probability.

∎

Remark.

As μ→∞\mu \to \infty, Pr⁡(PPMI⁡>0)→12\Pr(\operatorname{PPMI} \gt 0) \to \tfrac12 and 2πμ  E[PPMI⁡]→1\sqrt{2\pi\mu}\; \mathbb{E}[\operatorname{PPMI}] \to 1: the standardized count is approximately normal, log⁡(X/μ)≈(X−μ)/μ\log(X/\mu) \approx (X - \mu)/\mu, and the positive part of a standard normal has mean 1/2π1/\sqrt{2\pi}. We check this numerically rather than prove it here.

Under independence, then, rare pairs produce rare but large false positives, and frequent pairs produce frequent but tiny ones. PPMI tests every pair against independence at once, a multiple-testing problem (formalStatistics, Multiple Testing & False Discovery), and the cure for the large false positives is a proper significance test (Dunning 1993), the subject of the collocations topic.

The corpus can be put to the test directly. Of the 50,64850{,}648 positive entries of the two-word PPMI matrix, 90.5%90.5\% belong to pairs with μ<1\mu \lt 1, each of which a single co-occurrence could have produced under independence. Now shuffle every token of the training text across the whole corpus, keeping every sentence’s length: each word’s frequency is unchanged, and every association is destroyed. The shuffled text’s PPMI matrix has 94,86094{,}860 positive entries. Poisson independence with the training margins predicts 93,60393{,}603, within 1.3%1.3\%. Its squared Frobenius norm is 729,130729{,}130, larger than the real text’s 691,005691{,}005. At this scale, the size of PPMI’s entries is mostly sampling noise, and the signal is in which entries are positive. Shifting by log⁡5\log 5 reverses the comparison. The smoothed and shifted SPPMI⁡0.75,5\operatorname{SPPMI}_{0.75, 5} has 234,580234{,}580 for the real text against 206,808206{,}808 for the shuffled one, and the unsmoothed SPPMI⁡1,5\operatorname{SPPMI}_{1, 5} has 312,843312{,}843 against 281,464281{,}464.

A second correction targets the context side.

Proposition 4 (Context-distribution smoothing).

For 0<α<10 \lt \alpha \lt 1, let Zα=∑cncαZ_\alpha = \sum_c n_c^\alpha. The ratio

Pα(c)P(c)=NZα ncα−1\frac{P_\alpha(c)}{P(c)} = \frac{N}{Z_\alpha}\, n_c^{\alpha - 1}

is strictly decreasing in ncn_c and equals 11 at

t⋆=(NZα)1/(1−α).t^\star = \Bigl(\frac{N}{Z_\alpha}\Bigr)^{1/(1 - \alpha)}.

So smoothing lowers PMI⁡\operatorname{PMI} exactly on contexts with nc<t⋆n_c \lt t^\star and raises it on those with nc>t⋆n_c \gt t^\star. The unit is ncn_c, a context’s co-occurrence total, not its token count. For k≥k′k \ge k', the positive entries of SPPMI⁡α,k\operatorname{SPPMI}_{\alpha, k} are a subset of those of SPPMI⁡α,k′\operatorname{SPPMI}_{\alpha, k'}.

Proof.

n↦nα−1n \mapsto n^{\alpha - 1} is strictly decreasing for α<1\alpha \lt 1, and PMI⁡α−PMI⁡=−log⁡(Pα(c)/P(c))\operatorname{PMI}_\alpha - \operatorname{PMI} = -\log\bigl(P_\alpha(c)/P(c)\bigr). The shift subtracts log⁡k\log k from every entry, so a larger shift leaves fewer of them positive.

∎

With the two-word window and α=0.75\alpha = 0.75, t⋆=338.4t^\star = 338.4 co-occurrences. At this window a word averages 3.43.4 co-occurrences per occurrence, so the threshold is roughly 9999 occurrences. Below it lie 95.8%95.8\% of context words, carrying 34.8%34.8\% of the co-occurrence mass NN. The positive entries number 50,64850{,}648 unsmoothed and 50,61850{,}618 smoothed; smoothed and shifted, SPPMI⁡0.75,5\operatorname{SPPMI}_{0.75, 5} has 36,38236{,}382 and SPPMI⁡0.75,15\operatorname{SPPMI}_{0.75, 15} has 22,79522{,}795. Smoothing tempers rare contexts. It does not touch the singleton artifact, since a singleton’s smoothed PMI is still a function of frequency (Proposition 2).


Truncated SVD

A PPMI row has 3,4253{,}425 coordinates, most of them zero and many of them noise. The classical response is to keep only the matrix’s strongest directions.

Definition 3 (Truncated SVD embedding).

Let M=UΣV⊤M = U \Sigma V^\top be a singular value decomposition, with singular values in decreasing order, and let Ud,Σd,VdU_d, \Sigma_d, V_d keep the first dd. For an eigenvalue weight p∈[0,1]p \in [0, 1], the word vectors are the rows of Wp=UdΣd pW_p = U_d \Sigma_d^{\,p} and the context vectors the rows of Cp=VdΣd 1−pC_p = V_d \Sigma_d^{\,1 - p}.

The classical choice is p=1p = 1; Levy, Goldberg, and Dagan (2015) found p=12p = \tfrac12 and p=0p = 0 often better (cf. Bullinaria and Levy 2012). The theorem says what each choice makes the dot product of two word vectors mean.

Theorem 2 (What the eigenvalue weight measures).

  1. WpCp⊤=Md:=UdΣdVd⊤W_p C_p^\top = M_d := U_d \Sigma_d V_d^\top for every pp, the best rank-dd approximation of MM in the Frobenius and spectral norms.
  2. WpWp⊤=UdΣd 2pUd⊤W_p W_p^\top = U_d \Sigma_d^{\,2p} U_d^\top, a best rank-dd approximation of the positive semidefinite matrix (MM⊤)p(M M^\top)^p: the best one when p>0p \gt 0 and σd>σd+1\sigma_d \gt \sigma_{d+1}, while at p=0p = 0 every nonzero eigenvalue ties at 11 and the order of the SVD picks the dd directions. For p=1p = 1 it approximates MM⊤M M^\top, whose entry ∑cM[w,c] M[w′,c]\sum_c M[w, c]\, M[w', c] is a weighted sum over the contexts two words share; for p=0p = 0 it is the orthogonal projector UdUd⊤U_d U_d^\top.
  3. Suppose MM is symmetric, with eigendecomposition M=QΛQ⊤M = Q \Lambda Q^\top, eigenvalues ordered so that ∣λ1∣≥∣λ2∣≥⋯\lvert \lambda_1 \rvert \ge \lvert \lambda_2 \rvert \ge \cdots, and ∣λd∣>∣λd+1∣\lvert \lambda_d \rvert \gt \lvert \lambda_{d+1} \rvert. Then W1/2W1/2⊤=Qd∣Λd∣Qd⊤W_{1/2} W_{1/2}^\top = Q_d \lvert \Lambda_d \rvert Q_d^\top, which equals MdM_d exactly when λ1,…,λd≥0\lambda_1, \dots, \lambda_d \ge 0, and
∥Qd∣Λd∣Qd⊤−Md∥F=2(∑i≤d, λi<0λi2)1/2.\bigl\lVert Q_d \lvert \Lambda_d \rvert Q_d^\top - M_d \bigr\rVert_F = 2 \Bigl(\sum_{i \le d,\ \lambda_i \lt 0} \lambda_i^2\Bigr)^{1/2}.
Proof.

Part 1 is substitution, and the optimality is the Eckart–Young–Mirsky theorem (Eckart and Young 1936; Mirsky 1960; formalML, Singular Value Decomposition, Theorem 2). For part 2, MM⊤=UΣ2U⊤M M^\top = U \Sigma^2 U^\top with UU orthonormal, so (MM⊤)p=UΣ2pU⊤(M M^\top)^p = U \Sigma^{2p} U^\top is a spectral decomposition of a positive semidefinite matrix. A best rank-dd approximation keeps dd eigenpairs of largest eigenvalue, and since σ↦σ2p\sigma \mapsto \sigma^{2p} is nondecreasing, the first dd columns of UU are such a choice, which gives UdΣd2pUd⊤=WpWp⊤U_d \Sigma_d^{2p} U_d^\top = W_p W_p^\top. For part 3, the spectral theorem (formalML, The Spectral Theorem, Theorem 1) gives M=QΛQ⊤M = Q \Lambda Q^\top, and then σi=∣λi∣\sigma_i = \lvert \lambda_i \rvert, ui=qiu_i = q_i, and vi=sign⁡(λi) qiv_i = \operatorname{sign}(\lambda_i)\, q_i is a singular value decomposition. So W1/2W1/2⊤=∑i≤d∣λi∣qiqi⊤W_{1/2} W_{1/2}^\top = \sum_{i \le d} \lvert \lambda_i \rvert q_i q_i^\top while Md=∑i≤dλiqiqi⊤M_d = \sum_{i \le d} \lambda_i q_i q_i^\top. Their difference is ∑i≤d, λi<02∣λi∣qiqi⊤\sum_{i \le d,\ \lambda_i \lt 0} 2 \lvert \lambda_i \rvert q_i q_i^\top, whose Frobenius norm follows from the orthonormality of the qiq_i. Any other singular value decomposition changes UdU_d and VdV_d by one orthogonal matrix OO that commutes with Σd\Sigma_d, to UdOU_d O and VdOV_d O: sign flips of a pair (ui,vi)(u_i, v_i), or rotations within a group of equal singular values, which the gap ∣λd∣>∣λd+1∣\lvert \lambda_d \rvert \gt \lvert \lambda_{d+1} \rvert keeps inside the first dd. Then WpW_p and CpC_p become WpOW_p O and CpOC_p O, which changes none of these products.

∎

So a word vector’s dot product with a context vector approximates PMI whatever the weight, but its dot product with another word vector approximates something else: a weighted sum over shared contexts for p=1p = 1 (second-order co-occurrence, Schütze 1998), and, for a symmetric matrix and p=12p = \tfrac12, the matrix with every eigenvalue’s sign removed.

That last case is not academic. A symmetric window makes the unsmoothed PMI matrix symmetric (smoothing acts on the context side only), and the two-word PPMI matrix is strongly indefinite. Of its 100100 eigenvalues of largest magnitude, 4444 are negative, including the second, λ2=−83.9\lambda_2 = -83.9 (the first is λ1=137.4\lambda_1 = 137.4). At d=100d = 100 the half-power word-word matrix differs from MdM_d by 1.2481.248 times the norm of MdM_d itself. The eigenvector of λ2\lambda_2 shows why. Its two signs separate frequent words, each seen 184184 to 3,3623{,}362 times (and, in, alongside, toward, added, highlighted, and the nouns customers and markets), from rare made-up nouns seen 22 to 1212 times (channelline, nonreceivables, royaltyside, wellflow, …), and 58.7%58.7\% of the matrix’s PPMI mass joins the two sides. In a small window a rare word keeps company with frequent ones, and a nearly bipartite matrix has eigenvalues of both signs.

Corollary 1 (Adding context vectors keeps the positive part).

Let MM be symmetric, with ∣λd∣>∣λd+1∣\lvert \lambda_d \rvert \gt \lvert \lambda_{d+1} \rvert. For the singular value decomposition built from its eigendecomposition, W1/2+C1/2=2 Qd[Λd]+1/2W_{1/2} + C_{1/2} = 2\, Q_d \bigl[\Lambda_d\bigr]_+^{1/2}, where [⋅]+[\cdot]_+ zeroes the negative eigenvalues. For every singular value decomposition,

14(W1/2+C1/2)(W1/2+C1/2)⊤=∑i≤d, λi>0λi qiqi⊤,\tfrac14 \bigl(W_{1/2} + C_{1/2}\bigr)\bigl(W_{1/2} + C_{1/2}\bigr)^\top = \sum_{i \le d,\ \lambda_i \gt 0} \lambda_i\, q_i q_i^\top ,

the positive part of MdM_d.

Proof.

Take σi=∣λi∣\sigma_i = \lvert \lambda_i \rvert, ui=qiu_i = q_i, and vi=sign⁡(λi) qiv_i = \operatorname{sign}(\lambda_i)\, q_i, as in the proof of Theorem 2. Then σi (ui+vi)=∣λi∣ (1+sign⁡λi)qi\sqrt{\sigma_i}\,(u_i + v_i) = \sqrt{\lvert \lambda_i \rvert}\,\bigl(1 + \operatorname{sign} \lambda_i\bigr) q_i, which is zero for negative eigenvalues and 2λi qi2 \sqrt{\lambda_i}\, q_i for positive ones. Any other singular value decomposition replaces W1/2+C1/2W_{1/2} + C_{1/2} by (W1/2+C1/2) O(W_{1/2} + C_{1/2})\, O with OO orthogonal (the proof of Theorem 2), which leaves the product unchanged. The sum itself can change. If λj=−λi\lambda_j = -\lambda_i, then u=(qi+qj)/2u = (q_i + q_j)/\sqrt{2} and v=(qi−qj)/2v = (q_i - q_j)/\sqrt{2} are a singular pair for σi\sigma_i, and u+v=2 qiu + v = \sqrt{2}\, q_i.

∎

Levy, Goldberg, and Dagan (2015) recommended adding context vectors to word vectors as a heuristic. For a symmetric matrix, such as the unsmoothed PMI of a symmetric window, it is an exact operation: it projects out the negative eigenspace, the directions of the bipartite structure. On the corpus, at the setting where we checked Theorem 2 (two-word window, d=100d = 100, p=12p = \tfrac12, not tuned), adding the context vectors raises the sector-ranking score of the next section’s test nouns from 0.7120.712 to 0.7550.755, and their nearest-neighbor accuracy from 0.8090.809 to 0.8780.878.


Two kinds of low rank

Why should a co-occurrence matrix be approximately low rank at all? There are two classical answers, and they are not the same answer. Write RR for the matrix of ratios P(w,c)/(P(w)P(c))P(w, c)/\bigl(P(w)P(c)\bigr), so that PMI⁡=log⁡R\operatorname{PMI} = \log R entrywise.

Theorem 3 (Two kinds of low rank).

  1. Mixtures make the ratio low rank. Suppose words and contexts are independent given a latent class Z∈{1,…,K}Z \in \lbrace 1, \dots, K \rbrace, so that P(w,c)=∑zπzφz(w)ψz(c)P(w, c) = \sum_z \pi_z \varphi_z(w) \psi_z(c). Let Φ\Phi and Ψ\Psi hold the φz\varphi_z and ψz\psi_z as columns, Π=diag⁡(π)\Pi = \operatorname{diag}(\pi), and Dw,DcD_w, D_c the diagonal matrices of the marginals. Then
R=AΠB⊤,A=Dw−1Φ,B=Dc−1Ψ,R = A \Pi B^\top, \qquad A = D_w^{-1} \Phi, \quad B = D_c^{-1} \Psi,

so rank⁡R≤K\operatorname{rank} R \le K, and R−11⊤=A(Π−ππ⊤)B⊤R - \mathbf{1}\mathbf{1}^\top = A\bigl(\Pi - \pi\pi^\top\bigr) B^\top has rank at most K−1K - 1.

  1. Its PMI is low rank only to first order. If δ=max⁡w,c∣R(w,c)−1∣<1\delta = \max_{w,c} \lvert R(w, c) - 1 \rvert \lt 1, then
PMI⁡=∑n≥1(−1)n+1n(R−11⊤)∘n,\operatorname{PMI} = \sum_{n \ge 1} \frac{(-1)^{n+1}}{n} \bigl(R - \mathbf{1}\mathbf{1}^\top\bigr)^{\circ n},

where ∘n^{\circ n} is the entrywise power. The nn-th term has rank at most (K+n−2n)\binom{K + n - 2}{n}, and every entry of PMI⁡−(R−11⊤)\operatorname{PMI} - (R - \mathbf{1}\mathbf{1}^\top) is at most δ2/(2(1−δ))\delta^2 / \bigl(2(1 - \delta)\bigr) in absolute value.

  1. Log-bilinear models make the PMI low rank. If PMI⁡=XY⊤+a1⊤+1b⊤\operatorname{PMI} = X Y^\top + a \mathbf{1}^\top + \mathbf{1} b^\top with XX and YY of width dd, then rank⁡PMI⁡≤d+2\operatorname{rank} \operatorname{PMI} \le d + 2, while RR, its entrywise exponential, need not be low rank.
Proof.

(1) The word marginal is Φπ\Phi \pi, so Aπ=Dw−1Φπ=1A \pi = D_w^{-1} \Phi \pi = \mathbf{1}, and likewise Bπ=1B \pi = \mathbf{1}. Hence 11⊤=Aππ⊤B⊤\mathbf{1}\mathbf{1}^\top = A \pi \pi^\top B^\top, and R−11⊤=A(Π−ππ⊤)B⊤R - \mathbf{1}\mathbf{1}^\top = A(\Pi - \pi\pi^\top)B^\top. The middle factor sends 1\mathbf{1} to π−π=0\pi - \pi = 0, so its rank is at most K−1K - 1.

(2) Expand log⁡(1+x)\log(1 + x) in its series entrywise (formalCalculus, Power Series & Taylor Series). A matrix of rank rr is a sum ∑i≤raibi⊤\sum_{i \le r} a_i b_i^\top, and its nn-th entrywise power expands by the multinomial theorem into one rank-one term for each multiset {i1,…,in}\lbrace i_1, \dots, i_n \rbrace, namely a multiple of (ai1∘⋯∘ain)(bi1∘⋯∘bin)⊤(a_{i_1} \circ \cdots \circ a_{i_n})(b_{i_1} \circ \cdots \circ b_{i_n})^\top. There are (r+n−1n)\binom{r + n - 1}{n} such multisets (cf. Horn and Johnson 1991 on Hadamard products), and r=K−1r = K - 1. The remainder satisfies ∣log⁡(1+x)−x∣≤∑n≥2∣x∣n/2=x2/(2(1−∣x∣))\lvert \log(1 + x) - x \rvert \le \sum_{n \ge 2} \lvert x \rvert^n / 2 = x^2 / \bigl(2(1 - \lvert x \rvert)\bigr).

(3) A sum of a rank-dd matrix and two rank-one matrices has rank at most d+2d + 2.

∎

Part 1 is the aspect model of probabilistic latent semantic analysis (Hofmann 1999), and with Dirichlet priors on its components it becomes the latent Dirichlet allocation of the topic-models topic (Blei, Ng, and Jordan 2003). Part 3 is the form skip-gram and GloVe fit (Pennington, Socher, and Manning 2014), the subject of the word2vec and GloVe topics. The neural-language-models topic’s softmax bottleneck is part 3 for log-probabilities, and its escape, a mixture of softmaxes, escapes part 3 exactly the way part 1’s mixtures do. Part 2 says how the two hypotheses relate. For weak associations they coincide to first order, and they part ways as associations grow strong. On random mixtures with weakened association, the share of the PMI’s energy beyond rank K−1K - 1 falls like the square of the association’s strength.

The corpus’s generator is close to part 1’s model at the document level: every content noun in a document comes from that document’s sector vocabulary or from a shared one. Take the 115115 content nouns seen at least 2020 times and their document-level co-occurrences. They are not the benchmark’s 115115 test nouns below: 6363 of them come from the shared vocabulary. Of their pairs of distinct nouns, 15.3%15.3\% never co-occur. A six-sector mixture predicts that R−11⊤R - \mathbf{1}\mathbf{1}^\top has rank at most 55.

singular value, as a share of the first12345678
ratio R−11⊤R - \mathbf{1}\mathbf{1}^\top110.9630.9630.9240.9240.6170.6170.4210.4210.184\mathbf{0.184}0.1710.1710.1570.157
PPMI110.7490.7490.5880.5880.5470.5470.4920.4920.3440.3440.2400.2400.2130.213

The ratio matrix drops after the fifth singular value, to the level of noise: the shuffled corpus’s largest singular value for the same nouns is 0.1610.161 of the real one. The energy beyond rank 55 is 11.6%11.6\% for the ratio matrix and 27.8%27.8\% for PPMI. A topic model would find this structure more easily than an embedding would.


Recovering the planted sectors

The shared corpus’s generator draws each content noun from its document’s sector vocabulary or, half the time, from a vocabulary all sectors share, and each vocabulary grows by a Pitman–Yor process as the vocabulary-statistics topic described. Rebuilding the generator recovers which vocabulary every noun came from, which gives us a test with a known answer.

Definition 4 (The planted-sector benchmark).

The benchmark nouns are the training nouns drawn from exactly one sector vocabulary and seen at least five times. For a set of word vectors, the nearest-neighbor accuracy is the share of nouns whose nearest other noun, by cosine similarity (formalRAG, The Vector Space Model and TF-IDF), comes from the same sector. The pair AUC is the probability that a random same-sector pair of nouns has a higher cosine than a random pair from different sectors, with ties counting one half (Mann and Whitney 1947).

There are 227227 benchmark nouns: industrials 101101, technology 4040, banking 3535, energy 1818, retail 1717, and healthcare 1616. A seeded split within each sector sends 112112 to a dev set and 115115 to a test set. Within each family, sparse matrices and SVD embeddings, the setting with the best dev AUC is chosen before any test noun is scored. The families range over the contexts, the weightings (counts, PPMI, smoothed PPMI, and two shifts), and for SVD three base matrices, six ranks dd from 1010 to 300300, and p∈{0,12,1}p \in \lbrace 0, \tfrac12, 1 \rbrace. A noun’s nearest other noun, drawn at random from the remaining test nouns, would share its sector 26.2%26.2\% of the time.

One context is held out of the selection. The generator plants a noun’s sector at the document level, so document-level co-occurrence reads the label almost directly: even raw counts put every test noun’s nearest neighbor in its sector, with a pair AUC of 0.9920.992. We report it as an oracle and select among the local contexts, which are what embedding methods use. Document-level co-occurrence is SS⊤−diag⁡(S1)S S^\top - \operatorname{diag}(S \mathbf{1}), where SS is the term-document matrix whose SVD is latent semantic analysis (Deerwester et al. 1990; formalRAG, PCA as Optimal Linear Dimensionality Reduction). It is the Gram matrix of SS, less the pairs of a token with itself that Definition 1 excludes.

context (test nouns)counts: AUCcounts: nearest neighborPPMI: AUCPPMI: nearest neighbor
window of 110.4910.4910.3040.3040.5810.5810.6090.609
window of 220.5260.5260.5740.5740.7120.7120.8260.826
window of 440.5480.5480.6520.6520.7960.7960.9570.957
window of 880.5550.5550.6520.6520.8130.8130.9570.957
sentence0.5600.5600.6350.6350.8130.8130.9650.965
document (oracle)0.9920.9921.0001.0001.0001.0001.0001.000

PPMI beats counts at every context, as Theorem 1 predicts, and wider contexts recover more, because sector is a property of a whole document. Smoothing does not help: the selected sparse matrix is unsmoothed sentence-level PPMI, with dev AUC 0.7980.798 against 0.7930.793 for its smoothed twin.

selected on devdev AUCdev nearest neighbortest AUCtest nearest neighbor
sparse: sentence PPMI0.7980.7980.8660.8660.8130.8130.9650.965
SVD: window of 88, SPPMI⁡0.75,5\operatorname{SPPMI}_{0.75, 5}, d=25d = 25, p=0p = 00.9510.9510.9460.9460.973\mathbf{0.973}0.9650.965

On the test nouns, truncation raises the AUC by 0.1600.160, with a jackknife standard error of 0.0190.019 (Efron 1982), at an identical nearest-neighbor accuracy. What the SVD buys is global ranking. Sparse PPMI already puts each noun’s nearest neighbor in its sector 96.5%96.5\% of the time, but it ranks many cross-sector pairs above same-sector ones. The rank-2525 embedding orders nearly all pairs correctly.

The win is narrow. Only 5959 of the 270270 SVD settings beat the sparse matrix on test AUC, and 6262 on dev. For the selected base and weight, the test AUC by rank is 0.5240.524 at d=10d = 10, 0.9730.973 at 2525, 0.9480.948 at 5050, 0.7660.766 at 100100, 0.6310.631 at 200200, and 0.6010.601 at 300300, and dev and test peak at the same rank. With too few dimensions the leading directions are frequency and template structure (Proposition 2, Theorem 2), not sectors; with too many, noise directions dilute the cosine, most of all when p=0p = 0 weights every direction equally.

The 396396 sector nouns seen only two to four times were never used in any selection, so they are a second test. Their AUC is 0.5170.517 for counts, 0.5750.575 for sparse PPMI, and 0.7280.728 for the SVD; their nearest-neighbor accuracy is 0.3940.394, 0.7170.717, and 0.6570.657, against 21.4%21.4\% for chance. On rare words too, truncation improves the ranking and gives up a little at the nearest neighbor.


The company a word keeps, and the shape of the spectrum

The laboratory lets you check these claims yourself. In panel A, pick a word, a context, and a weighting, and read off its five nearest neighbors, each tagged with its planted sector or lexicon category, along with the test scores of that setting. Counts give template and frequency neighbors. PPMI gives sector neighbors once the window is wide enough. At the two-word window, strong’s neighbors include weak and soft, while the document context puts robust first. The SVD’s neighbors of loans, stores, trials, software, and orders are sector-pure. Production keeps the company of its template, crude production averaged … thousand barrels per day. Panel B shows the selected SVD’s scores as the rank varies; the real and shuffled spectra, where unshifted PPMI’s largest singular value is smaller than the shuffled corpus’s; the signed eigenvalues of the two-word matrix; and Theorem 3’s two spectra.

A · The company a word keeps — nearest neighbors by context and weighting
strongpositive· window 2 · PPMI
improved0.41positive
stronger0.37positive
healthy0.36positive
weak0.36negative
soft0.34negative
sector-ranking AUC, test nouns
0.712
nearest neighbor in sector, test nouns
0.826
chance
0.262
polarity from SO, this context
0.500
polarity words with any evidence
0.000
planted sectors:industrialstechnologybankingenergyretailhealthcare· stand-in lexicon:positivenegativeuncertaintylitigiouspolyseme· common: the shared vocabulary

Neighbors are drawn from the training words seen at least five times. The scores are for the window 2 setting on the 115 test nouns; the document context reads the planted sector directly, so it was never eligible for selection. For polarity words, SO is Turney’s semantic orientation against the other stand-in polarity words: windows give no evidence, sentences point the wrong way, documents get it right.


B · Rank and spectrum — where truncation helps, and what the singular values hold
501001255075100singular values, window 2, PPMI — solid: real textdashed: tokens shuffled
largest singular value, real
137.4
largest singular value, shuffled
155.3
-137137eigenvalues of window-2 PPMI by magnitude: 44 of 100 negative (gold)00.51151015Theorem 3, frequent nouns at the document level: solid, ratio R − 11ᵀ; dashed gold, PPMIplanted rank 5 | dotted: shuffled-corpus noise
energy beyond rank 5, ratio
11.6%
energy beyond rank 5, PPMI
27.8%

Unshifted PPMI's largest singular value is smaller than a shuffled corpus's: at this scale most of its energy is noise (Proposition 3). Shifting by log 5 puts the real spectrum on top. Nearly half the large eigenvalues are negative, which half-power word vectors misread (Theorem 2). For the document-level nouns, the ratio matrix shows the planted rank and PPMI smears it.


Finance case study: what distribution cannot see


Where this goes next

  • Word2vec. Skip-gram with negative sampling learns word and context vectors whose dot products, at the optimum and on observed pairs, equal PMI⁡α−log⁡k\operatorname{PMI}_\alpha - \log k, the unclipped shifted matrix of Definition 2. The word2vec topic proves it under the conditions it states. Its customary sum of word and context vectors is Corollary 1’s projection only approximately, for balanced factors of a symmetric product, and with α=0.75\alpha = 0.75 the target is not symmetric.
  • GloVe. GloVe fits a log-bilinear model to log co-occurrence counts, the form of Theorem 3’s third part.
  • Topic models. Latent Dirichlet allocation is Theorem 3’s first part with priors: low rank in the ratio, not in the PMI.
  • Contextual embeddings. One vector per word type cannot separate liability the accounting term from liability the risk, or tell strong from weak by their windows. Contextual embeddings give each token its own vector.
  • Lexicon sentiment. The lexicon-sentiment topic takes up polarity directly, with the real Loughran–McDonald dictionary fetched at run time.
  • Collocations. Dunning’s likelihood-ratio test separates association from the rare-pair noise of Proposition 3.

Honest caveats


Implementation

The companion notebook (notebookPath) imports distributional_semantics_ppmi_svd.py, which owns every number on this page. It imports the vocabulary-statistics topic’s frequency spectrum and Zipf law, the n-gram topic’s sentence splitter, and the shared finance corpus, whose generator it reruns to recover the planted sectors. Running it as a script executes a harness of 1616 assertion-based tests in about ten seconds on a laptop CPU. The tests cover:

  • Definition 1 against a direct double loop, and the symmetry of every matrix; Proposition 1 on random joint distributions, against scipy.stats.entropy; Theorem 1’s two rates on random instances, and the corpus cosines.
  • Proposition 2 exactly on every pair seen once; Proposition 3 by exact Poisson sums, by Monte Carlo with Zipf margins, and against the shuffled corpus; Proposition 4’s threshold and nested supports.
  • The sparse SVD against numpy.linalg.svd; Theorem 2 and Corollary 1 on random rectangular, positive semidefinite, and indefinite matrices, on a tied pair λj=−λi\lambda_j = -\lambda_i under every SVD, and on the corpus; Theorem 3 on random mixtures, weakened mixtures, and log-bilinear models, and on the corpus’s nouns.
  • The pair AUC against scipy.stats.mannwhitneyu; the chance levels against a direct count; the recovery tables, the selection, and the narrowness of the SVD’s win; and the finance case study.

The laboratory reads its data from a JSON file that one of those tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.

References & Further Reading