Vector space models

In a vector space model, every word (or document) becomes a vector: a list of numbers, like a point on a map. Words with similar meanings sit close together. We measure closeness with Euclidean distance (straight-line distance) or, more often, cosine similarity (the angle between two vectors). Vectors can even capture relationships, such as king − man + woman ≈ queen.

Everyday analogy

A city map where restaurants are placed by what they serve, not by address. All the South Indian places cluster in one area, the bakeries in another. To find something similar to your favourite, look at its neighbours.

Example

Word vectors are learned from how words are used: words that appear in similar sentences ("I drank hot ___": tea, coffee, chai) get similar vectors. You can build them by counting which words appear near each other (co-occurrence) or by training models like Word2Vec.

kingqueenmanwomanDelhiIndiaParisFranceSame direction = same relationship (man→woman ≈ king→queen; country→capital)
In a vector space, words are points, and relationships become directions.

Word relationships as directions on a map

manwomankingqueengenderroyaltyking − man + woman ≈ queen

A simplified 2-D picture. Real word vectors have hundreds of dimensions; a technique called PCA (principal component analysis) squeezes them down to 2-D so we can draw them.

Why cosine similarity often beats distance

Document"rice" count"cricket" count
A: short food article101
B: sports article112
C: long recipe book chapter250

Euclidean distance

A to B = 14.2 · A to C = 15.0

Says A is closer to the sports article, just because C is longer. ✗

Cosine similarity

A and B = 0.18 · A and C = 0.99

Looks at direction (what the text is about), so A matches the recipe. ✓

Try it yourself

About 10 min

Do word maths

  1. Ask an AI chatbot: In word-vector terms, what is king - man + woman?
  2. Try your own: Delhi - India + France.
  3. Ask it to explain why this works.

What you should see: Words as vectors capture relationships, so you can do maths with meaning.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.

Build it for real · guided projectBuild a sentiment analyser for product reviewsAbout 60 min · Copy-paste code · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.