Notes

Word2Vec

Word2Vec is the model that made dense word vectors ordinary. Its trick was to stop trying to understand words at all: train a shallow network on a fill-in-the-blank game, then discard the network and keep the weights.

The prediction game
Slide a window over a large corpus and set up one of two tasks. Skip-gram takes the centre word and predicts its neighbours; CBOW averages the neighbours and predicts the centre word. Both are trained with negative sampling — score the real pair against a handful of randomly drawn fake ones — which replaces an expensive softmax over the whole vocabulary with a few cheap binary decisions. The input layer's weight matrix is then the embedding table: one row per word, a few hundred numbers wide, and that matrix is the entire deliverable.

What came out of it
Mikolov and colleagues published it at Google in 2013 with pretrained 300-dimensional vectors over a 100-billion-word news corpus that a generation of projects simply loaded. Two findings travelled further than the architecture: the analogy result, where king minus man plus woman lands near queen, so relations behave like directions in the space; and the discovery that training is cheap enough on ordinary hardware that domain-specific vectors over clinical notes or product titles became routine, usually through gensim.

Its limits
There is one vector per word type, so every sense of bank is averaged into a single point, and a word unseen in training gets nothing at all — gaps answered respectively by the contextual embeddings of ELMo and BERT and by FastText's subword vectors. The objective also conflates similarity with mere relatedness, which is why antonyms such as hot and cold sit suspiciously close together.

Word2Vec learns dense word vectors by training a shallow network on a prediction task over a sliding context window — skip-gram predicts the neighbours from the centre word, CBOW the reverse — usually with negative sampling for efficiency. The learned input weight matrix is the embedding table, holding one fixed vector per word. Published in 2013, it made pretrained embeddings standard practice and produced the analogy behaviour in which relations correspond to directions in the space.

Here is a game. Cover up one word in a sentence and guess it from the words around it. Play that game a few billion times and you learn a great deal about which words behave alike, without anyone ever explaining what any of them mean.

Word2Vec is software playing exactly that game. It does not finish knowing definitions. It finishes with a set of numbers for every word, arranged so that words used in similar ways end up close together.

That was the surprise of 2013: real, useful knowledge about language squeezed out of ordinary text that nobody had to label or explain first. A great deal of what came afterwards in language technology rests on the same idea.