Backstory · Embedding Playground

Meaning is geometry

Why a word, to a language model, is a place rather than a string. And what the famous king − man + woman ≈ queen trick quietly leaves out.

To a language model, a word is not a string of letters. It is a place. Every word it knows sits at a fixed point in a space of a few hundred dimensions, and the only thing that carries meaning in that space is distance. Words that behave alike sit close together. Words that don't sit far apart. That is the entire trick, and it is stranger than it sounds.

I run a weekly coffee series at work on understanding AI, and this was the session I was most impatient to teach, because it is the one where the abstraction finally turns into something you can touch. I kept trying to explain the idea in words and watching it not land. You can say "the model represents words as vectors," get a nod, and the nod means nothing, because nobody can picture three hundred dimensions and nobody should try. The idea only arrives when you can move a point yourself and watch the meaning move with it. So I built a place to do that. It is called the Embedding Playground, it does its arithmetic on real word vectors rather than a cartoon of them, and it runs entirely in your browser for a deliberately boring reason: everyone in the room could open it from a single link, with no install and no account, and start playing while I talked.

Two wrong ways to describe it

There are two camps on what a thing like this knows, and both are half right. One camp says it is a lookup table with delusions of grandeur, a stochastic parrot matching patterns with no grasp of anything. The other says the representations are rich and structured, that the model in some real sense understands. The lookup camp is right that there is no referent in here: the word king does not point at a king, and there is no crown anywhere in the numbers. The representation camp is right that the structure is real and not an accident, because you can do arithmetic on it and get sensible answers back.

The frame that holds both is older than the model. "You shall know a word by the company it keeps," the linguist J.R. Firth wrote in 1957. Meaning in this space is not a definition, it is a position relative to everything else, learned from the company each word keeps across billions of sentences. The model does not know what a king is. It knows where king sits relative to queen, throne, monarch, and man. That turns out to be enough to be useful and not enough to be trusted, and most of the confusion about these systems lives in the gap between those two facts.

king man + woman queen king − man + the same step man king woman queen
The same offset that separates man from king separates woman from queen. That parallel is the analogy.

The famous trick, and the thumb on the scale

The canonical demo is king − man + woman ≈ queen. It is genuinely remarkable that it works at all, and I put it front and center in the tool. I also left in something the demos usually hide. The arithmetic does not actually land on queen. It lands near it, and the tool then reports the nearest word after quietly excluding the three input words from the running. Take that exclusion away and the honest answer to king − man + woman is often king again, because you only nudged it a little. The clean examples are real. They are also curated, and most analogies you try yourself will be messier than the one on the poster...

Some of that mess is pure delight. Ask the playground for king − man + dog and the nearest word it hands back is cat. Strip the man out of king and what is left is roughly pure authority; add a dog to that and the geometry gives you a cat. Cats are just dogs with authority, and the vectors agree.

The bias is sneakier than royalty ever shows you, and the cleanest place to catch it is doctor − man + woman. The top answer the tool returns is physician, and for a second that is a relief: physician is just a neutral, respectable word for doctor, no stereotype in sight. Then you read one line down. nurse sits at essentially the same similarity score as physician (0.61 against 0.61), a designed dead heat. Asked for a woman's version of a doctor, the geometry says "physician" out loud and "nurse" just as loudly, because it learned its sense of doctor from the same writing we did, and that writing has a gender in it. The tell is not that the model blurts out something ugly. It is that the ugly answer is tied for first, hiding behind a respectable one.

A single analogy can bury that under its top result, which is why the playground has a whole mode that does nothing but project jobs onto a heshe axis. The pattern stops hiding: nurse and homemaker and receptionist drift one way, engineer and mechanic and soldier the other, and the model is not claiming anyone should do these jobs. It is reporting, descriptively, how the words sit together across everything people have written. King and queen never show you that — and that is the part the magic trick skips. The royalty demo is the delight; the doctor one is the lesson.

What I got wrong on purpose

Two things in the playground are lies of compression, and I would rather name them than have you catch them. First, every picture you see is two-dimensional, and the space is three hundred. Flattening 300 down to 2 throws away almost everything, so the tidy little maps are a projection, not the territory. The tool tries to make good on this by printing the true 300-dimensional cosine next to each word, so when the picture lies about a distance, the number beside it does not. Second, only a slice of the vocabulary ships. GloVe has four hundred thousand words; I send 755 of them. Partly that is bandwidth: the full set is gigabytes and this had to open from a link in a meeting. Mostly it is on purpose. This was built for a lesson, not for total exploration of the language, so I curated the words to make the neighborhoods and the analogies land, and kept the vocabulary small so the point stays sharp. The words you can do live arithmetic on are a vocabulary I chose, deliberately. What I did not fake is the neighborhoods: each word's nearest neighbors are precomputed against the entire 400,000-word space and shipped alongside the slice, so "who is closest to king" is the real answer, not an artifact of what I happened to include.

Few things shape what you conclude from a space like this more than the ruler you measure it with.

The measure underneath all of it is cosine similarity, the dot product of two normalized vectors and about two lines of JavaScript, and like every instrument it has a bias. It reads the angle between two vectors and ignores their length, which makes it blind to some things and loud about others. The playground is, in the end, an argument that you should be able to hold the ruler yourself instead of taking my word, or a vendor's, for what the geometry says.

Why bother

Because the most useful intuition about these systems is also the most undersold. When you reword a prompt and suddenly get a better answer, you did not say the magic words. You moved your request to a slightly different place in a space like this one, closer to the region the model associates with what you actually wanted. Nothing understood you better. The geometry just put you in a better neighborhood. Once that clicks, a lot of prompt folklore stops looking like folklore and starts looking like navigation.

One honest scope note, because this is where people overreach. Embeddings are the floor, not the whole building: a modern language model stacks a great deal on top of this geometry, and the playground only ever shows you the floor. But the floor is where a surprising amount gets decided, and it is the part you can actually feel. Your word choice does not just pick a meaning, it drags in everything sitting next to that meaning, the connotations and associations and the bias the doctor example pulled into the open. You ask for one thing and the geometry hands the model that thing plus its whole neighborhood. Words matter, and this is the most literal sense in which they do.

The whole thing is live, it stores nothing, and it makes no network calls once it loads. Go move some words around. And if you do: what is a prompt that worked better the moment you reworded it? That is this geometry, felt from the outside...

Robert Hoekstra
Robert Hoekstra builds independent software as awryLabs: games, libraries, and small tools, one project at a time. More about me, or see the Embedding Playground this note is about.

← All stories