Word Similarity & Analogies
P2.aiml-foundations.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: SVD & Dense Word Vectors
Where next?
Go up a level
P2.aiml-foundations.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: SVD & Dense Word Vectors
Go up a level
Now that every word is a short dense vector, we can finally measure meaning. Two words are similar when their vectors point the same way — and the tool that measures "the same way" is cosine similarity. From there we can rank a word's nearest neighbours and even do arithmetic on meaning itself, the famous king − man + woman analogy trick.
Two arrows can differ in length and in direction. For meaning we care only about direction: a frequent word should not seem similar to everything just because its vector is long. Cosine similarity divides out length and keeps only the angle, giving a score from −1 (opposite) through 0 (right angle, unrelated) to +1 (same direction, synonymous).
Why it matters — This is the single most common similarity measure in NLP — it drives search ranking, deduplication, retrieval-augmented generation, and clustering. Every 'find similar documents' feature is cosine similarity underneath.
This series recalls Co-occurrence & the Distributional Hypothesis, SVD & Dense Word Vectors and Word Similarity & Analogies, and brings back two ideas from Mathematics for ML.
Self-check
Which idea says that words appearing in similar surroundings tend to have similar meanings?
Self-check
Which method squeezes a wide, mostly-zero PPMI table into short dense word vectors?
Self-check
What does cosine similarity between two word vectors compare?
Self-check
Two word vectors are (1, 0) and (0, 2). What is their cosine similarity? Give a whole number.
Self-check
f doubles a number and g adds 3 to a number. What is g(f(4))? Give a whole number.
Self-check
After SVD, the first two components explain 70 % and 20 % of the variance, and every later one about 1 %. Where does the elbow suggest stopping?
Self-check
Of 10 sentences, 4 contain the word bank, and 2 of those 4 also contain river. Given that a sentence contains bank, what is the probability it contains river? Give the answer to 1 decimal place.
Self-check
Mia ranks word pairs by raw co-occurrence count and finds that the words ‘the’ and ‘of’ top every list. What should she change?
Self-check
Sam says the vectors (1, 1) and (5, 5) must mean different things, because one is five times longer. What is the mistake?
Self-check
Jo keeps all 500 SVD dimensions of a 500-word PPMI table, saying more width always gives better word vectors. What is wrong?
Open in Labs: Dot product against cosine
Practise this lesson's 10 self-checks
One per screen: 10 checked on this page, 0 you reveal and mark yourself. Nothing is recorded.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Loading your notes...