The AI Reader.
The Mechanics

A transformer redraws a word's vector for every sentence it appears in

Word2vec's famous king-minus-man-plus-woman trick ran on a vector frozen once at training time, and most explanations of how today's language models represent a word still describe that same frozen kind.

Why this matters

Every model you have typed a prompt into runs this step before it does anything else: your text gets cut into pieces, and each piece is swapped for a row in a table the model learned during training. That row, not the letters you typed, is what the rest of the model works with. This lesson follows that swap down to the exact lookup. It also settles a specific confusion. The king-minus-man-plus-woman trick people quote as proof a model "understands" analogies is real, from a real, inspectable table. But it describes a kind of vector a modern model uses for exactly one step before moving on. By the end, you will know what a word turns into before a model works with it, and where the tidy vector-arithmetic story stops describing what a model like this one actually does.

Background optional reading
01
A model can recognize strawberry's letters and still miscount them: the token → integer id step, one lookup before this lesson begins.
02
A token id is an address into a table the model learned: a deeper look at the same lookup, including tied input and output tables and rows training barely touches.

A word enters as a number before it means anything

Ask almost any chatbot for words like dog and it offers puppy before it offers cat. Feed the right tool the arithmetic "king minus man plus woman" and it hands back queen. Both are the same trick. Somewhere inside the model, dog and puppy sit close together. And king, man, woman, and queen sit at points that can be added and subtracted like ordinary numbers. A word, though, is just a string of letters. Getting from letters to something a model can do arithmetic on takes a specific, traceable series of steps.

The first step turns text into a short sequence of integers, one per token, by matching each piece against a fixed vocabulary list. That integer is where this lesson picks up. On its own, an integer carries no meaning: it is a position in a list, nothing else. The step that gives it one is a second lookup, into a much larger table. Vaswani and colleagues describe the transformer architecture almost every current large model is built on. They state the mechanism in one line: the model uses learned embeddings to convert each input token into a vector of a fixed width.1 Token id 40, whatever token that happens to be, means row 40 of that table. Nothing is computed. The row is read.

That is as far down as this explanation goes. Every step before this one had a further mechanism underneath it, worth asking about. This one doesn't. The row is not standing in for some deeper process. Reading it out of the table is the entire operation. The vector it returns, a few hundred to a few thousand numbers, is what the rest of the model works with from here on.

The table nobody wrote

Picture the table itself: one row per token the model knows, one column per number in the vector, usually called the model's width. In the base transformer Vaswani's paper describes, the width is 512 numbers; in the larger version, 1024. The vocabulary runs to roughly 32,000 to 37,000 tokens, depending on the language pair.1

None of those numbers describes anything a person decided in advance. Before 2013, the field's standard practice was to keep word vectors deliberately small. Mikolov and colleagues introduced word2vec, which popularized much larger ones. They describe the prior norm as a "modest dimensionality of the word vectors between 50-100."2 A vector that size starts as random numbers. Training nudges it, one example at a time, by the same process that adjusts every other weight in the network. Nobody writes a row down. Training arrives at it.

What training arrives at is at least partly checkable. A real 50-number word vector, the kind word2vec's contemporaries were producing, begins 0.50451, 0.68607, -0.59517 and runs for 47 more entries. Jay Alammar, showing that vector for the word king, says plainly: "It's a list of numbers. We can't tell much by looking at the values."3 Printing every number in a row is one thing; explaining what any single one means is another. None of the papers behind this lesson claim the second, only where a row sits relative to the others.

The arithmetic word2vec actually showed

Once every word is a row, "arithmetic on words" is literal: take one row, subtract another, add a third, and search the table for the nearest row to what is left. Mikolov and colleagues built exactly that search. Their own worked table shows the offset from Paris to France, added to Italy, landing nearest Rome, and added to Japan, nearest Tokyo. The same offset run on professions turns Einstein minus scientist plus Messi into midfielder, and plus Picasso into painter.2 Across a test set of 19,544 such questions, their best model, trained on six billion words with 1,000-number rows, solved 65.6 percent overall. That included 66.1 percent of the semantic questions and 65.1 percent of the syntactic ones.2

The sentence most people actually quote, king minus man plus woman equals queen, is not in that table, or anywhere else in this paper. It appears once, in a single sentence, credited to a separate paper by overlapping authors.2 The companion paper published the same year, introducing the training tricks behind the numbers above, never uses the words king or queen. Its own headline example is that the vector for Madrid, minus Spain, plus France, lands closer to Paris than to any other word vector in the collection.4 The paper that actually puts the literal king-queen sentence into print is a competing method: Pennington, Socher, and Manning's GloVe, published the following year. It uses the sentence to motivate its own evaluation scheme, while crediting the same third, uninspected paper for the underlying idea.5 The example everyone reaches for to explain this trick is real; it just doesn't come from where the story says it does.

