eᵢ — a one-hot vector
Read "e i". It is a vector with a 1 in position i and 0 everywhere else: token number i, written as a vector.
has entries and a single 1, at position . Multiplying it by a matrix picks out row of that matrix: .
No real implementation does that multiplication; it just reads row from memory (nn.Embedding in PyTorch). Writing it as a multiplication shows that the embedding step is an ordinary matrix product like every other layer. It also makes the gradient easy to see: only row of gets updated.
Example
Positions are counted from 0 here, so position 2 is the third slot.
Where the course uses it
Related terms
- |V| — size of the vocabularyRead "the size of V". Single bars around a set mean "how many items it has", so |V| is the number of tokens in the vocabulary.
- { } — a setCurly braces list the members of a set: a collection of values with no order and no repeats. Read {0, 1} as "the set of 0 and 1".
- W_E — the embedding matrixRead "W E". It is a learned table with one row per token in the vocabulary; each row is that token's vector of d_model numbers.