Definitionintro
Word embedding
Also called word vector, distributed word representation.
A map from each word of a vocabulary to a dense real vector, usually of 50 to a few hundred dimensions, fit from text so that words used alike lie close together.
Definition
Let be a finite vocabulary of word types and a positive integer, the dimension. A word embedding is a map . It is stored as a real matrix whose row is the word vector . Reading a vector is a table lookup; in matrix form, , where is the one-hot vector of . This is the embedding lookup table of machine learning, applied to words.
The term carries two conditions that the bare map does not. First, is much smaller than : typical values are 50 to 300 for vocabularies of to words, so the vectors are dense (most entries nonzero) rather than sparse. Second, the vectors are fit from text, by a model or a factorization that follows the distributional hypothesis: words that occur in similar contexts should get similar vectors. Similarity of two words is then measured by the cosine similarity
or by the dot product, or by the Euclidean distance after each vector is scaled to unit length.
A word embedding gives one vector per type. Every occurrence of "bank" gets the same vector, whatever its sense. A method that gives one vector per token, as a function of the sentence, makes a contextual word embedding.
Many methods learn two tables: word vectors and context vectors , and the model only sees the dot products . The skip-gram model keeps the word table. GloVe uses the sum of the two vectors of each word. Such a pair of tables is not unique: for any invertible matrix , the tables and give the same dot products. Cosines between word vectors survive only the orthogonal choices of . So an embedding is fixed at most up to a rotation or a reflection of the space, and two embeddings trained apart, for example in two languages, need a map between them before their vectors can be compared (see cross-lingual embedding mapping).
Examples and non-examples
A toy embedding. Take and the vectors , and , all of unit length. Then , and . In this space "cat" is close to "dog" and unrelated to "car". Rotate the plane by any angle and the three cosines do not change.
Learned embeddings (examples).
- The input vectors of the skip-gram model or of the continuous bag-of-words model, trained with negative sampling or hierarchical softmax.
- GloVe vectors, fit by weighted least squares to log co-occurrence counts.
- The rows of (or of ) from a truncated singular value decomposition of a positive PMI matrix, as in latent semantic analysis.
- Subword information embeddings, where a word vector is a sum of character n-gram vectors, so that words never seen in training also get a vector.
- The lookup table of a neural language model, such as the neural probabilistic language model of Bengio et al., learned together with the rest of the network.
Non-examples.
- One-hot vectors. is a map into , but , and the cosine of any two different words is 0. It says nothing about similarity.
- Raw count rows. The row of in a word-context matrix is a distributional vector, but it is sparse and has one dimension per context. It becomes a word embedding only after a reduction to a few hundred dense dimensions.
- A random table. Rows drawn at random and never fit to text form a map , but their geometry does not follow any usage. This is the state of a table before training.
- Contextual vectors. The hidden states of ELMo or BERT depend on the sentence, so the same word gets many vectors. They are contextual embeddings, not word embeddings in the sense above.
- Cluster labels. The bit strings of Brown clustering group similar words, but a word belongs to one cluster path, and the strings are not points in with a cosine.
Related definitions
- Word similarity. The cosine of two word vectors, compared with human ratings of word pairs, is the usual intrinsic test of an embedding. Word analogy is another intrinsic test, and the use of the vectors as features in a downstream task is the extrinsic test.
- Distributional vector. Any vector that describes a word by its contexts, sparse or dense. The rows of a word-context matrix weighted by PMI are distributional vectors; Turney and Pantel 2010 survey these vector space models. Word embeddings are the dense, low-dimensional kind.
- Embedding of other objects. The same idea gives a sentence embedding, a paragraph vector for documents and a node embedding for the vertices of a graph. DeepWalk runs the skip-gram model on random walks.
- Implicit factorization. For skip-gram with negative sampling, the SGNS factorization theorem shows that the word and context tables factorize a shifted PMI matrix when the dimension is large enough. This links the neural and the count-based examples above.
- Bias in embeddings. Embeddings fit from text also encode the social associations of that text. The word embedding association test measures them and hard debiasing removes one direction of them.
References
- Bengio, Ducharme, Vincent and Jauvin 2003, the shared table C of word feature vectors, learned with the language model
- Collobert, Weston, Bottou, Karlen, Kavukcuoglu and Kuksa 2011, the lookup table layer and word vectors trained on unlabeled text and reused across tagging tasks
- Mikolov, Chen, Corrado and Dean 2013, Sections 3 and 4 (the CBOW and skip-gram models, and the test set of 8869 semantic and 10675 syntactic analogy questions)
- Turney and Pantel 2010, the word-context matrix, weighting by PMI and smoothing by truncated SVD
Where this leads
- BiLSTM-CRF
- Neural transition-based dependency parser
- Contextual word embedding
- Continuous bag-of-words model
- Cross-lingual embedding mapping
- GloVe
- Hard debiasing of word embeddings
- Retrofitting
- Sentence embedding
- Skip-gram model
- Smooth inverse frequency embedding
- Word analogy
- Word embedding association test
- Word mover's distance
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W0 stub |
|
Tag 9HSMWP Edit this page History Report an error Markdown