Words as Places in Meaning
A second look at the map of meaning: tokens get the places, the places are knobs set by training, and directions carry meaning.
A quick note on how we teach here. You won't find equations or numbers in this series, and that is on purpose. The goal is understanding, not arithmetic, so every idea is explained in plain words and simple pictures. When you want the math later, the rest of Internals Decoded is ready for you.
Welcome back. Last time we chopped language into tokens. Today we go back to an idea you met much earlier, in Turning Meaning Into Places: the map of meaning. You know a lot more now than you did then. You know about knobs, about training, and about tokens. With those in hand, the map has some surprises to show you.
Here is what you already know. A machine gives each thing it knows a place on a huge imaginary map. Things that turn up in similar surroundings end up close together, and things whose surroundings have little in common end up far apart. A place on that map is called an embedding.
This second look adds three new ideas. The things that get the places are tokens. The places themselves are knobs, set by the same training you have watched all along. And directions on the map can carry meaning.
Tokens get the places
In a language model, the things placed on the map are the tokens from last time. Every block in the tokenizer's bucket gets its own spot: whole common words like "cat", and pieces like "hipp" or "amus". When the model reads your sentence, the first thing it does with each token is look up its place on the map. Those places are where everything else starts.
The places are knobs
Here is the idea the first look could not show you. A token's place on the map is not written down by a person. Each place is stored as a long address, with far more parts than a street name and a house number, and every part of that address is a knob, just like the knobs in The Knobs Inside.
So the map is learned the same way everything else is learned. Before training, every token starts at a random spot. "King" might sit right next to "banana". Then training begins. Each time the model guesses the next token and misses, backpropagation works out which way every knob should turn, and gradient descent nudges them all a little, including the knobs that hold each token's place. Tokens that turn up in similar surroundings get nudged in similar ways, so they drift toward each other. "Happy" and "joyful" both turn up after words like "she felt", so over countless examples their places end up close together. Nobody drew the map. It grew as a side effect of getting better at guessing the next token.
The people who build these machines describe it in just these terms. PyTorch's guide to its embedding table, from one of the most popular toolkits for building them, calls it a lookup table whose entries are learnable weights that start out random.
A map with many directions
Back in Turning Meaning Into Places, we pictured the map as a field stretching in more directions than we can draw. That is still the right picture. Each token's long address has one part for every direction, and a real model's map has a great many directions. We cannot draw it, and we do not need to. We only need to know that tokens with similar meanings have similar addresses.
Directions carry meaning
Here is the second surprise. On a well trained map, it is not only closeness that means something. Directions can mean something too.
Researchers saw this in an early word map, described in a paper called Efficient Estimation of Word Representations in Vector Space. Take the step that leads from "man" to "woman". Now go to "king" and take the same step, the same distance in the same direction. The word closest to where you land is "queen". That one step seems to carry something like "the female version of this". It does not work this neatly for every pair of words, but it showed that the layout of the map holds more than just who sits near whom.
The same token, different meanings
One more thing the first look could not show you. A token's place on the map is only where it starts. Take "bank" in "a walk along the river bank" and in "money in the bank". Both start from the same spot, because they are the same token. But as the model passes them through its layers, it mixes in what the words around them say, and by the time it guesses the next word, the two have moved toward different meanings. How the model decides which surrounding words to mix in, and how much, is called attention. It is a big new idea waiting for you after this series.
Naming the map
You already know the name from Turning Meaning Into Places: embeddings. When they belong to tokens, people say token embeddings, or word embeddings. Now you know three things about them that the first look could not show: the places belong to tokens, they are knobs set by training, and their directions can carry meaning. Later, when you want the numbers behind all this, Embeddings: Meaning as Numbers in the series AI, From Zero picks it up.
Where this is heading
Now every token has a home on the meaning map. When the model reads a fresh run of tokens, it starts from their places on the map, passes them through its layers, and ends up with a likelihood for every token it knows, the row of bars you met in How Likely, Really. It could always take the most likely one. That is the safe, obvious choice. But it draws its next token like a raffle, so now and then it takes one a little further down the list. How bold should it be? That choice, between caution and surprise, is set by a dial.
Test yourself
A brand new language model is about to start training. Where do "happy" and "glad" sit on its map right now? Where will they end up, and what moves them there?
Answer: Right now they sit at random spots, maybe nowhere near each other, because every token's place starts out random. Each place is a set of knobs, like all the other knobs inside the model. As training goes on, every missed guess leads backpropagation to work out how each knob should turn, and gradient descent nudges them, including the knobs that hold each token's place. "Happy" and "glad" turn up in similar surroundings, like after "I am so" or "she felt", so the nudges push their places in similar ways. Over countless examples, they drift close together. Nobody draws the map. It grows as the model gets better at guessing the next token.
Next: Careful or Adventurous. It turns the dial called temperature and shows what happens to the model's next word when it plays safe and when it takes chances.