How do you show that skip-gram with negative sampling, with K negatives per positive pair, has an optimum at w⊤c=PMI(w,c)−log⁡K for each (word, context) pair, so it implicitly factorises a shifted PMI matrix (Levy and Goldberg). What assumptions do you need?

Sequence models and transformers, Word embeddings
Level L4 Advanced. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can write the expected objective per pair as a function of the score and solve for its stationary point.

Key idea

The per-pair objective is ℓ(x)=#(w,c)log⁡σ(x)+K #(w) #(c)∣D∣log⁡σ(−x) with x=w⊤c. Setting ℓ′(x)=0 gives ex=#(w,c) ∣D∣K #(w)#(c).

Steps

  1. Let #(w,c) be the count of the pair in the corpus, #(w) and #(c) the word and context counts, ∣D∣ the total number of pairs. Negatives for w are drawn from the unigram distribution PD(c)=#(c)/∣D∣.
  2. The global objective is ∑w,c[#(w,c)log⁡σ(w⊤c)+K #(w) PD(c)log⁡σ(−w⊤c)]: each observed pair is a positive, and each occurrence of w draws K negatives.
  3. Assume the vectors have enough freedom (large dimension) that each score xwc=w⊤c can be set independently. Then maximise each term separately in x.
  4. Let A=#(w,c) and B=K #(w)#(c)/∣D∣. Then ℓ(x)=Alog⁡σ(x)+Blog⁡σ(−x) and ℓ′(x)=Aσ(−x)−Bσ(x), using ddxlog⁡σ(x)=σ(−x).
  5. Set ℓ′=0: Aσ(−x)=Bσ(x), so ex=σ(x)/σ(−x)=A/B. Thus x=log⁡AB=log⁡#(w,c) ∣D∣#(w)#(c)−log⁡K.
  6. Since PMI(w,c)=log⁡P(w,c)P(w)P(c)=log⁡#(w,c)∣D∣#(w)#(c), the optimum is w⊤c=PMI(w,c)−log⁡K.
  7. Interpretation: the matrix W⊤C approximates the shifted PMI matrix. Pairs never seen have PMI=−∞, so in practice a low-rank constraint and finite training stop this. Positive PMI (clip at 0) is also used.

Common mistakes

How long your answer should be

One page; 8–10 minutes.

Last checked on 4 December 2026.

Read this

Previous in Sequence models and transformers: What is an induction head, and how can a two-layer attention-only transformer use a pair of heads to complete a pattern such as [A][B]…[A]→[B]? What evidence ties induction heads to in-context learning?
Next in Sequence models and transformers: Assume the loss follows L(N,D)=E+ANα+BDβ and training compute is C=6ND. Derive the compute-optimal N⋆(C) and D⋆(C) and their scaling exponents. What do α=0.34 and β=0.28 imply?