Paper commentary
word2vec Explained: deriving Mikolov et al.'s negative-sampling word-embedding method
Negative sampling replaces the softmax in word2vec with a sigmoid objective
- Problem Skip-gram's softmax divides by a sum over every context, and that sum must be recomputed for every word-context pair in the corpus. This makes training expensive on large corpora.
- Method Negative sampling replaces the softmax with a sigmoid that classifies each word-context pair as observed or sampled. Observed pairs push their dot product up, while random sampled pairs push it down.
- Results The derivation shows that the negative-sampling objective is a sum of log-sigmoid terms over observed and sampled pairs, which matches equation (4) of Mikolov et al. The note does not prove that this objective yields good embeddings.
Why the full softmax is too costly
The skip-gram model wants parameters under which each observed context gets high probability given its word. Its probabilities come from a softmax over dot products of word and context vectors. Every probability therefore divides by a sum over all available contexts. Taking the log turns the products into sums, but each term still carries the log of that normalizing sum.
The denominator is the expensive part, because it must be recomputed for every pair in the corpus. The paper's parameter count of |C| × |V| × d shows how large the model already is before any sum is taken. One way to make the computation more tractable is to replace the softmax with a hierarchical softmax. The note doesn't elaborate on the hierarchical softmax, and it doesn't pursue that direction.
Instead, the note turns to negative sampling, which it describes as optimizing a different objective from skip-gram. Negative sampling is presented as a more efficient way of deriving word embeddings. Behind the whole approach sits an assumption: maximizing the objective should give similar words similar vectors. The note says it is not clear why this assumption holds.
The assumption is not motivated in the literature, and the note adds one reason for a related choice. If a word and its context share one vector, the model would need a low value for v · v, which is impossible. So the note keeps word and context vocabularies distinct, which lets the model avoid that conflict.
Scoring pairs as observed or not
The key idea is to stop asking which context a word predicts and to ask, for each word-context pair, whether it came from the corpus at all. Let p(D = 1 | w, c; θ) be the probability that a pair came from the data, so p(D = 0 | w, c) = 1 − p(D = 1 | w, c) is the probability that it didn't. The note models that probability with a sigmoid of the dot product, p(D = 1 | w, c; θ) = 1 / (1 + e^(−v_c · v_w)).
Scoring only observed pairs has an easy answer: make every pair look genuine. Setting every word and context vector equal, with their dot product K large, pushes each probability toward 1. The note estimates that K around 40 is enough to reach a probability of 1. So the objective needs a mechanism that stops all vectors from collapsing onto one shared value.
The mechanism is a set D′ of random word-context pairs, all assumed to be incorrect. The objective now multiplies the probabilities of D with the probabilities of being wrong for D′, and taking logs turns this into a sum. Using σ(x) = 1 / (1 + e^(−x)), the objective becomes \[ \sum_{(w,c)\in D}\log\sigma(v_c\cdot v_w)+\sum_{(w,c)\in D'}\log\sigma(-v_c\cdot v_w) \] which is maximized.
Maximizing it pushes the dot product up for observed pairs and down for sampled pairs.
The result is almost equation (4) of Mikolov et al. The note's version covers all of D together with D′ at once, whereas Mikolov et al. state it for a single observed pair and k sampled pairs. Their D′ holds k times as many pairs as D, because each observed pair gets k sampled partners.
Drawing negatives and reading the objective
Negative pairs come from a random draw, and Mikolov et al. make that draw from a specific distribution. Their constructed set D′ is k times larger than D, so each observed pair gets k negative contexts. Equivalently, the samples (w, c) in D′ follow pwords(w) times pcontexts(c) raised to 3/4, divided by a normalization constant Z. In the Mikolov et al.
work each context is a word, so pcontext(x) and pwords(x) are both count(x) divided by the text length.
Freezing one side of the model changes the kind of problem it becomes. If the word representation is fixed and only the context representation is learned, the model reduces to logistic regression, which is convex. The same holds when the context representation is fixed and only the word representations are learned. Learning both sets of vectors jointly makes the objective non-convex.
Unlike skip-gram, this formulation doesn't model p(c|w).
The skip-gram objective and the negative-sampling objective differ in what they sum over. Negative sampling optimizes the objective over the entire corpus D ∪ D′ at once. Mikolov et al. present it for one observed pair and k sampled pairs instead.
The word2vec code also applies a dynamic window, which the next section covers. Subsampling of frequent words is one more preprocessing choice that affects the contexts. Mikolov et al. report that subsampling of frequent words improves embedding quality on some benchmarks.
Context windows and subsampling in the word2vec code
The generic definition gives each word a fixed window of size k on each side of it. The word2vec code changes this by sampling a window size k′ uniformly from 1 to k for each word. So k sets only the maximal window size, and the actual window varies from word to word. Because the window shrinks for some words, nearby words get more weight than distant ones on average.
word2vec also discards words before it builds any contexts. Words appearing fewer than min-count times are dropped as both words and contexts. Frequent words, as defined by the sample parameter, are down-sampled. The removed words are cut out of the text first, so the windows for the remaining words reach further across the original sentence.
Mikolov et al. report that subsampling frequent words improves embedding quality on some benchmarks. Their motivation was that frequent words are less informative. The note offers a second reading: a larger effective window brings in content-full words that are linearly far from the focus word. That reading makes the similarities more topical, according to the note.
The note doesn't test this explanation, so it stays a suggestion.
Why good embeddings remain unexplained
The note's final question is why the objective produces useful vectors at all. The distributional hypothesis says that words in similar contexts have similar meanings. The objective raises the dot product vw · vc for good word-context pairs and lowers it for bad ones. Words that share many contexts therefore end up with similar vectors, which is the intuition the note offers.
The authors call this argument very hand-wavy, so it doesn't count as a proof.
The first section already flagged the gap: the assumption that maximizing objective (4) yields good embeddings has no stated reason. The authors write that it is not clear to them why this assumption holds. The derivation shows how the negative-sampling objective follows from the skip-gram model, but it doesn't link that objective to embedding quality.
The note doesn't provide a formal account of why the objective gives good word representations. Its authors say they don't really know, and they want a more formal argument. So the assumption stays an informal intuition, not a proven link to the distributional hypothesis.
Paper info
- Authors
- Yoav Goldberg, Omer Levy
- Venue
- arXiv · Preprint
- First published
- 2014-2-15
- Added
- 2026-11-12
- Updated
- 2014-2-15
- Version
- v1
- arXiv
- 1402.3722
- Category
- cs.CL · cs.LG · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Yoav Goldberg, Omer Levy (2014). word2vec Explained: deriving Mikolov et al.'s negative-sampling word-embedding method. arXiv:1402.3722v1. https://arxiv.org/abs/1402.3722v1
BibTeX
@misc{goldberg2014word2vec,
title = {{word2vec Explained: deriving Mikolov et al.'s negative-sampling word-embedding method}},
author = {Yoav Goldberg and Omer Levy},
year = {2014},
eprint = {1402.3722},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1402.3722v1}
}