LLM Library
FoundationsAnimated
Embeddings
Each token becomes a vector of numbers that captures meaning.
The idea
An embedding table maps each token id to a learned vector. Similar tokens end up with similar vectors, and later layers refine them using context.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
Raw text enters the system, for example "The cat sat on the".
- stage:
- 1/12
- part:
- Text in
1/12
The green dot is one token travelling through the model. The boxed section repeats for every layer.
Step by step
- 1Look up the vector for each token id
- 2Stack them into a matrix
- 3Add position information
- 4Pass the matrix into the first layer
Where it is used
The first step of every transformer; also used for search and RAG.
Watch out for
The same word has the same starting vector. Context is added by attention in later layers.