intermediate representations 40 min read

word2vec as Implicit Matrix Factorization

Skip-gram's three objectives share one optimum up to offsets, shifted PMI; negative sampling fits it by a count-weighted logistic PCA; and since the loss sees only the product of word and context vectors, the optimizer's balance, not the objective, decides which similarities we get

Overview & Motivation

Train word2vec on the finance corpus with an eight-word window, five negative samples, and 2525 dimensions. Then take every pair of words that occurs together in the training text and compare the dot product of the first word’s vector with the second word’s context vector against the shifted pointwise mutual information of the distributional-semantics topic. For the 816816 pairs seen at least 100100 times, the two agree with correlation 0.9850.985. For the 98,92698{,}926 pairs seen once, the correlation is 0.6410.641. Word2vec never forms a co-occurrence matrix, yet it fits one, and how closely depends on how often the pair was seen.

Now take that trained model and change the basis of its vectors: replace the word vectors WW by WAWA and the context vectors CC by CA−⊤CA^{-\top} for an invertible matrix AA. Every word–context dot product, and therefore the training loss, is unchanged. The word–word similarities are not. Over five such factorizations of the one trained product, the score for grouping nouns by their planted sector ranges from 0.7370.737 to 0.9010.901, and the nearest neighbors of strong change. The objective does not decide which words are similar.

This topic proves both halves of that picture.

  1. The objective chooses the matrix. Skip-gram’s three training objectives, a full softmax, noise-contrastive estimation, and negative sampling, all have optima equal to pointwise mutual information (PMI) up to row and column offsets. Negative sampling’s is exactly PMI⁡α−log⁡k\operatorname{PMI}_\alpha - \log k on observed pairs, and unobserved pairs have no optimum (Levy and Goldberg 2014).
  2. At low rank, negative sampling is a weighted logistic PCA. The loss is exactly a count-weighted sum of Bernoulli KL divergences, so frequent pairs are fitted closely and rare ones loosely. A truncated SVD of shifted PMI weights every entry alike.
  3. The optimizer chooses the factorization. The loss sees only the product WC⊤WC^\top, so it fixes word similarity only up to a change of basis. Gradient flow conserves W⊤W−C⊤CW^\top W - C^\top C, and balanced factors are the square-root weighting of the distributional-semantics topic, with word plus context vectors equal to the positive part of a symmetric product.

Then we test what the factorization buys on the planted-sector benchmark, and the finance case study asks whether it finds a polarity direction that the window counts do not carry.


Three objectives, one matrix

Fix a window context, the two-word window L2 or the eight-word window L8, and write #(w,c)\#(w, c) for the distributional-semantics topic’s pair counts (its Definition 1), #(w)=∑c#(w,c)\#(w) = \sum_c \#(w, c), and N=∑w,c#(w,c)N = \sum_{w, c} \#(w, c). With L8 there are N=576,098N = 576{,}098 pair occurrences over 143,345143{,}345 observed cells, 1.22%1.22\% of the 3,42523{,}425^2 possible pairs; with L2, 215,948215{,}948 over 53,29353{,}293, 0.45%0.45\%. The smoothed context distribution is Pα(c)=#(c)α/∑c′#(c′)αP_\alpha(c) = \#(c)^\alpha / \sum_{c'} \#(c')^\alpha, with the context counts taken as column sums.

A word gets a vector ww∈Rd\mathbf{w}_w \in \mathbb{R}^d and, separately, every word gets a context vector cc∈Rd\mathbf{c}_c \in \mathbb{R}^d. They are the rows of two matrices W,C∈RV×dW, C \in \mathbb{R}^{V \times d}; in this topic CC always means the context matrix. The score of a pair is xwc=⟨ww,cc⟩x_{wc} = \langle \mathbf{w}_w, \mathbf{c}_c \rangle, so the matrix of all scores is X=WC⊤X = W C^\top, a matrix of rank at most dd. Each objective below asks this matrix to predict the counts.

Definition 1 (Skip-gram with a full softmax).

The skip-gram model predicts each context from its word by a softmax over all contexts (Mikolov et al. 2013a), and is trained by minimizing

Lsoft(X)=−∑w,c#(w,c)log⁡exwc∑c′exwc′.L_{\text{soft}}(X) = -\sum_{w, c} \#(w, c) \log \frac{e^{x_{wc}}}{\sum_{c'} e^{x_{wc'}}} .

The softmax needs a sum over the whole vocabulary for every training pair. Negative sampling replaces it with a few binary decisions.

Definition 2 (Skip-gram with negative sampling).

Let σ(x)=1/(1+e−x)\sigma(x) = 1/(1 + e^{-x}) and k≥1k \ge 1. Each observed pair (w,c)(w, c) is a positive example, and for each one we draw kk negative contexts c1,…,ckc_1, \dots, c_k independently from the noise distribution Pn=PαP_n = P_\alpha. The sampled loss of the pair is −log⁡σ(xwc)−∑i≤klog⁡σ(−xwci)-\log \sigma(x_{wc}) - \sum_{i \le k} \log \sigma(-x_{wc_i}). Its expectation, summed over all NN pairs, is the negative-sampling objective

LNS(X)=−∑w,c[awclog⁡σ(xwc)+bwclog⁡σ(−xwc)],awc=#(w,c),bwc=k #(w) Pα(c).L_{\text{NS}}(X) = -\sum_{w, c} \Bigl[ a_{wc} \log \sigma(x_{wc}) + b_{wc} \log \sigma(-x_{wc}) \Bigr], \qquad a_{wc} = \#(w, c), \quad b_{wc} = k\, \#(w)\, P_\alpha(c).

Here bwcb_{wc} is the expected number of times the pair (w,c)(w, c) is drawn as a negative (Mikolov et al. 2013b; Goldberg and Levy 2014). Word2vec’s exponent is α=0.75\alpha = 0.75, the same smoothing the distributional-semantics topic studied in its Proposition 4.

Definition 3 (Noise-contrastive estimation).

Noise-contrastive estimation (NCE) treats xwcx_{wc} as an unnormalized log⁡P(c∣w)\log P(c \mid w) and trains a classifier to tell data pairs from noise pairs, with logit swc=xwc−log⁡(kPn(c))s_{wc} = x_{wc} - \log\bigl(k P_n(c)\bigr) (Gutmann and Hyvärinen 2010, 2012; Mnih and Teh 2012). Its objective LNCEL_{\text{NCE}} is LNSL_{\text{NS}} with xwcx_{wc} replaced by swcs_{wc}.

The difference between the two binary objectives is a single subtracted term. To see what it changes, we find each objective’s optimum when the scores are unconstrained, one free number per cell. The softmax comes first.

Proposition 1 (The softmax optimum).

