What is word2vec?
Word2vec is a family of shallow neural network models that learn a dense vector, or embedding, for every word in a vocabulary from raw text. It trains on a simple prediction task: guess a word from its neighbors, or its neighbors from the word. After training, words used in similar contexts end up with similar vectors.
Word2vec was released by Tomas Mikolov and colleagues at Google in 2013, with two architectures, CBOW and skip-gram, and a set of training tricks that made it fast on billions of words. Its vectors became standard inputs for text classifiers, named entity recognizers, and search systems, and the famous king − man + woman ≈ queen result showed that the vectors encode relationships. The same idea, learning embeddings from context, is the first layer of every modern language model.
Key ideas
- Word2vec learns one dense vector per word from the words around it.
- Words that appear in similar contexts get vectors that point in similar directions.
- Skip-gram predicts the context from a word; CBOW predicts a word from its context.
- Negative sampling replaces the expensive full softmax with a few binary decisions per pair.
- Vector offsets encode relationships, so king − man + woman lands near queen.
- Word2vec vectors are static: each word has one vector whatever sentence it appears in.
Common questions
What is the difference between word2vec and GloVe?
Word2vec learns from local windows, updating vectors one (word, context) pair at a time. GloVe, from Stanford in 2014, first counts how often every pair of words co-occurs in the whole corpus and then fits vectors whose dot products match the log of those counts. The resulting vectors behave similarly, and which one wins depends on the task and the training data.
How many dimensions do word2vec vectors have?
Usually 100 to 300. The widely used Google News vectors released with the paper have 300 dimensions for 3 million words and phrases. Larger sizes help only when there is enough training text to fill them.
Is word2vec deep learning?
Not in the usual sense. It is a two-layer linear model: an embedding lookup followed by an output layer, with no hidden nonlinearity. Its contribution was to show that a very simple network trained on huge amounts of text learns useful representations.
Do word embeddings contain bias?
Yes. Embeddings learn whatever associations their training text contains, including stereotypes. Bolukbasi et al. (2016) found that Google News vectors complete "man is to computer programmer as woman is to" with "homemaker", and proposed methods to reduce such gender directions.
Related explainers
- Embeddings — Turning words and categories into vectors
- CBOW (Continuous Bag of Words) — Predict the center word from its context — the averaging architecture behind Word2Vec
- Skip-gram — Predict context words from a center word — the architecture that powers Word2Vec with negative sampling
- Norms & Distance Metrics — L1, L2, cosine similarity — measuring closeness in vector spaces
- BERT & Masked Language Modeling — Mask a word, predict it from both sides — how BERT learns deep bidirectional representations
- Named Entity Recognition — Identify and classify named entities — people, places, organizations — in running text
References
- Mikolov et al. (2013), "Efficient Estimation of Word Representations in Vector Space"
- Mikolov et al. (2013), "Distributed Representations of Words and Phrases and their Compositionality", NeurIPS
- Pennington, Socher & Manning (2014), "GloVe: Global Vectors for Word Representation", EMNLP
- Bolukbasi et al. (2016), "Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddings"
- Jurafsky & Martin, "Speech and Language Processing" (3rd ed. draft)
Last updated