Tokens and Embeddings, lesson 8
Blind spots of cosine similarity
Opposites, negation and rare words that similarity scores get wrong.
You know embeddings come from the company words keep ("The distributional hypothesis") and how cosine similarity scores them ("Cosine similarity and the dot product").
Part 1. Opposites keep the same company
Fill the gap: "the soup is too ___", "a ___ drink", "___ weather", "the water was ___". Hot fits every one. So does cold.
Embeddings learn from exactly those gaps. Opposites like hot and cold, good and bad, buy and sell are used in the same kinds of sentences, so they collect the same neighbours.
Example 1.1
Hot, cold and spicy
- neighbours:soupdrinkweatherwaterdayhot32241cold23241spicy31000
Made-up neighbour counts, like the tables in "The distributional hypothesis". Hot and cold share almost every neighbour. Spicy only shows up around food.
- hot · cold=6 + 6 + 4 + 16 + 1=3333 ÷ (√34 × √34)=0.97
Cosine of hot and cold: 0.97, nearly the top of the scale.
- hot · spicy=9 + 2=1111 ÷ (√34 × √10)=0.60
Hot and spicy, which can mean the same thing about food, score only 0.60. By this measure, hot is far more like its opposite.
Your turn
In the Google News word2vec vectors, which of these sits among the very closest words to "good"?
So a high cosine means "used in similar places". Often that's the same as "means something similar". For opposites it isn't, and the vectors can't tell the difference on their own.
Part 2. "not" barely moves the vector
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- "not" barely moves the vector
- Close is not the same as correct
Tokens and Embeddings overviewSpotted a mistake? Tell us.