Lab

Embedding

Embedding: A list of numbers that represents a token or a piece of text, learned so that things used in similar ways end up pointing in similar directions.

A model cannot do maths on letters, so the first thing it does with a token is swap it for a list of numbers. That list is the token’s embedding, and the model keeps one for every token ID in a big table. Looking a token up is just reading its row, and the rest of the model works with those rows, never with the letters.

No single number in an embedding means anything you could name. Meaning is spread across all of them. What matters is how one list compares with another. Treat each embedding as an arrow from the origin: arrows pointing the same way belong to things that are used in similar ways, and arrows at right angles belong to things that are unrelated. The usual measure is cosine similarity, which looks only at direction, not length.

Embeddings are learned, not written by hand. Older word vectors such as GloVe were built from counts of which words appear near each other in a large body of text. In a modern language model, the embedding table is simply the first layer, adjusted during training along with every other weight. Either way, the vectors reflect how words are used in the training text, including its stereotypes.

The same idea works for longer text. An embedding model can turn a sentence or a paragraph into one vector, which is what lets search systems find passages by meaning rather than exact words.

The explainer maps real word vectors, lets you compute a cosine by hand, and shows which directions carry meaning and bias.

See it working

Explore it in Meaning as a map

How word vectors place each word as a point, so words used alike land close together and relationships become directions.

Open the explainer