Every word the machine reads is a point in space. Meaning is which points sit near which.
Fifty numbers per word, and nobody decided what any of them stand for. They fell out of counting which words turn up near which, across six billion words of text. In the box below, the pull between two words is that real measurement, not a story about it.
What a vector buys you
If meaning is a direction, you can do arithmetic with it.
Give every word a list of 50 numbers and you have given every word a position. Positions on their own would only buy you similarity: near means alike, far means unalike. What makes this idea powerful is the thing positions have that labels do not: the space between them.
Subtract one word’s position from another’s and you get a direction: not a word, but a displacement, a “whatever it is that turns this into that”. The startling result is that those displacements are reusable. Mikolov and colleagues found it in 2013, and you can reproduce it here on vectors anyone can download. The step from man to king is very nearly the same step as the one from woman to queen, even though nothing in the training ever compared those two pairs.
Watch it happen. The figure draws one arrow, picks it up, and puts it down somewhere else.
Three words, each fifty numbers, shown on the plane their own differences span.
The canonical one. Whatever separates man from king turns out to be roughly the same displacement that separates woman from queen.
GloVe 6B, 50 dimensions, measured. Not an illustration.
Two things this demonstration usually leaves out
Both are worth more than the trick itself.
The arrow does not land on the word. It lands near it. queen is the closest of 50,000 words to where the arithmetic points, at a cosine of 0.861. But it also sits 2.55 units off the plane the picture is drawn on. Every published version of this diagram is a shadow of something 50-dimensional, and the number, not the picture, is the claim.
The inputs have to be excluded by hand. Ask for the nearest word to king − man + woman without ruling anything out and the answer is king, at 0.886, which is higher than queen. The convention of dropping the three input words comes from the original evaluation, and without it most of these analogies return one of their own ingredients. That is not a scandal, but it is the sort of detail that separates knowing the demo from knowing the method.
And try the comparative one. bigger − big + small does not give smaller. It gives larger, with smaller only 3rd. The geometry is real, and it is approximate, and both of those are true at once.
Now you try
Feel the pull between two words.
You have seen that distance in this space means something. Now guess it. The magnet’s strength is the real measured similarity between the pair. Commit to a guess, then find out how wrong the intuition is.
- Score
- 0
- Streak
- ×0
- Caught
- 0/0
- Time
- 45s
Words with real meaning in common drift in. Everything else is pushed to the walls. Get the named neighbour alone in the ring before you press.
arrows or drag to steer · space to grab
One word rides the magnet. Every other word in the box is pulled toward it or shoved away by its real similarity to that word. Steer with the pointer or the arrow keys, and press space to grab whatever is inside the ring. You are asked for a specific neighbour, so predict which one the numbers actually put closest.
A model cannot do arithmetic on the word cat. So before anything else happens, every word is turned into a list of numbers. Here is that list, fifty of them, drawn as fifty little bars. Nobody chose what any of them mean.
Loading the vectors…
Do arithmetic with words
Because direction carries meaning, you can add and subtract words like numbers. Every figure below is computed in your browser from the same vectors the game just used.
Word arithmetic, computed here, on the same vectors
Loading the word vectors…
Look up any word’s neighbours
Type a word and see what the numbers put next to it, including the neighbours you would not have guessed. Those are the interesting ones.
Fetching 1,851 word vectors…
Nearest, measured in all 50
Loading…
Look at where these land on the map. Some sit right next to the highlighted word; others are across the page. The list is right and the map is lying. Flattening fifty dimensions into two has to throw something away.
Embeddings
NextAttention+What is actually going onHow does counting produce meaning?Words that mean similar things get used in similar company. Counting the company is enough.
The idea is older than the machinery: you shall know a word by the company it keeps. Coffee and tea both show up near cup, morning, drink, hot. Nobody has to state that they are related. The pattern of co-occurrence already says so.
GloVe turns that into arithmetic. It builds the table of how often each word appears near each other word across the whole corpus, then finds a set of coordinates that reproduces those counts as closely as possible. Fifty numbers per word here; production models use hundreds or thousands, and learn them as part of training rather than in advance.
Take it apart yourself: How a model learnsDescent · 8 min. Optional.
+What is actually going onDo these vectors carry human bias?Yes, and it is measurable with the same arithmetic that makes the famous example work.
Bolukbasi and colleagues showed in 2016 that the same word arithmetic which lands near queen also produces occupational stereotypes along a gender direction. That is not a bug in the algorithm. The vectors are a compression of how words are used in real text, so associations that exist in the text exist in the geometry.
Worth carrying forward: this is the raw material every language model is built on. When a model produces a stereotyped assumption, the first place to look is not its instructions. It is what the arrangement of the text it read already implied.
Take it apart yourself: Why the failures happenFailure Bench · 10 min. Optional.
+Watch somebody explain itOpens with embeddings, words as directions in space, before going deeper.
Optional: watch someone explain it
Transformers, the tech behind LLMs
3Blue1Brown
Opens with embeddings, words as directions in space, before going deeper.
+Go and try this on a real assistantAsk for a word that sits between two others.
Go and try this
Find where the arithmetic falls over
Use the bench above on relationships from your own field. A tool and what it makes. A country and its currency. A verb and its past tense.
Then try a pair where the relationship is subtle, and see what comes back instead.
What to watch for: How often the top answer is one of the inputs' close relatives rather than the analogy you meant. The trick works far less reliably than the famous example suggests, and seeing that is worth more than seeing it succeed.
+Check yourselfIt marks itself, and nothing is sent anywhere.
The same arithmetic gives stereotyped answers on some inputs. Why?
Sources
- GloVe: Global Vectors for Word Representation
Pennington, Socher & Manning (EMNLP 2014)
The method behind every vector on this page, and the account of why counting co-occurrence produces directions that mean something.
- GloVe pre-trained word vectors
Stanford NLP
The 6B 50-dimensional vectors themselves, trained on Wikipedia 2014 and Gigaword 5. Every similarity in the game and the benches is computed from these.
Public Domain Dedication and Licence v1.0
- Efficient Estimation of Word Representations in Vector Space
Mikolov, Chen, Corrado & Dean (arXiv:1301.3781, 2013)
Where the word-arithmetic result came from, a year before GloVe.
- Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddings
Bolukbasi, Chang, Zou, Saligrama & Kalai (arXiv:1607.06520, 2016)
The measurement that the same arithmetic reproduces the stereotypes present in the training text.
- Transformers, the tech behind LLMs
3Blue1Brown
Opens on the same idea, words as directions in space, and then keeps going.