Word Similarity & Analogies
P2.aiml-foundations.03 · Audience: guest, it-ml, language-pro · Prerequisites: SVD & Dense Word Vectors
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).
ⓘ Concept: Cosine similarity measures direction, not size
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.
Ask the mentor about this module
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.
Try it yourself
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.
Where next?
Later in AI/ML Foundations
Go up a level