word2vec Explained: deriving Mikolov et al.'s negative-sampling word-embedding method
Yoav Goldberg, Omer Levy
TL;DR
This note clarifies the negative-sampling objective used in Mikolov et al. word2vec. It contrasts the full softmax formulation with a scalable alternative that uses negative sampling and a logistic loss to learn word and context embeddings efficiently. It explains how negative samples are constructed from a unigram distribution raised to the 3/4 power and describes the roles of dynamic context windows and sub-sampling in shaping embeddings. While the justification remains heuristic, the approach robustly aligns with the distributional hypothesis and underpins the practical success of efficient word embeddings.
Abstract
The word2vec software of Tomas Mikolov and colleagues (https://code.google.com/p/word2vec/ ) has gained a lot of traction lately, and provides state-of-the-art word embeddings. The learning models behind the software are described in two research papers. We found the description of the models in these papers to be somewhat cryptic and hard to follow. While the motivations and presentation may be obvious to the neural-networks language-modeling crowd, we had to struggle quite a bit to figure out the rationale behind the equations. This note is an attempt to explain equation (4) (negative sampling) in "Distributed Representations of Words and Phrases and their Compositionality" by Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg Corrado and Jeffrey Dean.
