An integer ID isn’t useful as a number (ID 9246 isn’t “bigger” than ID 12 in any meaningful way). So we use an embedding table: a big matrix with one row per token.
Breaking down the notation
Piece Meaning The embedding table (a grid of learned numbers) “is a member of" "A grid of real numbers with rows and columns” Vocabulary size (number of distinct tokens, e.g. 100,000) Width of the model (e.g. 4096 or 8192). The length of each token’s vector
Token ID simply selects row , giving a vector of floats. These vectors are learned parameters, initialized randomly and shaped by training.
What emerges: tokens used in similar contexts end up with similar vectors. Directions in the space come to encode concepts. The old famous example:
Nobody designed that. It’s what minimizes next-token loss.
Try it
Fly around a real embedding space in 3D: Embedding Projector.
Positional information
Attention by itself has no sense of order. It treats the input as a bag of vectors. So we inject position information. Original transformers added sinusoidal or learned position vectors. Most modern LLMs use RoPE (rotary position embeddings), which rotates the query and key vectors by an angle depending on position, so the attention score between two tokens naturally depends on how far apart they are.