deep · 6 min
Embeddings
A token or piece of text turned into a list of numbers, where similar meanings sit close together.
updated 23 Sept 2026
Here's a small search. We have six short documents: one about the Mediterranean diet, one about photosynthesis, one about rivers, one about Shakespeare, one about 20th-century inventions, and one saying Apple's quarterly earnings call is on Thursday, November 2, 2023. Now we ask:
When is Apple's conference call scheduled?
The search hands back the Apple sentence. But look at the words. The question says "conference call" and "scheduled". The document says "earnings call" and gives a date. A search that matched words would have a hard time here. This one matched meaning. How?
Each document, and the question, got turned into a list of numbers, and the list for the question sat closest to the list for the Apple sentence. Those lists are embeddings. Let's build up to them from a toy.
Foods on a line
Say we want to place foods on a scale from "not a sandwich" to "very much a sandwich". A hot dog scores high, a salad low, soup lower still. Every food is now one number, a point on a line.
One number can't tell apple strudel from a hot dog, so let's add a second scale: how much of a dessert it is. Now every food is two numbers, a point on a flat map. Strudel goes up in the dessert corner, and the hot dog and shawarma end up side by side. Add a third scale, how liquid it is, and borscht moves off away from everything else.
That list of numbers is a vector, and the vector for one item is its embedding. Two ideas carry over to the real thing. Every item gets the same number of numbers. And we can measure the distance between two points, where close means alike.
Real embeddings differ in two ways. They're much longer: classic word embeddings use 256, 512 or 1,024 numbers, and GPT-3 used 12,288 per token. And nobody picks the axes. They're learned, and a single axis almost never lines up with something you could name, like "dessertness". The sandwich scale is a teaching toy.
Why not just number the words?
Computers already turn words into numbers. Tokenization gives every token an id. But an id says nothing about meaning: token 318 isn't "near" token 319 in any useful way.
The other old trick is a one-hot vector. For a menu of 5,000 dishes, each dish is 5,000 zeros with a single 1 in its own slot. That's huge, and every dish is exactly as far from every other one. A hot dog is as unlike a shawarma as it is unlike a salad. An embedding is short and every number in it does some work, arranged so distance means something.
Where the numbers come from
Nobody writes embeddings by hand. They start out random and get nudged during training, so that things that behave alike end up near each other.
For words, "behave alike" means "show up in the same kinds of places". If the training text has they rode a horse down into the canyon and they rode a burro down into the Grand Canyon, a model learning to predict the words around each word will give "horse" and "burro" similar vectors.
That idea took off with word2vec in 2013, which learned good word vectors from 1.6 billion words in under a day. Its authors noticed something odd: directions in the space meant things. Take Paris, subtract France, add Italy, and the nearest word is Rome. Biggest − big + small lands near smallest.
How often does that work? The paper's own table of examples would score only about 60% if you demanded exact answers, and it includes misses like small → "larger". The famous king − man + woman ≈ queen works "kind of": in one model, queen sat near the spot, but a bit off. So enjoy it, and don't build on it.
Inside an LLM, a table
An LLM keeps a big table with one row per token in its vocabulary. Once your text has been turned into ids, each id picks its row, and from then on the model works with that row of numbers. It never sees the id again. For GPT-3 the table was 50,257 rows by 12,288 numbers, about 618 million numbers in all. It's the model's first set of learned weights. It starts random, and training arranges it so tokens with similar meanings sit close together. (The model also mixes in where each token sits in the text, so it can tell "dog bites man" from "man bites dog".)
But there's a catch with a lookup table. It doesn't know the sentence. "Orange" gets the same starting row in both of these:
- She wore an orange scarf.
- He squeezed an orange for juice.
One point has to stand for a colour and a fruit. That's called a static embedding, and word2vec works the same way: there, "orange" always sits nearer the colours than "juice".
The layers after the lookup deal with that. They pass information between the tokens and nudge "orange" towards whatever its neighbours suggest. By the end, each token's vector carries the whole sentence. Those are contextual embeddings, and the part that moves the information around is attention.
At the far end, a second table the same size runs the other way, turning the final vector into one score per token for next-token prediction.
Outside the model, an API
Now back to our search. The embeddings that found the Apple sentence didn't come from inside a chat model. They came from an embedding model: a separate model that reads a whole piece of text, a sentence or a page, and gives back one vector for all of it. It has its own endpoint and its own price. OpenAI bills it per input token.
As of 2026-09, OpenAI's text-embedding-3-small returns 1,536 numbers per
text and text-embedding-3-large returns 3,072. Voyage AI's voyage-4
family returns 1,024 by default. Anthropic doesn't make an embedding model
at all. Its docs point Claude users to Voyage AI and suggest comparing
vendors, so a Claude app that needs embeddings uses a second provider.
Turn text into vectors, compare distances: that one trick drives semantic search, clustering, recommendations and classification. How to measure the distance is cosine similarity, and how to pick one of these models is choosing an embedding model.
A few things catch people out when they start using them:
- Embed the question and the documents with the same model. Vectors from different models live in different spaces and can't be compared. Switch models, and you re-embed everything.
- Some APIs want to know which is which. Voyage's
input_typeputs a short instruction in front of your text ("Represent the query for retrieving supporting documents: "). For search, always set it. - Size costs money. Bigger vectors cost more to store and search. OpenAI lets you ask for shorter vectors (3,072 down to 1,024, say) for a small loss in accuracy. Voyage vectors can be cut from 1,024 to 256 and stored as 8-bit or 1-bit numbers, 4 or 32 times smaller.
- They have a knowledge cutoff. OpenAI's
text-embedding-3models know nothing after September 2021.
You'll also hear "embedding" used for three different things: the token table, the vectors moving through the model's layers, and what an embedding API returns. When someone says "the embedding", it's worth asking which.
Close to what?
One last thing about distance. Embeddings only capture what their training rewarded. In a model trained to suggest dishes by time of day, cereal and breakfast sausage sit close together. In a model that sorts vegetarian from non-vegetarian, they're far apart. Same two foods, near in one space and far in another.
So when our search put the question next to the Apple sentence, it meant those texts are related in the way that model learned to see things. That's usually what we want. It isn't a promise that the closest document is correct, or even that a different embedding model would pick the same one.
Further reading
- Embeddings (Machine Learning Crash Course), Google, 2025. The gentlest intro, with the food example and the orange example. Start here if vectors are new to you.
- Efficient Estimation of Word Representations in Vector Space, Mikolov et al. (Google), 2013. The word2vec paper. Look at Table 8 to see how well the analogies really work.
- Transformers, the tech behind LLMs, 3Blue1Brown, 2024. The token table inside GPT-3, and directions that mean things, drawn out.
- minbpe: LLM Tokenization lecture, Andrej Karpathy, 2024. The spot where a token id turns into a row of the embedding table.
- Vector embeddings, OpenAI docs. The API side: model sizes, shortening vectors, and search and classification examples.
- Embeddings, Anthropic docs. Why Claude apps use Voyage AI, and the six-document search from the top of this page.