Cs224n lecture 1,2 word vectors

Word Vectors

Represent words by distributional semantics - “by the company they keep”. 100-dim vectors do really well in capturing word semantics. Words will be similar in vector space if they appear in similar contexts over the corpus.

How to word vectors capture semantic meaning? Whatever ‘units’ of meaning (captured by ferquency of context words) exist, the process to generate the word vectors must linearly map them.

Word2Vec, Skipgrams Implementation

Use the similarity of word vectors for context or outside (o) and center (c) to calculate c given o or vice cersa.

Screenshot 2019-12-21 at 10.04.47 PM.png

Screenshot 2019-12-21 at 10.05.44 PM.png

Word2Vec: Skipgrams

Training Word2Vec: Negative Sampling

Naive softmax is the method presented above

Negative Sampling is a variant of max-margin loss (where we try to maximize the margin between positive examples and negative examples). Main Idea: Train binary logistic regressions for a true pair (center word and word in its context window) vs several noise pairs (the center word paired with a random word). So we avoid having a million terms in the deonminator. The Negative Sampling Objective Function is: essentially, we want to maximize the similarity of the context word and push the similarities of the negatively sampled words to be as low as possible.

Aside: GloVe

How to word vectors capture semantic meaning? Whatever ‘units’ of meaning (captured by ferquency of context words) exist, the process to generate the word vectors must linearly map them.

Count-based Word Vectors: Old way to make word vectors

This sums up the two philosophies to making word embeddings:

Screenshot 2019-12-21 at 11.33.24 PM.png

Large or small ratios are dimensions of meaning whereas ratios close to 1 are not.

Screenshot 2019-12-21 at 11.34.03 PM.png

Key insight in GloVE:

If you set $w_i^Tw_j = \log P(i | j)$, the immediately we get $w_x^T(w_a-w_b) = \log \frac{P(x|a)}{P(x|b)}$, i.e. if you make the dot products = log(co-occurence probability), then the vector differences occur with a ratio of the co-occurence probabilities. So the objective function to train GloVE is where the $f(X_{ij})$ function controlls the influence of very common word pairs. Essentially, set the loss to the square difference between the doct product and the log probabilities (with bias terms)

Based on count occurences but trained iteratively like Work2Vec ## Evaluation of Word Vectors

Appendix:

The Structure of Langauge

We assume people have a lot of world knowledge, so we can express a lot with very limited information.

Notes On Word Vectors

Evaluation of Word Vectors

Old Stuff

WordNet - synonym sets, people don’t really use it anymore. NLTK - swiss army knife of nlp - can do anything but not good at anything. Always use good tools.