VisualAI
Chapter 3 · Language Models

Words as Numbers

Meaning becomes geometry: king − man + woman lands you right next to queen.

9 minLesson 6 of 23

A neural network only eats numbers — but a word isn't a number. The fix is one of the most beautiful ideas in AI: give every word a location in a map of meaning, and watch arithmetic start to make sense of language.

The lazy approach would be to number the words: cat = 1, dog = 2, king = 3. But those numbers are meaningless — they say cat and dog are as different as 1 and 2, and that king is somehow “bigger” than both. We need numbers that actually capture what a word means.

So instead we give each word a whole listof numbers — coordinates that place it somewhere in a space of meaning. The trick is that these coordinates aren't assigned by hand; they're learned, by noticing which words show up in similar contexts. Words used the same way drift to the same neighbourhood. Explore the result:

Embedding Space

Hover words · drive the analogy machine

manwomankingqueenprinceprincessuncleauntboygirlactoractressfranceparisitalyromejapantokyospainmadridgermanyberlinenglandlondondogpuppycatkittenwolfhorseliontigerapplebananacheesebreadpizzacoffee

Swipe the map sideways to explore →

The analogy machine — meaning as arithmetic

is toasis toqueen

king − man + woman = (5.0, 4.0) → nearest word: queen

Hover or tap a word to see its nearest neighbours · colours group words by meaning, with no one telling them to

A 2-D cartoon of a real embedding space. Nobody labelled these clusters — they emerge from how words are used.
Try this

Hover dog — its nearest neighbours are puppy and cat, not pizza. The animals huddle together; the foods form their own island; countries and capitals line up in pairs. Then run the analogy machine: king − man + woman. The arrow lands right on queen. Try paris − france + italy too.

Meaning becomes geometry

Each word's list of numbers is called its embedding (a fancy word for “the point where we embedded this word in space”). Two ideas fall out of it, and they're the whole payoff:

Closeness = similarity.Words near each other mean similar things. The model can measure “how related are these two words?” by literally measuring the distance between their points.

Directions = relationships. The arrow from man to woman points the same way as the arrow from king to queen — that shared direction is the concept of gender. The arrow from a country to its capital is another consistent direction. Because relationships are directions, you can do arithmetic with meaning.

Key idea

An embedding turns each word into a point in a space of meaning. Similar words sit close together, and the directions between words carry real concepts — so king − man + woman genuinely lands near queen. Language becomes geometry.

Two honest caveats. Our map is 2-D so you can see it; a real embedding space has hundredsof dimensions, with room for thousands of independent “directions” like tense, formality, or sentiment. And the coordinates are learned from oceans of text by a network trying to predict surrounding words — which is a sneak preview of how language models train.

The payoff

Words are finally numbers a network can chew on. But a sentence is a sequence, and meaning depends on context — “river bank” and “money bank” share a word but not a meaning. How does a model let each word check the others to figure out what's going on? That mechanism is attention— and it's next.