Lecture12 - Word RepEmb
Lecture12 - Word RepEmb
Processing
Lecture 12: Lexical Semantics (part I) -
Word Representations and Word Embeddings.
11/30/2020
COMS W4705
Yassine Benajiba
Jabberwocky
• Can you identify what the words in this poem mean?
• Question answering:
0
0 a
⋮
⋮
1
fish
⋮
⋮
⋮
⋮
⋮
|V| zythum⋮
0
⌓ 52 58 4 4 6 26
sim(⊠,⌘) = 0.770
⊠ 115 89 10 42 33 17 sim(⊠,⁂) = 0.939
sim(⊠,⌓) = 0.961
⊚ 59 39 23 4 0 0
⁙ 98 14 6 2 1 0
⁂ 12 17 3 2 9 27
⎔ 11 2 2 0 18 0
cup 98 14 6 2 1 0
pig 12 17 3 2 9 27
berry 11 2 2 0 18 0
Verb-Object counts
• Row vector xdog describes usage of dog as a grammatical object in the corpus.
• Can be seen as coordinates in n-dimensional Euclidean space.
Geometric Interpretation
• Row vector xdog describes usage of
dog in the corpus.
• Can be seen as coordinates in
n-dimensional Euclidean space.
• Illustrated for two dimensions "get"
and "use".
α=54.3°
Orthogonal vectors
(90° angle, no shared attributes):
What to do with DSM
similarities
2. Context definition:
5. Dimensionality reduction.
6. Similarity measure.
Effect of context size
Nearest neighbors of dog
2-word window:
cat, horse, fox, pet, rabbit, pig, animal, mongrel, sheep,pigeon
30-word window:
kennel, puppy, pet, terrier, rottweiler, canine, cat, to bark, Alsatian
Term Weighting
• Problem: Not all context terms are equally relevant to
characterize the meaning of a word.
• Term frequency: How often does the term t appear in the context
window of the target word?
• TF*IDF:
Sparse vs. Dense Vectors
• Full co-occurrence matrix is very big and contains a lot of 0 entries.
• Two models:
(Word2Vec, Mikolov et al. 2013)
0.02 a
0 d hidden
⋮
neurons 0.0 thought
0 Σ
0.04 cheese
eat 1 Σ
0 ⋮ 0.03 place
⋮ Σ
⋮
0 0.0 run
|V| neurons |V| neurons
softmax activation
• Softmax function normalizes the activation of the output neurons to sum up to 1.0.
Skip-Gram Model
• Compute error with respect to each context word.
wt-c place ...a place to eat delicious cheese .
⋮ (eat, place)
(eat, to)
wt-1 to (eat, delicious)
eat (eat,cheese)
wt+1 delicious
wt
⋮
wt+c cheese
• Combine errors for each word, then use combined error to update
weights using back-propagation.
Embeddings are Magic
(Mikolov 2016)
• https://code.google.com/archive/p/word2vec/
• https://nlp.stanford.edu/projects/glove/