2

From tokens to vectors

Each ID picks a row of numbers from a table, and a second table adds where the word sits.

Hover or tap a word or a row to follow it from ID to E to X. Tap empty space to reset.

blue frame: learned weights (training changes them)green frame: numbers worked out for this sentence
1Each ID picks a row of numbers
Module 2, step 1: Each ID picks a row of numbers

A table called E has one row of 3 numbers for every token in the vocabulary. Our four IDs pick four rows.

E is the embedding table (10 × 3). A row is the token's embedding vector.

2The same lookup, as a multiplication
Module 2, step 2: The same lookup, as a multiplication

A row of zeros with a single 1, times E, gives exactly one row of E. Same answer, matrix style.

one-hot vector · E = embedding.

3Add where each word sits
Module 2, step 3: Add where each word sits

A second table, P, adds a row for each position. Now the same word in a different place looks different.

X = E[ids] + P[0:4]. P holds learned positional embeddings.

Four words are now four rows of numbers: X, 4 × 3. Each row = the word's own numbers + its position's numbers.