GloVe's method is built independently, from a global count of which words appear near which others rather than word2vec's local prediction. It reports a stronger result on the same kind of test: 75 percent overall, its best run using 300-number rows trained on 42 billion words. That is three questions in four.5

How much of that is really arithmetic

A 75 percent score sounds like the vector space is doing real geometric reasoning. Two independent researchers checked how much of that number came from arithmetic, and how much came from a rule built into the test. Tal Linzen audited the method from outside it. A literal, unassisted version, one that simply reports whichever word sits nearest the computed point, mostly hands back one of the three words already in the question. Subtract man from king, add woman, and the nearest row to that point is often king or woman itself, not queen.6 Every reported accuracy figure above comes from a version of the test that forbids the search from answering with a word already in the question. Reversing the direction of a question changes the score, even though the underlying arithmetic does not. Linzen found the same offset, asked backward, dropped a US-cities category's accuracy from 69 percent to 17 percent.6

Nissim, van Noord, and van der Goot measured exactly how much the forbidding rule was carrying. On the standard test set, the same constrained search behind every accuracy number above scores 0.74 by one measure and 0.71 by a stricter one. Strip the rule out, let the search answer with an input word if that is genuinely nearest, and the identical formula collapses to 0.21 by both measures.7 Three answers in four become roughly one in five. None of this means the vectors carry no structure. Something in that space does put queen nearer than most words to that point, or the constrained search could not find it at all. It means a meaningful share of the trick's fame belongs to the test's rulebook, not to the geometry alone.

A vector that moves with the sentence

Word2vec and GloVe share one more property, easy to miss because the demo depends on it. Each word gets exactly one row, decided once during training, and reused every time the word appears again. The row for play is the same row whether the sentence is about baseball or Broadway.

A transformer's embedding table starts the same way, a static row per token, read the same way Vaswani's paper describes.1 But that row is not the end of its story. The model immediately hands it to attention, layer after layer. Each layer recombines a token's row with the rows around it in that particular sentence, a step this lesson names but leaves for its own lesson to explain. Peters and colleagues, building a language model, showed exactly what that recombination buys. Where word2vec-style approaches "only allow a single context-independent representation for each word," their model assigns each token a vector that is a function of the entire sentence around it.8 Put a fixed vector for play next to its nearest neighbors and the senses blur together: playing, game, games, played, football, multiplayer, among others.8 Ask the sentence-sensitive version the same question with two different sentences: "Chico Ruiz made a spectacular play on Alusik's grounder" and "Olivia De Havilland signed to do a Broadway play for Garson." It answers with two different vectors, each correctly matched to sentences about the same sense of the word.8

The real difference between the 2013 story and a modern model is not the arithmetic. It is what happens to the row immediately afterward. Word2vec's vectors stop at the table: reading the row is the last step as well as the first, so a demo built from those rows tests the whole representation a word will ever get. A transformer's row is only the first step. Pull it up for play in isolation, before attention has touched it, and it tells you as little as Alammar's fifty numbers did. Which sense is meant depends on the sentence, and the sentence has not been consulted yet.

The takeaway

A word turns into a vector in exactly one way: its token id points at a row in a table the model learned, and that row is read, not computed. Word2vec and GloVe stop there. The arithmetic that made them famous, king minus man plus woman landing near queen, is a real result, though the exact sentence traces to a different paper than the one usually credited. A meaningful share of the trick's reported accuracy also depends on a rule that forbids the search from answering with a word already in the question. None of that makes the underlying table meaningless: distances and directions inside it do line up with real relationships in the founding papers' own numbers. A modern model reads the same kind of row. Then it spends every layer above that row reshaping it, using the sentence around it, so the vector for play only settles once the model knows which play is meant. The lookup is where a word becomes a number. The sentence is where that number becomes the right one.

Go deeper optional reading
01
Simon Willison, Embeddings: What they are and why they matter: what the same nearest-neighbor trick does for documents, images, and search once the vectors are not just for single words.
02
Christopher Olah, Deep Learning, NLP, and Representations: goes further into why the offset trick works at all, and marks the exact point where the explanation runs out.

Sources

  1. Vaswani et al. · Attention Is All You Need (NeurIPS 2017)
  2. Mikolov, Chen, Corrado & Dean · Efficient Estimation of Word Representations in Vector Space (2013)
  3. Jay Alammar · The Illustrated Word2vec
  4. Mikolov, Sutskever, Chen, Corrado & Dean · Distributed Representations of Words and Phrases and their Compositionality (NeurIPS 2013)
  5. Pennington, Socher & Manning · GloVe: Global Vectors for Word Representation (EMNLP 2014)
  6. Tal Linzen · Issues in Evaluating Semantic Spaces Using Word Analogies (ACL Workshop, 2016)
  7. Nissim, van Noord & van der Goot · Fair Is Better Than Sensational: Man Is to Doctor as Woman Is to Doctor (2020)
  8. Peters et al. · Deep Contextualized Word Representations (ELMo, NAACL 2018)