For a word with #(w)>0\#(w) \gt 0, the row’s loss −∑c#(w,c)log⁡softmax⁡(xw⋅)c-\sum_c \#(w, c) \log \operatorname{softmax}(x_{w \cdot})_c attains its infimum exactly when #(w,c)>0\#(w, c) \gt 0 for every context cc. Its minimizers are then

xwc=log⁡P(c∣w)+κw=PMI⁡(w,c)+log⁡P(c)+κwx_{wc} = \log P(c \mid w) + \kappa_w = \operatorname{PMI}(w, c) + \log P(c) + \kappa_w

for an arbitrary constant κw\kappa_w. If some #(w,c)=0\#(w, c) = 0, the infimum is approached as xwc→−∞x_{wc} \to -\infty and never attained.

Proof.

With P(c∣w)=#(w,c)/#(w)P(c \mid w) = \#(w, c)/\#(w), the row’s loss is #(w)\#(w) times the cross-entropy of P(⋅∣w)P(\cdot \mid w) relative to p=softmax⁡(xw⋅)p = \operatorname{softmax}(x_{w\cdot}). That is at least #(w)\#(w) times the entropy of P(⋅∣w)P(\cdot \mid w), with equality exactly when p=P(⋅∣w)p = P(\cdot \mid w) (Gibbs’ inequality; formalML, KL Divergence, Propositions 1–3). The softmax takes every value in the open simplex and is unchanged by adding a constant to xw⋅x_{w\cdot}, so the infimum is attained exactly when P(⋅∣w)P(\cdot \mid w) has no zeros, at the stated xx. If P(c∣w)=0P(c \mid w) = 0, no softmax reaches it, and the loss decreases toward its infimum as xwc→−∞x_{wc} \to -\infty.

∎

An unseen context has no best score, only better and better ones. This is the neural-language-models topic’s Corollary 1, that a never-seen target has no maximum-likelihood fit, applied one context at a time. Negative sampling inherits the same phenomenon in a sharper form.

Theorem 1 (The negative-sampling optimum).

For a,b>0a, b \gt 0, the function φ(x)=alog⁡σ(x)+blog⁡σ(−x)\varphi(x) = a \log \sigma(x) + b \log \sigma(-x) is strictly concave on R\mathbb{R}, with unique maximizer x⋆=log⁡(a/b)x^\star = \log(a/b). For a=0<ba = 0 \lt b, φ\varphi increases strictly toward 00 as x→−∞x \to -\infty and has no maximizer. Hence, for unconstrained scores, LNSL_{\text{NS}} separates into one such function per cell, it has a minimizer exactly when every pair is observed, and on observed pairs the minimizer is

xwc⋆=log⁡#(w,c)k #(w) Pα(c)=PMI⁡α(w,c)−log⁡k.x^\star_{wc} = \log \frac{\#(w, c)}{k\, \#(w)\, P_\alpha(c)} = \operatorname{PMI}_\alpha(w, c) - \log k .
Proof.

Since ddxlog⁡σ(x)=σ(−x)\tfrac{d}{dx} \log \sigma(x) = \sigma(-x), we get φ′(x)=aσ(−x)−bσ(x)\varphi'(x) = a \sigma(-x) - b \sigma(x) and φ′′(x)=−(a+b) σ(x)σ(−x)<0\varphi''(x) = -(a + b)\, \sigma(x) \sigma(-x) \lt 0. The equation φ′(x)=0\varphi'(x) = 0 says σ(−x)/σ(x)=e−x=b/a\sigma(-x)/\sigma(x) = e^{-x} = b/a, so x⋆=log⁡(a/b)x^\star = \log(a/b). For a=0a = 0, φ′(x)=−bσ(x)<0\varphi'(x) = -b \sigma(x) \lt 0 everywhere, and φ(x)→0\varphi(x) \to 0 as x→−∞x \to -\infty. Finally, with P(w,c)=#(w,c)/NP(w, c) = \#(w, c)/N and P(w)=#(w)/NP(w) = \#(w)/N, log⁡(a/b)=log⁡P(w,c)P(w)Pα(c)−log⁡k\log\bigl(a/b\bigr) = \log \frac{P(w, c)}{P(w) P_\alpha(c)} - \log k, which is the distributional-semantics topic’s Definition 2.

∎

This is Levy and Goldberg’s (2014) theorem, and its matrix is the one the distributional-semantics topic named and did not prove anything about: the unclipped shifted PMI. The theorem has a reading in terms of classifiers. σ(x⋆)=a/(a+b)\sigma(x^\star) = a/(a + b) is the probability that a pair with these counts came from the data rather than from the noise, when the prior odds of data to noise are 1/k1/k. So the optimal score is the log density ratio of data pairs to noise pairs plus the log prior odds, the identity of formalML’s Density Ratio Estimation (its Theorem 4). That page states the identity for the Bayes classifier; Theorem 1 is the proof that the logistic loss reaches it, cell by cell. Each cell is a logistic regression with a canonical link (formalStatistics, Generalized Linear Models, Theorem 1), which is why the optimum is unique.

Proposition 2 (NCE and negative sampling fit one matrix up to offsets).

Under Theorem 1’s hypotheses, NCE’s optimum is xNCE⋆=log⁡P(c∣w)x^\star_{\text{NCE}} = \log P(c \mid w), with no free row constant, and

xNCE⋆(w,c)−xNS⋆(w,c)=log⁡(kPn(c)),x^\star_{\text{NCE}}(w, c) - x^\star_{\text{NS}}(w, c) = \log\bigl(k P_n(c)\bigr),

an offset that depends on the context alone. Every optimum is PMI⁡\operatorname{PMI} (with α=1\alpha = 1) plus a matrix constant along rows plus a matrix constant along columns:

objectiverow offsetcolumn offset
full softmaxκw\kappa_w (any)log⁡P(c)\log P(c)
noise-contrastive estimation00log⁡P(c)\log P(c)
negative sampling00log⁡P(c)−log⁡Pα(c)−log⁡k\log P(c) - \log P_\alpha(c) - \log k

So every optimum has rank at most rank⁡(PMI⁡)+2\operatorname{rank}(\operatorname{PMI}) + 2.

Proof.

