Classical NLPNLP 09

word2vec

word2vec learns a vector for every word by training a small network to predict a word’s neighbours in a huge amount of text. Unlike the count-based vectors in Word Similarity, the result is dense: each word is 300 numbers, and directions in that space carry meaning. These are the original Google News vectors (Mikolov et al., 2013), squeezed into 3D with PCA for display.

analogies
PCA projection ·
drag: rotate · scroll: zoom · hover: neighbours · double-click: spin

Most of the variation lives outside these 3 dimensions, so words can look close here while being far apart in the full 300; similarity scores are always computed on the full vectors. Picking an analogy switches to a view fitted on word pairs sharing that relation: faint arrows are the other pairs, grey dashed is the pair in the analogy, yellow is the same offset applied to the third word, and the circle is where the arithmetic lands.

how this data was made
  1. Training (by Google, 2013). word2vec was trained on about 100 billion words of Google News articles. For every word it learned 300 numbers, adjusted so that words appearing in similar contexts end up with similar vectors. The released model covers 3 million words and phrases.
  2. Loading. We kept the 300,000 most frequent entries and scaled every vector to length 1, so that the dot product of two vectors equals their cosine similarity.
  3. Choosing words. 62 words were picked by hand in six groups, so that clusters and relations are easy to see. Nothing else from the model is shipped with this page.
  4. Compressing to 3D. Principal component analysis (PCA) finds the three directions along which these 62 vectors vary most; each word is then described by its position along those three directions. The three components keep 30% of the variation. The rest is lost, which is why the plot can mislead.
  5. Everything else uses the full 300 dimensions. Similarities, the nearest neighbours (searched across all 300,000 words) and the analogy answers were computed before compression. Analogies use the standard method: compute a − b + c and return the most similar word, excluding the three input words. That exclusion does much of the work. With the inputs left in, the nearest word to king − man + woman is king itself (similarity 0.80, ahead of queen at 0.71), and puppy − dog + cat gives cat and puppy before kitten; the two medical analogies shown here come out on top either way. Linzen (2016) and Nissim et al. (2020) explain why analogy results should be read with this in mind.
  6. Relation views. Each analogy button switches to a second PCA, fitted only on word pairs that share one relation (for example man → woman, king → queen, uncle → aunt), which is how such plots are usually drawn. The side panel reports how parallel the pair arrows are in that view and in the full 300 dimensions.

References

  1. Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word representations in vector space. arXiv:1301.3781. arxiv.org/abs/1301.3781
  2. Mikolov, T., Sutskever, I., Chen, K., Corrado, G., & Dean, J. (2013). Distributed representations of words and phrases and their compositionality. Advances in Neural Information Processing Systems 26. arxiv.org/abs/1310.4546
  3. Levy, O., & Goldberg, Y. (2014). Neural word embedding as implicit matrix factorization. Advances in Neural Information Processing Systems 27. papers.nips.cc
  4. Linzen, T. (2016). Issues in evaluating semantic spaces using word analogies. In Proceedings of the 1st Workshop on Evaluating Vector-Space Representations for NLP (pp. 13–18). ACL. doi.org/10.18653/v1/W16-2503
  5. Nissim, M., van Noord, R., & van der Goot, R. (2020). Fair is better than sensational: man is to doctor as woman is to doctor. Computational Linguistics, 46(2), 487–497. doi.org/10.1162/coli_a_00379
  6. word2vec (Google News vectors), distributed from the word2vec project page, code.google.com/archive/p/word2vec, whose code is released under the Apache License 2.0. Shown here in modified form: a 62-word subset, reduced to 3D with PCA.