- Introduced by
- Tomas Mikolov et al.
- Year
- 2013
- Type
- Neural word-embedding model
What does it do?
Word2Vec is a neural word-embedding method introduced by Mikolov and colleagues in 2013.
It learns a dense numeric vector for each word from a text corpus, so that words used in similar contexts receive vectors that lie close together. The resulting embeddings let semantic similarity between words be measured with simple vector operations.
The intuition behind the method
A computer cannot compare the meaning of words directly, but it can learn from the company words keep. Word2Vec reads a large corpus and notices which words tend to surround which other words. Words used in similar contexts get similar vectors, so 'king' lands near 'queen' and far from 'banana'. Meaning is encoded as position in space, and similarity becomes a distance you can compute.
History
Mikolov and colleagues introduced Word2Vec in 2013 in a paper on efficient estimation of word representations in vector space, which proposed the skip-gram and continuous bag-of-words architectures. Related approaches that followed include GloVe, covered on its own page, and later contextual embedding models.
When to use it
Choose Word2Vec when you have a large collection of unlabelled text and want dense vectors that reflect how words are used, for example to explore word relationships or to supply word-level features to a downstream task. It is a poor choice when the corpus is small, because the model learns only from co-occurrence and cannot build reliable vectors from little text; pretrained vectors such as GloVe are then usually more appropriate. It is also unsuitable for questions that depend on the sense of a word in a particular sentence, since each word receives one static vector. If there is no text data at all, word embeddings cannot be built and methods for structured data should be used instead.
Limitations and considerations
- Learns only from co-occurrence within a context window, so rare words receive few training signals and their vectors are unreliable.
- Vectors reflect the usage found in the training corpus; embeddings trained on one domain do not transfer automatically to another.
- Assigns one vector per word form, so it cannot separate the different senses of a polysemous word such as 'bank' by context.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Learns from unlabelled text alone, so it needs no manual annotation of words or sentences.
- Places words used in similar contexts close together, so cosine similarity between vectors gives a usable measure of related usage.
- Yields fixed-length dense vectors, commonly 100 to 300 dimensions, that can be used as features in downstream models.
Applications
- Finding words whose usage is closest to a query term, for example in search and recommendation.
- Supplying word-level numeric features to text clustering and classification.
- Exploring relationships between terms in a large corpus, such as the nearest neighbours of a concept.
- Building domain-specific lexicons from corpora in research and industry.
How it works
How it works
The text corpus is cleaned and split into tokens, and each token becomes a unit that receives its own vector. These choices matter: upper- and lower-case forms, punctuation and inflected variants are separate tokens unless they are normalised, so each gets a separate vector and its own share of the training signal. No universal minimum corpus size applies, but very small corpora yield unstable vectors because the model learns only from co-occurrence.
Each word is paired with the words that surround it within a sliding context window. These (target word, context word) pairs are the training signal: they encode which words appear together and form the basis for learning that contextually similar words should have similar vectors.
A shallow neural network is trained on the context pairs, using either the skip-gram architecture (predict surrounding words from a target word) or continuous bag-of-words (predict a target word from its surroundings). The network's weights are adjusted until words in similar contexts receive similar vectors. The user sets the context window size, the vector dimensionality, a minimum word count below which rare words are discarded, and the number of training passes (epochs); these settings should be chosen for the corpus at hand rather than taken as fixed. In the simplest formulation the output layer is a softmax over the entire vocabulary, which is costly for large vocabularies, so practical implementations approximate it, for example with hierarchical softmax or negative sampling.
After training, each word is represented by its learned dense vector, taken from the input-side weight matrix of the network and commonly 100 to 300 dimensions. These embeddings can then be compared with cosine similarity to find related words, or used as numeric features feeding downstream tasks such as clustering or classification.
Common pitfalls
- Training on very little text produces vectors that mostly reflect noise; check whether nearest-neighbour lists look plausible before using the embeddings, and consider pretrained vectors such as GloVe.
- Skipping normalisation of case, punctuation and word forms splits one word across several vectors and thins out the training evidence for each.
- Training on a corpus that does not match the target domain, such as general news text for clinical notes, gives vectors for the wrong usage.
- Reading a single static vector per word as its full meaning hides the senses that the surrounding context would separate.
Frequently asked questions
What is the difference between skip-gram and CBOW?
Both are shallow neural architectures that learn word vectors from context windows. Skip-gram predicts the surrounding context words from a given target word, whereas continuous bag-of-words (CBOW) predicts the target word from the combined vectors of its surrounding words. Neither is universally superior, so the choice is usually settled empirically for a given corpus.
How large does my corpus need to be?
Word2Vec learns only from co-occurrence, so it needs a substantial amount of text. No universal minimum corpus size is established. If your corpus is small, check whether the nearest-neighbour lists look plausible, and consider pretrained embeddings such as GloVe.
How do I measure similarity between two words?
Compare their learned vectors with cosine similarity, which ranges from -1 to 1. Words used in similar contexts get similar vectors, so values close to 1 usually indicate related usage. Cosine values are only comparable within a single trained model, because vectors from separate training runs are not directly comparable.
Can Word2Vec tell apart different meanings of the same word?
No. It assigns a single static vector per word form, blending all of its senses together. Distinguishing word senses from context requires contextual embedding models rather than Word2Vec.
Related methods
Sources
Mikolov, T., Chen, K., Corrado, G. & Dean, J. (2013). Efficient Estimation of Word Representations in Vector Space.
Open publication reference2018_Book_IntroductionToDeepLearning, p. 170