Theorem 1 applied to the logit ss gives s⋆=log⁡(a/b)s^\star = \log(a/b), so xNCE⋆=log⁡(a/b)+log⁡(kPn(c))=log⁡(#(w,c)/#(w))=log⁡P(c∣w)x^\star_{\text{NCE}} = \log(a/b) + \log\bigl(k P_n(c)\bigr) = \log\bigl(\#(w, c)/\#(w)\bigr) = \log P(c \mid w). Subtracting xNS⋆=log⁡(a/b)x^\star_{\text{NS}} = \log(a/b) gives the offset. The table follows from log⁡P(c∣w)=PMI⁡(w,c)+log⁡P(c)\log P(c \mid w) = \operatorname{PMI}(w, c) + \log P(c) and PMI⁡α=PMI⁡+log⁡P(c)−log⁡Pα(c)\operatorname{PMI}_\alpha = \operatorname{PMI} + \log P(c) - \log P_\alpha(c), and a row-constant or column-constant matrix has rank one.

∎

Negative sampling is NCE with the noise correction log⁡(kPn(c))\log(k P_n(c)) dropped (Dyer 2014). The two do not estimate the same thing: NCE recovers the conditional distribution P(c∣w)P(c \mid w) itself (Mnih and Kavukcuoglu 2013), and negative sampling recovers an association score. But they differ by a context offset, and a model with a bias term per context could absorb it. This is the neural-language-models topic’s Theorem 6 in another guise: a log-bilinear model with biases has a score matrix of rank at most d+2d + 2, and all three objectives ask for PMI in that form, which is the third part of the distributional-semantics topic’s Theorem 3.

The binary objective also differs from the softmax contrastive loss that formalRAG studies. There, the optimal critic of InfoNCE is PMI only up to a constant per query (formalRAG, InfoNCE and the Contrastive Objective, the proof of Theorem 1). Negative sampling’s logit is pinned: its constant is −log⁡k-\log k, and nothing else.


What negative sampling minimizes at low rank

Theorem 1 describes a model with one free number per cell. Word2vec has 2Vd2Vd numbers for V2V^2 cells, with d=25d = 25 against V=3,425V = 3{,}425, and 98.8%98.8\% of the cells at the eight-word window have no optimum at all. So what does it fit?

Theorem 2 (Negative sampling is a weighted logistic PCA).

Let ywc=awc/(awc+bwc)y_{wc} = a_{wc}/(a_{wc} + b_{wc}), and let H(y)=−ylog⁡y−(1−y)log⁡(1−y)H(y) = -y \log y - (1 - y) \log(1 - y) be the Bernoulli entropy. For every score matrix XX,

LNS(X)−∑w,c(awc+bwc) H(ywc)=∑w,c(awc+bwc) KL⁡(Bern⁡(ywc) ∥ Bern⁡(σ(xwc))).L_{\text{NS}}(X) - \sum_{w, c} (a_{wc} + b_{wc})\, H(y_{wc}) = \sum_{w, c} (a_{wc} + b_{wc})\, \operatorname{KL}\bigl(\operatorname{Bern}(y_{wc}) \,\Vert\, \operatorname{Bern}(\sigma(x_{wc}))\bigr).

So inf⁡LNS=∑(a+b)H(y)\inf L_{\text{NS}} = \sum (a + b) H(y), and fitting a rank-dd matrix X=WC⊤X = WC^\top is a weighted KL projection of the target x⋆=log⁡(a/b)x^\star = \log(a/b) onto the rank-dd matrices. On an observed cell, each term is (a+b)(a + b) times the Bregman divergence of the softplus A(x)=log⁡(1+ex)A(x) = \log(1 + e^x),

DA(x,x⋆)=A(x)−A(x⋆)−σ(x⋆)(x−x⋆),D_A(x, x^\star) = A(x) - A(x^\star) - \sigma(x^\star)(x - x^\star),

and the cell’s loss has curvature (a+b) σ(x⋆)σ(−x⋆)=ab/(a+b)(a + b)\, \sigma(x^\star) \sigma(-x^\star) = ab/(a + b) at its optimum.

Proof.

Factor a+ba + b out of one cell: −alog⁡σ(x)−blog⁡σ(−x)=(a+b)[−ylog⁡σ(x)−(1−y)log⁡(1−σ(x))]-a \log \sigma(x) - b \log \sigma(-x) = (a + b)\bigl[-y \log \sigma(x) - (1 - y) \log\bigl(1 - \sigma(x)\bigr)\bigr], a Bernoulli cross-entropy, which equals H(y)+KL⁡(Bern⁡(y)∥Bern⁡(σ(x)))H(y) + \operatorname{KL}\bigl(\operatorname{Bern}(y) \Vert \operatorname{Bern}(\sigma(x))\bigr) (formalML, KL Divergence, Proposition 1). The Bernoulli family in its natural parameter xx has log-partition AA and mean A′=σA' = \sigma, and for an exponential family the KL divergence between members is the Bregman divergence of the log-partition (formalML, Information Geometry, Definition 8, in the natural coordinates of its Theorem 5), with σ(x⋆)=y\sigma(x^\star) = y. The curvature is (a+b)A′′(x⋆)=(a+b)σ(x⋆)σ(−x⋆)(a + b) A''(x^\star) = (a + b)\sigma(x^\star)\sigma(-x^\star), and σ(x⋆)=a/(a+b)\sigma(x^\star) = a/(a + b).

∎

An exponential-family PCA (Collins, Dasgupta, and Schapire 2001) is a low-rank fit of natural parameters under the family’s own divergence. With the Bernoulli family it is logistic PCA, and Landgraf and Bellay (2017) observed that negative sampling is exactly this, with a weight a+ba + b on every cell. The weights are what separate it from the distributional-semantics topic’s SVD.

Corollary 1 (Against the truncated SVD).

A truncated SVD of SPPMI⁡α,k\operatorname{SPPMI}_{\alpha,k} minimizes ∑w,c(max⁡(xwc⋆,0)−xwc)2\sum_{w, c} \bigl(\max(x^\star_{wc}, 0) - x_{wc}\bigr)^2 over rank-dd matrices, with equal weight on every cell (Eckart and Young 1936; formalML, Singular Value Decomposition, Theorem 2). Negative sampling minimizes ∑(a+b) DA(x,x⋆)\sum (a + b)\, D_A(x, x^\star), and it differs in three ways.

  1. It weights by counts. Near the optimum, (a+b)DA(x,x⋆)=12aba+b(x−x⋆)2+O((x−x⋆)3)(a + b) D_A(x, x^\star) = \tfrac12 \tfrac{ab}{a + b} (x - x^\star)^2 + O\bigl((x - x^\star)^3\bigr), a least-squares fit with weight aba+b\tfrac{ab}{a + b}, and 12min⁡(a,b)≤aba+b≤min⁡(a,b)\tfrac12 \min(a, b) \le \tfrac{ab}{a + b} \le \min(a, b).
  2. It pushes unobserved cells down instead of clipping them. An unobserved cell has y=0y = 0 and pays blog⁡(1+ex)b \log(1 + e^{x}), which keeps decreasing as x→−∞x \to -\infty.
  3. It keeps negative targets. An observed pair with x⋆<0x^\star \lt 0 is fitted at x⋆x^\star, not at 00.
Proof.

Part 1 is the second-order Taylor expansion of the cell’s loss at its optimum (formalCalculus, The Hessian, Theorem 3), with Theorem 2’s curvature; that theorem gives a remainder of o((x−x⋆)2)o\bigl((x - x^\star)^2\bigr), and since the cell’s loss is infinitely differentiable, Taylor’s theorem with the third derivative bounds it by O((x−x⋆)3)O\bigl((x - x^\star)^3\bigr). The bounds follow from ab/(a+b)=min⁡(a,b)⋅max⁡(a,b)/(a+b)ab/(a + b) = \min(a, b) \cdot \max(a, b)/(a + b) and max⁡(a,b)≤a+b≤2max⁡(a,b)\max(a, b) \le a + b \le 2 \max(a, b). Parts 2 and 3 are Definition 2 with a=0a = 0, and Theorem 1.

∎

So a pair seen once can count for no more than once, however large its PMI, while the SVD weighs its clipped PMI like any other entry. The corpus shows the predicted ordering. Train the model described in the overview (L8, k=5k = 5, α=0.75\alpha = 0.75, d=25d = 25, 4040 epochs) and compare xwc=⟨ww,cc⟩x_{wc} = \langle \mathbf{w}_w, \mathbf{c}_c \rangle with xwc⋆=PMI⁡0.75(w,c)−log⁡5x^\star_{wc} = \operatorname{PMI}_{0.75}(w, c) - \log 5 on every observed pair, grouped by count.

times the pair was seenpairscorrelation of xx with x⋆x^\starmean ∣x−x⋆∣\lvert x - x^\star \rvert
once98,92698{,}9260.6410.6411.2971.297
22 to 4427,99427{,}9940.8180.8180.5370.537
55 to 191912,20012{,}2000.9400.9400.2910.291
2020 to 99993,4093{,}4090.9790.9790.1980.198
100100 or more8168160.9850.9850.1390.139

The correlation rises and the error falls with every band. The ordering is Corollary 1’s; the levels are partly unfinished training, since the correlation for pairs seen once was 0.4780.478 after 1010 epochs. Most observed pairs, 69%69\%, are seen once, so most of the matrix is fitted loosely. The unobserved cells, which have no target, are pushed far down: over all 11.611.6 million of them the mean score is −5.18-5.18, against −0.63-0.63 for observed pairs, and 97.8%97.8\% of them score below the median observed pair.

Training has not finished: the loss was still falling when it stopped, from 1.8261.826 per pair after 1010 epochs to 1.65141.6514 after 4040. It ends 0.1760.176 per pair above Theorem 2’s floor of 1.47521.4752, but not all of that gap is unfinished training. The floor is an infimum that no finite score attains: the unobserved cells reach it only at −∞-\infty, and 0.0910.091 of the gap sits on them; a rank-2525 matrix cannot reach every observed target either.

Where does −5.18-5.18 come from? The product’s top singular vectors have one sign on every word and the opposite sign on every context, so the leading term σ1u1v1⊤\sigma_1 u_1 v_1^\top is negative in every entry. It carries 87.4%87.4\% of ∥WC⊤∥F2\lVert WC^\top \rVert_F^2, its leading singular value is 6.36.3 times the next, and its mean entry is −5.15-5.15, the level of the unobserved cells. Word2vec has no bias terms, but Proposition 2 says its optimum wants offsets, and Theorem 1 says the 98.8%98.8\% of cells that were never observed want −∞-\infty. The model spends one of its 2525 dimensions on a near-constant offset, negative in every entry, that pushes everything down.


The algorithm

So far the objective has been the expectation of what word2vec computes. Here is what it computes.

Definition 4 (Word2vec's stochastic gradient descent).

Each epoch visits the NN observed pairs in a fresh random order, in minibatches of 512512. Each pair draws k=5k = 5 negatives from PαP_\alpha, and the parameters take one gradient step on the minibatch’s summed sampled loss. The step size decays linearly from η0=0.05\eta_0 = 0.05 to 10−4η010^{-4}\eta_0 over training. Initialization follows the word2vec C code: the entries of WW are uniform on [−12d,12d][-\tfrac{1}{2d}, \tfrac{1}{2d}], and C=0C = 0.

The sampled loss is an unbiased estimate of LNSL_{\text{NS}}, by linearity of expectation over the negatives, so its gradient is an unbiased estimate of the objective’s gradient. Two departures from the C code are worth stating. The code updates after every pair, from several threads without locks, while we sum the gradients of a minibatch; and we train for 4040 epochs (the comparison grid below, 2020), many more than the C code’s default of five, because our corpus is small.

Remark.

The shipped word2vec also samples each window’s width uniformly from 11 to LL and discards frequent words at random before forming windows. Both change the counts #(w,c)\#(w, c), the first by weighting a pair at distance δ\delta by (L−δ+1)/L(L - \delta + 1)/L, and leave the form of the objective alone. Levy, Goldberg, and Dagan (2015) showed that both transfer to count-based methods. We train on the distributional-semantics topic’s unweighted counts so that Theorem 1’s target is exactly that topic’s matrix.


Gauge and balance

Every objective above is a function of the product X=WC⊤X = W C^\top. That leaves something undetermined.

Proposition 3 (Every factorization of one product).

If W′C′⊤=WC⊤W' C'^\top = W C^\top and all four matrices have full column rank dd, then W′=WAW' = WA and C′=CA−⊤C' = C A^{-\top} for a unique invertible AA. Consequently every objective of Definitions 1–3 determines the matrix of word–word dot products only up to WMW⊤W M W^\top with M=AA⊤M = A A^\top an arbitrary positive definite matrix, and word–word dot products are preserved exactly when AA is orthogonal.

Proof.

The columns of W′W' and of WW both span the column space of the product, so W′=WAW' = WA for some AA, invertible because both have rank dd. Then WAC′⊤=WC⊤W A C'^\top = W C^\top, and multiplying by a left inverse of WW gives AC′⊤=C⊤A C'^\top = C^\top, so C′=CA−⊤C' = C A^{-\top}. Finally, WMW⊤=WW⊤W M W^\top = W W^\top with WW of full column rank forces M=IM = I.

∎

The same freedom appears in every model whose score is an inner product of two learned embeddings, including the dual encoders of retrieval (formalRAG, Dense Retrieval and Dual Encoders, Theorem 2, for the rank ceiling such scores share). For word vectors it matters, because word similarity is a cosine between rows of WW, which no part of the loss sees. The trained model shows how much it matters. Take its product, with singular value decomposition UΣV⊤U \Sigma V^\top, and refactor it four ways: the distributional-semantics topic’s eigenvalue weights W=UΣpW = U\Sigma^p, C=VΣ1−pC = V \Sigma^{1 - p} for p=0,12,1p = 0, \tfrac12, 1, and a random AA with condition number 100100. All five have the same product to ten digits, and so the same loss.

factorization of the one producttest AUCtest nearest neighbornearest neighbors of strong
as trained0.8860.8860.8520.852weak, unfavorable, solid, soft, healthy
p=0p = 00.8490.8490.8780.878unfavorable, weak, soft, resilient, disappointing
p=12p = \tfrac120.901\mathbf{0.901}0.8520.852weak, unfavorable, solid, resilient, soft
p=1p = 10.8900.8900.8430.843weak, unfavorable, solid, healthy, efficient
random AA, condition number 1001000.7370.7370.6700.670adverse, healthy, unfavorable, solid, confident

The scores are those of the planted-sector benchmark of the next section. So which factorization does training produce? The answer comes from the optimizer, and it is cleanest for gradient flow, the limit of gradient descent with infinitesimal steps (formalCalculus, First-Order ODEs), where a conservation law found for deep linear networks applies verbatim (Du, Hu, and Lee 2018; Arora, Cohen, and Hazan 2018).

Theorem 3 (Gradient flow conserves the imbalance).

Let L(W,C)=f(WC⊤)L(W, C) = f(W C^\top) for a differentiable ff, and write G=∇f(X)G = \nabla f(X). Along the gradient flow W˙=−GC\dot W = -G C, C˙=−G⊤W\dot C = -G^\top W, the d×dd \times d matrix

D=W⊤W−C⊤CD = W^\top W - C^\top C

is constant. A gradient step of size η\eta, with ∇W=G^C\nabla_W = \hat G C and ∇C=G^⊤W\nabla_C = \hat G^\top W for any matrix G^\hat G, including a minibatch’s sampled gradient, changes it by exactly

Dt+1−Dt=η2(∇W⊤∇W−∇C⊤∇C).D_{t+1} - D_t = \eta^2 \bigl( \nabla_W^\top \nabla_W - \nabla_C^\top \nabla_C \bigr).
Proof.

ddtW⊤W=W˙⊤W+W⊤W˙=−C⊤G⊤W−W⊤GC\tfrac{d}{dt} W^\top W = \dot W^\top W + W^\top \dot W = -C^\top G^\top W - W^\top G C, and ddtC⊤C=−W⊤GC−C⊤G⊤W\tfrac{d}{dt} C^\top C = -W^\top G C - C^\top G^\top W, the same matrix. For the step, expand (W−η∇W)⊤(W−η∇W)−(C−η∇C)⊤(C−η∇C)(W - \eta \nabla_W)^\top (W - \eta \nabla_W) - (C - \eta \nabla_C)^\top(C - \eta \nabla_C): the first-order terms are −η(C⊤G^⊤W+W⊤G^C)-\eta(C^\top \hat G^\top W + W^\top \hat G C) from both products and cancel, and the second-order terms are as stated.

∎

If training starts balanced, with W⊤W=C⊤CW^\top W = C^\top C, gradient flow keeps it balanced. Balance determines the factorization up to a rotation.

Lemma 1 (Balanced factorizations).

Let X=UΣV⊤X = U \Sigma V^\top have rank dd and distinct singular values, and let WC⊤=XW C^\top = X with W⊤W=C⊤CW^\top W = C^\top C. Then W=UΣ1/2RW = U \Sigma^{1/2} R and C=VΣ1/2RC = V \Sigma^{1/2} R for an orthogonal matrix RR.

Proof.

Let B=W⊤W=C⊤CB = W^\top W = C^\top C, which is positive definite since WW has rank dd. Then XX⊤=WC⊤CW⊤=WBW⊤X X^\top = W C^\top C W^\top = W B W^\top. Write the thin SVD W=PSQ⊤W = P S Q^\top; then B=QS2Q⊤B = Q S^2 Q^\top and WBW⊤=PS4P⊤W B W^\top = P S^4 P^\top, which must equal XX⊤=UΣ2U⊤X X^\top = U \Sigma^2 U^\top. Both are eigendecompositions of one matrix with distinct eigenvalues, so S=Σ1/2S = \Sigma^{1/2} and P=UEP = U E for a diagonal sign matrix EE, and W=UΣ1/2RWW = U \Sigma^{1/2} R_W with RW=EQ⊤R_W = E Q^\top orthogonal. The same argument with X⊤X=CBC⊤X^\top X = C B C^\top gives C=VΣ1/2RCC = V \Sigma^{1/2} R_C. Then X=UΣ1/2RWRC⊤Σ1/2V⊤=UΣV⊤X = U \Sigma^{1/2} R_W R_C^\top \Sigma^{1/2} V^\top = U \Sigma V^\top forces Σ1/2RWRC⊤Σ1/2=Σ\Sigma^{1/2} R_W R_C^\top \Sigma^{1/2} = \Sigma, so RWRC⊤=IR_W R_C^\top = I.

∎

Corollary 2 (Balanced word vectors are the square-root weighting).

For balanced factors of XX:

  1. WW⊤=UΣU⊤W W^\top = U \Sigma U^\top, the distributional-semantics topic’s Definition 3 with p=12p = \tfrac12, applied to the matrix negative sampling fitted. Cosines between word vectors are those of UΣ1/2U \Sigma^{1/2}.
  2. If X=QΛQ⊤X = Q \Lambda Q^\top is symmetric, then 14(W+C)(W+C)⊤=[X]+\tfrac14 (W + C)(W + C)^\top = [X]_+, the positive part of XX.
Proof.

Part 1: by Lemma 1, WW⊤=UΣ1/2RR⊤Σ1/2U⊤W W^\top = U \Sigma^{1/2} R R^\top \Sigma^{1/2} U^\top. Part 2: for symmetric XX the singular vectors can be taken as ui=qiu_i = q_i and vi=sign⁡(λi) qiv_i = \operatorname{sign}(\lambda_i)\, q_i, so W+C=(U+V)Σ1/2R=2 Q[Λ]+1/2RW + C = (U + V)\Sigma^{1/2} R = 2\, Q [\Lambda]_+^{1/2} R, as in the distributional-semantics topic’s Corollary 1, and RR cancels in (W+C)(W+C)⊤(W + C)(W + C)^\top.

∎

This is the precise sense of that topic’s promise. Adding context vectors to word vectors, the heuristic of Levy, Goldberg, and Dagan (2015), is the projection onto the positive eigenspace, exactly for balanced factors of a symmetric product, and only up to a rotation that no cosine can see. We check the whole chain on a small symmetric instance. Gradient descent at full rank, started balanced, fits the optimum to 2⋅10−142 \cdot 10^{-14}, and 14(W+C)(W+C)⊤\tfrac14 (W + C)(W + C)^\top misses [X⋆]+[X^\star]_+ by at most 0.00420.0042 with step 0.020.02 and 0.00240.0024 with step 0.010.01: the error shrinks with the step, as Theorem 3 predicts.

The corpus is less tidy, and the page should say how. Word2vec’s initialization is nearly balanced: ∥D0∥\lVert D_0 \rVert is 1.3×10−41.3 \times 10^{-4} of the final ∥W⊤W∥\lVert W^\top W \rVert. But minibatch SGD with word2vec’s step sizes is not gradient flow. Theorem 3’s second-order terms add up: DD grows 1,8191{,}819-fold in the first epoch, keeps growing, and ends at 0.800.80 of ∥W⊤W∥\lVert W^\top W \rVert. What cosines depend on, though, is the basis change AA in W=UΣ1/2AW = U \Sigma^{1/2} A, which is orthogonal exactly for balanced factors. Its singular values lie in [0.800,1.206][0.800, 1.206] after the first epoch, in [0.788,1.204][0.788, 1.204] after the last, and in [0.786,1.215][0.786, 1.215] at every checkpoint, so it is nearly orthogonal throughout, and its smallest singular value lies mostly along the offset direction found above. The trained vectors score 0.8860.886 against 0.9010.901 for the exactly balanced UΣ1/2U \Sigma^{1/2}. The balanced reading holds, approximately. With α=0.75\alpha = 0.75 the target is not symmetric, so the corpus can check part 1 of Corollary 2 but not part 2.


Recovering the planted sectors

The distributional-semantics topic built a benchmark with a known answer: 227227 nouns that the corpus generator drew from exactly one of six sector vocabularies, split into 112112 dev nouns for choosing settings and 115115 test nouns for scoring (its Definition 4). The pair AUC is the probability that a same-sector pair of nouns has a higher cosine than a cross-sector pair, and the nearest-neighbor accuracy is the share of nouns whose nearest other noun shares their sector; chance for the latter is 0.2620.262. That topic’s best setting was a truncated SVD of SPPMI⁡0.75,5\operatorname{SPPMI}_{0.75,5} at the eight-word window with d=25d = 25, which is the matrix negative sampling with k=5k = 5 and α=0.75\alpha = 0.75 fits. So the first comparison holds the matrix and the rank fixed and changes only the method.

the same matrix, d=25d = 25dev AUCdev nearest neighbortest AUCtest nearest neighbor
negative sampling, 4040 epochs0.8700.8700.8660.8660.886\mathbf{0.886}0.8520.852
truncated SVD, p=0p = 0 (that topic’s selection)0.9510.9510.9460.9460.973\mathbf{0.973}0.9650.965
truncated SVD, p=12p = \tfrac120.9440.9440.9290.9290.9660.9660.9650.965

On the test nouns, negative sampling trails the SVD by 0.0870.087 in AUC, with a jackknife standard error of 0.0170.017, and by 0.1130.113 in nearest-neighbor accuracy, with a paired standard error of 0.0340.034. Averaging word and context vectors changes nothing here (0.8860.886 either way). The 396396 rarer sector nouns, seen two to four times and never used for any choice, give the same verdict: AUC 0.6520.652 for negative sampling against 0.7280.728 for the SVD, and nearest-neighbor accuracy 0.5930.593 against 0.6570.657.

Corollary 1 predicts the direction. On the benchmark nouns’ rows, pairs seen at most four times are 92.3%92.3\% of the observed pairs, and they carry 98.7%98.7\% of the squared mass of SPPMI⁡0.75,5\operatorname{SPPMI}_{0.75,5}, which the SVD fits with equal weight. They carry only 54.8%54.8\% of negative sampling’s weight ab/(a+b)ab/(a + b). A noun’s sector shows mostly in rare pairs with other sector words: pairs with a noun of the same sector carry 56.2%56.2\% of that squared mass, and 99.7%99.7\% of their share sits in pairs seen at most four times. Negative sampling, by design, trusts rare pairs less. Training longer helps: the same configuration trained for 2020 epochs instead of 4040 scores 0.8590.859.

A small grid gives negative sampling its own choice of window and dimension, selected on dev nouns by the same rule as before, with 2020 epochs each.

window, dimensiondev AUCdev nearest neighbortest AUCtest nearest neighbor
L2, d=25d = 250.7200.7200.6340.6340.7090.7090.5910.591
L2, d=100d = 1000.6970.6970.6430.6430.7230.7230.6520.652
L8, d=25d = 25 (selected)0.863\mathbf{0.863}0.8480.8480.8590.8590.7650.765
L8, d=100d = 1000.8300.8300.9200.9200.8330.8330.8870.887

The wider window wins, as it did for counts, because sector is a property of whole documents. The selected model beats the distributional-semantics topic’s best sparse matrix (0.8130.813) in AUC and trails its SVD by 0.1140.114 (standard error 0.0210.021). On this corpus, at this budget, the count-based method with a truncated SVD is the better reader of planted sectors.


One cell, and the factorization training picks

The laboratory makes both halves of the topic concrete. Panel A shows one cell of the objective: pick one of six contexts of revenue, its most associated context in each count band, from a pair seen once to a pair seen 129129 times, plus the most frequent context it never meets, and the curve is that cell’s loss. Its minimum sits at PMI⁡α−log⁡k\operatorname{PMI}_\alpha - \log k and moves by log⁡3\log 3 when you change kk from 55 to 1515; its width is set by the weight ab/(a+b)ab/(a + b); and the dot marks what the trained model actually learned. The pair seen once, revenue with plantline, has weight 0.340.34 and is fitted badly (learned −0.91-0.91, target 0.660.66); revenue with fiscal, seen 5353 times, is fitted almost exactly. The context outlook, never seen with revenue, has no minimum at all. Panel B follows training: drag the epoch slider and watch frequent pairs reach the diagonal first while rare pairs stay scattered and unobserved cells sink. Its second view shows the five factorizations of one product, with their scores and the neighbors of strong and loans.

A · One cell of the objective — the loss of one (word, context) pair as a function of its score
0123-8-6-4-20246loss above its minimum, revenue·plantline · dashed: x* = PMI_α − log kscore x = ⟨word vector, context vector⟩
times seen, a
1
expected negative draws, b
0.52
optimum x* = PMI_α − log k
0.662
local weight ab/(a + b)
0.340
trained score (k = 5, α = 0.75)
-0.913

Changing k slides the minimum by −log k; the curve's width falls as the weight grows, so frequent pairs are pinned and rare ones are not. The dot is the score the trained model learned (filled at the setting it was trained with): close to x* for a pair seen dozens of times, far from it for a pair seen once. A context never seen with revenue has no minimum, only a push toward −∞.


B · Training and the gauge — what SGD fits, and the factorization it picks
-10-8-6-4-2024-2024unseenas·midprices: x* = -0.72, learned -0.58as·shareline: x* = -1.04, learned -1.25brokerpoint·stockers: x* = 0.07, learned -2.03change·hedgers: x* = 0.17, learned 0.13climbed·subswap: x* = 0.14, learned -1.87crossseats·which: x* = 0.46, learned 0.55dallas·undermargin: x* = 0.46, learned -2.45decreased·loans: x* = -1.12, learned -2.14dmitri·event: x* = 1.11, learned 0.77efficiency·tentative: x* = -1.37, learned -2.33expectations·vendorflow: x* = -1.11, learned -0.62expenses·pipers: x* = 2.37, learned -0.35from·outcredit: x* = -1.02, learned -1.14interpatent·the: x* = 0.01, learned 0.15machinery·transseat: x* = -1.18, learned -1.75microwell·royaltyflows: x* = -0.72, learned -0.83multishare·broader: x* = 0.15, learned -0.37order·crossassets: x* = 0.31, learned 1.01ostrander·banking: x* = -1.64, learned -3.15overmargin·of: x* = 0.65, learned 0.19plantware·stockment: x* = 2.06, learned -0.29portlines·at: x* = -1.58, learned -3.13postleases·outtender: x* = 2.43, learned 0.39postleases·undertrades: x* = 3.2, learned -0.54preshares·crossdevice: x* = 2.56, learned -0.86priorities·intermarket: x* = -1.21, learned -0.43priorities·renetwork: x* = 0.69, learned 0.62quarter·goods: x* = -0.24, learned -1.02rateflows·wren: x* = 3.46, learned 1.65reflected·priceside: x* = 0.52, learned -1.37rerate·creditwork: x* = 1.37, learned -1.86royaltybook·operating: x* = -0.31, learned -1.46storeworks·taxes: x* = 0.34, learned -0.53subtariffs·investments: x* = 3.93, learned -0.64the·levybook: x* = -2.94, learned -4.09trailed·microwell: x* = -0.29, learned -0.85volume·warranters: x* = 1.45, learned -1which·patentings: x* = -1.07, learned -1.36wren·capacity: x* = -1.28, learned -0.62year·channelware: x* = 0.74, learned 0.09a·solenne: x* = -2.93, learned -2an·networks: x* = -0.81, learned -0.74analysts·systems: x* = -1.59, learned -1.45and·marketage: x* = -1.79, learned -1.82and·redeposit: x* = -1.55, learned -1.31business·a: x* = -2.21, learned -2.67coroyaltys·management: x* = 0.57, learned 0.63customers·developers: x* = 0.25, learned -0.2data·is: x* = 0.53, learned 0.75demand·channels: x* = -2.38, learned -2.49described·refleet: x* = -0.96, learned -1.45fischer·of: x* = -0.88, learned -0.16focus·transfleet: x* = -1.04, learned -1.62from·services: x* = -2.17, learned -0.95headcount·levels: x* = -0.53, learned -1.17highlighted·nonpolicys: x* = -0.25, learned -0.76interdealers·in: x* = 0.47, learned 0.83interplant·and: x* = -0.27, learned -0.34meridale·healthcare: x* = 1.75, learned 1.84ohio·held: x* = 0.02, learned -0.15order·aerospace: x* = -2.24, learned -3.96order·lending: x* = -1.19, learned -2.38outshare·logistics: x* = -1.24, learned -1.6payableflow·levels: x* = 0.58, learned -1.53performance·performance: x* = -1.28, learned -0.6rebatebase·change: x* = -1.47, learned -2.09refleet·stockment: x* = -0.08, learned -0.76remain·verity: x* = 0.52, learned 0.35resources·warrantment: x* = 0.01, learned -0.29rose·routeside: x* = 0.74, learned -0.62shaped·assay: x* = 1.17, learned 1.03speaking·grace: x* = 2.49, learned 2.14submerchants·was: x* = -0.5, learned 0.96tanaka·publicly: x* = 2.46, learned 2.43this·larkspur: x* = -1.63, learned -2.66to·bonders: x* = -1.46, learned -1.81trailed·fell: x* = -0.59, learned -1.55transtender·swaper: x* = -1.18, learned -1.39turbine·follow: x* = -0.22, learned 0.06wellside·developers: x* = 1.01, learned 0.24and·crossdeposit: x* = -1.53, learned -1.44as·lending: x* = -1.85, learned -1.97as·works: x* = -1.78, learned -1.85called·decreased: x* = -0.95, learned -0.82canada·base: x* = 2.23, learned 1.57capacity·resources: x* = -0.62, learned -0.58cash·pointed: x* = 0.33, learned 0.13checking·expects: x* = 1.85, learned 1.41contracts·highlighted: x* = -0.82, learned -0.8decreased·called: x* = -0.92, learned -0.8expense·markets: x* = -1.38, learned -1.23expense·result: x* = -1.04, learned -0.6fees·percent: x* = -0.77, learned -0.75freightings·contracts: x* = -1.11, learned -1.57freightings·markets: x* = -1.26, learned -0.72halvorsen·thank: x* = -0.38, learned -0.1in·networkside: x* = -1.92, learned -2.05in·submarket: x* = -2, learned -2.1investors·boston: x* = 2.38, learned 2.38its·chicago: x* = 0.85, learned 0.54kraus·of: x* = 0.02, learned -0.01management·production: x* = -1.22, learned -1.78ongoing·statute: x* = 1.76, learned 1.39outprices·capital: x* = -0.8, learned -2.32performance·remained: x* = -1.12, learned -0.93portlines·as: x* = -0.59, learned -0.64production·focus: x* = -0.05, learned 0.08resilient·markets: x* = -0.59, learned -1.25result·costs: x* = -0.29, learned -0.2revenue·outperformed: x* = -0.04, learned -0.74routebooks·management: x* = -0.56, learned -0.32royaltyflows·aerospace: x* = -0.9, learned -0.95shipments·was: x* = -0.84, learned -0.57shipments·which: x* = -1.11, learned -1.32team·microcredits: x* = -1.05, learned -1.76the·overpremium: x* = -1.66, learned -1.94third·expense: x* = 0.9, learned 0.83to·transtender: x* = -1.89, learned -1.81trend·sales: x* = -0.88, learned -0.57undermargin·swaper: x* = -0.06, learned -0.99a·mid: x* = 0.33, learned 0.44and·at: x* = -1.94, learned -1.87and·cost: x* = -1.7, learned -1.63and·freightworks: x* = -1.47, learned -1.33and·turbine: x* = -1.57, learned -1.67cedar·for: x* = -0.23, learned -0.41classified·industrials: x* = 2.5, learned 2.15classified·under: x* = 3.38, learned 2.71date·on: x* = 2.12, learned 2.26event·current: x* = 1.81, learned 1.8expanded·footprint: x* = 3.55, learned 4.04expectations·percent: x* = -1.38, learned -2.08focused·on: x* = 1.88, learned 1.77fourth·revenue: x* = 0.58, learned 0.24halvorsen·services: x* = 0.16, learned -0.47in·fluctuations: x* = -1.69, learned -1.65in·portlines: x* = -1.58, learned -1.58in·strong: x* = -1.11, learned -1indemnification·a: x* = 1.21, learned 1.24joining·the: x* = 0.1, learned -0.16kestrel·halvorsen: x* = 0.03, learned -0.62of·its: x* = -1.59, learned -1.79operating·unchanged: x* = 0.07, learned 0.04pellucid·for: x* = -0.06, learned -0.1percent·levels: x* = -0.86, learned -0.7precycles·in: x* = -0.81, learned -0.77quarter·freight: x* = -0.2, learned -0.5remained·of: x* = -0.95, learned -1.31reported·marrow: x* = 0.13, learned -0.01results·freightings: x* = -0.39, learned -0.43results·markets: x* = -0.35, learned -0.21revenue·period: x* = -0.69, learned -1.05section·of: x* = 0.85, learned 1.01securities·a: x* = 1, learned 0.8serves·officer: x* = 2.32, learned 2.11support·turbine: x* = 0.57, learned 0.72taxes·income: x* = 2.09, learned 0.89the·rose: x* = -2.62, learned -2.69with·dunmore: x* = -0.64, learned -0.51within·industrials: x* = 2.39, learned 2.48a·called: x* = 0.43, learned 0.43a·in: x* = -1.14, learned -1.06and·broader: x* = -0.87, learned -0.72and·invest: x* = -0.85, learned -0.88and·markets: x* = -0.8, learned -0.74and·plan: x* = -0.76, learned -0.76and·the: x* = -0.8, learned -0.81as·trend: x* = 0.42, learned 0.31demand·a: x* = -0.3, learned -0.6demand·management: x* = 0.28, learned 0.21described·which: x* = 1.45, learned 1.06discussion·the: x* = 0.51, learned 0.44estimates·outlook: x* = 1.7, learned 1.49financial·the: x* = -0.36, learned -0.21focus·areas: x* = 2.22, learned 1.92for·expects: x* = 0.45, learned 0.54from·and: x* = 0.22, learned 0.26from·resources: x* = 1.55, learned 1.5from·toward: x* = 1.49, learned 1.53highlighted·as: x* = 1.1, learned 0.98in·a: x* = -1.45, learned -1.34in·levels: x* = -0.74, learned -0.88in·trend: x* = -0.9, learned -1.07include·priorities: x* = 1.94, learned 1.83industrial·halvorsen: x* = 1.84, learned 1.45invest·to: x* = 1.04, learned 0.98levels·capital: x* = 2.29, learned 1.58management·to: x* = 0.23, learned -0.15margins·in: x* = 0.19, learned 0.17of·areas: x* = 0.36, learned 0.14of·reported: x* = 0.44, learned 0.47of·the: x* = -0.28, learned -0.29outlook·estimates: x* = 1.55, learned 1.58precycles·and: x* = -0.14, learned -0.09quarter·for: x* = 0.49, learned 0.4result·a: x* = 0.69, learned 0.63rose·in: x* = 0.05, learned 0.13the·team: x* = -0.57, learned -0.6to·continued: x* = 0.78, learned 0.75were·broadly: x* = 1.12, learned 0.97learned score ⟨w, c⟩ (vertical) against its target PMI_α − log k (horizontal) · window 8, d = 25target x* = PMI_α − log k
times seen:1 (r = 0.641)2–4 (r = 0.818)5–19 (r = 0.940)20–99 (r = 0.979)100+ (r = 0.985)· dashed: learned = target
loss per pair (floor)
1.6514 (1.4752)
r, pairs seen once
0.641
r, pairs seen 100+
0.985
gauge A's singular values
0.788 – 1.204
‖WᵀW − CᵀC‖ / ‖WᵀW‖
0.799

revenue·plantline is not among the sampled pairs; its count band is highlighted. At epoch 0 every score is 0, since the context vectors start at zero. Frequent pairs reach the diagonal first; pairs seen once stay scattered, as their small weight predicts, and unobserved cells sink. The imbalance grows well above zero, because SGD is not gradient flow, but the gauge stays near orthogonal from the first epoch on.


Finance case study: polarity isn’t a direction


Where this goes next

  • GloVe. GloVe fits log⁡#(w,c)\log \#(w, c) by weighted least squares with explicit biases and a weight that grows with the count, the same structure as Corollary 1’s local fit with a different weight. The next topic compares the two and takes up the linear structure behind word analogies, which is a statement about word–word geometry and so, by Proposition 3, about the gauge.
  • Contextual embeddings. One vector per word type cannot tell strong from weak by their windows. Contextual embeddings give each token its own vector, trained by a masked-language-model objective that is again a softmax over the vocabulary.
  • Knowledge-graph embeddings. TransE and its successors train with negative sampling over corrupted triples, and Theorem 1’s per-cell analysis applies to their scores as well.
  • Contrastive retrieval. formalRAG’s hard-negative mining asks which negatives to draw for a dual encoder; here the noise distribution decides what the optimum factorizes.

Honest caveats


Implementation

The companion notebook (notebookPath) imports word2vec_implicit_factorization.py, which owns every number on this page. It imports the distributional-semantics topic’s module for the co-occurrence counts, the PMI matrices, the SVD baselines, the benchmark, and the semantic-orientation scores, and the neural-language-models topic’s module for its log-softmax and gradient checkers. Running it as a script trains five negative-sampling models in NumPy and executes a harness of 1414 assertion-based tests in under a minute on a laptop CPU. The tests cover:

  • Proposition 1, Theorem 1, and Proposition 2 against unconstrained L-BFGS (scipy.optimize) on random instances, and Theorem 1 exactly on every observed pair of the corpus; the hand-written gradients against complex-step and central differences; the unbiasedness of the sampled loss.
  • Theorem 2 on random instances, against scipy.stats.entropy, with its curvature and weight bounds; the fit by count band and the offset direction on the corpus.
  • Proposition 3 on random instances and on the trained model; Theorem 3’s step identity on real minibatches and its drift as the step shrinks; Lemma 1 and Corollary 2 on random instances and end to end from a balanced start; the near-balance of the trained model.
  • The controlled comparison, the grid and its selection, the weight mechanism, 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