Introduction
In classical NLP, words were treated as atomic symbols, such ashotel, conference or walk, and represented with sparse one-hot vectors:
The length of each vector equals the vocabulary size , which runs from tens of thousands of words for a single application to millions for web-scale text. One-hot vectors are also orthogonal by construction, so nothing relates motel to hotel: their dot product is
One of the key ideas that made NLP successful is distributional semantics, which goes back to Firth: a word’s meaning is given by the words that frequently appear close by. When a word appears in a text, its context is the set of words that appear nearby, within a fixed-size window. The many contexts of across a corpus are used to build up a representation of .

banking is represented by the words to its left and right across all sentences of the corpus.
This is the idea behind word2vec embeddings, which the rest of this section develops. Embeddings learned this way are general purpose. A model for a specific task can start from them or learn its own embedding layer from scratch, and which works better depends on the task and on how much labeled data it has.
Features of Word2Vec embeddings
In 2013, Tomas Mikolov and colleagues at Google published two papers that learn word vectors of a few hundred dimensions by training a shallow network to predict the words around each word (Mikolov et al., 2013; Mikolov et al., 2013). They released the code as word2vec.
banking in d=8 dimensions.
The Embedding Projector shows such vectors projected from dimensions to 3. Search for the word “truck”: the list of nearest neighbors is computed in the original -dimensional space, while the 3D positions come from PCA or t-SNE, so points that look close in the plot need not be neighbors. Projected to 2D, the vectors of US cities do not reproduce the geographic map, but cities that are similar in meaning fall close together, which is what an embedding is for.


king − man ≈ queen − woman, shown by the parallel red arrows. Four analogies can be read off the arrows and their directions. The figure is idealized: the query vector only has to be closer to queen than to any other word, not equal to it. The similar direction of the arrows indicates a similar relation.
Word2vec has two training algorithms[^1]. This section covers the skip-gram method, using the diagrams below.


banking is captured by how well it predicts the words around it across the corpus.
Prediction means maximum likelihood, as in the regression section: the network is trained to make match the empirical distribution by minimizing cross-entropy. The average negative log-likelihood is
where is the number of words in the corpus, which can reach billions. The vocabulary size is a different number: each distinct word counts once. Training pairs are generated directly from the corpus once the window is fixed:


Mind the difference between learning a representation from contexts across the corpus and applying that representation. Word2vec vectors are applied without context. After training, a single matrix is used, so the word ‘bank’ gets the same vector whether it appears next to ‘river’ or next to ‘deposit’.Contextual representations are covered in a separate section.

