Word Math: King Minus Man Plus Woman
Explore analogies and nearest neighbors.
Word Math: King Minus Man Plus Woman is a free NLP Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Vectors Have Directions
Because words are now vectors, you can add and subtract them like arrows. This unlocks a playful idea called word math.
The Famous Example
Take king, subtract man, add woman, and the nearest vector is queen. This analogy stunned researchers when it first appeared. 👑
result = emb["king"] - emb["man"] + emb["woman"]
# nearest word -> "queen"Why It Works
The step from man to woman is a consistent direction in space. Adding that same direction to king lands you near queen.
Relationships as Offsets
Many relations become repeatable vector offsets. The gap encoding gender or tense behaves like a fixed arrow across word pairs.
More Analogies
The trick generalizes nicely. Paris minus France plus Italy lands near Rome, capturing a capital-city relationship.
r = emb["paris"] - emb["france"] + emb["italy"]
# nearest word -> "rome"Finding the Answer
You compute the target vector, then search for its nearest neighbor among all word vectors using cosine similarity.
One Line in Gensim
gensim wraps the whole analogy in a single call. You list positive and negative words and read the top result.
model.most_similar(positive=["king", "woman"],
negative=["man"], topn=1)Nearest Neighbors
Even without subtraction, you can ask which words sit closest to one term. These neighbors reveal what the model thinks is similar.
It Is Not Perfect
Analogies often work, but not always. Bias in the training text can produce unfair or wrong results, so stay critical.
Bias Lives in Vectors
Embeddings absorb the stereotypes present in their data. Always remember that bias in text becomes bias in your model.
Why This Amazes People
Simple arithmetic on learned vectors reflects real human relationships. That is the clearest sign embeddings truly capture meaning. ✨
Quick Check
What does king minus man plus woman tend to produce?
Recap
Word math adds and subtracts vectors to solve analogies like king to queen. It shows embeddings encode real relationships, bias and all. ✅
Frequently asked questions
Is the “Word Math: King Minus Man Plus Woman” lesson free?
Yes — the full text of “Word Math: King Minus Man Plus Woman” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Word Math: King Minus Man Plus Woman”?
Explore analogies and nearest neighbors. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Word Math: King Minus Man Plus Woman” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- From Sparse Counts to Dense Vectors
- How word2vec Learns Meaning
- Loading GloVe Vectors in Python
- Word Math: King Minus Man Plus Woman