Embeddings Explained: How Token IDs Become Meaning | LLM Course #16
A token ID is only a label. In Lecture 16 of the LLM Masterclass we turn every ID into a vector of learned numbers: the embedding table, the lookup (token IDs pull rows out of a table), why it equals a one-hot vector times the table, how training moves similar tokens close together, real sizes (GPT-2 small), and ChotuGPT's Embedding class in NumPy. 💻 Code for this lecture (branch lecture-16): https://github.com/programmingline/chotugpt/tree/lecture-16 Lecture 16 of 32 — LLM Masterclass · Module 3: Text to numbers ⚠️ ChotuGPT is a simplified teaching model. The ten-token vocabulary, the 4-dimensional table and the 'after training' picture are toy, illustrative values for teaching. In this lecture: • Why token IDs carry no meaning by themselves • The embedding table: one row per token, one column per dimension • Lookup = indexing: our 7 token IDs become a 7 × 4 grid • Why it is the same as a one-hot vector times the table (but faster) • Random at the start, learned during training: similar tokens move close together • Real sizes: GPT-2 small has 50,257 tokens × 768 dimensions ≈ 38.6 million numbers • ChotuGPT's Embedding class in NumPy (chotugpt/embedding.py) • The open problem: the same vector wherever a word appears, so word order is lost Chapters: 00:00 Lecture 15 quiz answer 00:14 Embeddings: meaning as geometry 00:26 Token IDs are only labels 00:46 Building the embedding layer 00:53 The embedding table 01:17 Lookup: IDs pull out rows 01:39 Same as one-hot × table 01:56 Learned, not written by hand 02:21 Real sizes: GPT-2 small 02:40 Embedding in NumPy 03:03 Quiz 03:23 One problem left: word order 03:37 Recap & next lecture ✅ Lecture 15 quiz answer: A, the most frequent pair of tokens. Each merge adds one new token to the vocabulary. ❓ Quiz: An embedding layer is really… A) A lookup table of learned vectors B) A dictionary of definitions C) A sorting algorithm. Comment your answer. I reveal it in Lecture 17! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 15 — Tokenization and BPE ⏭ Next: Lecture 17 — Positional encoding Sources: Y. Bengio et al., "A Neural Probabilistic Language Model", JMLR 2003. T. Mikolov et al., "Efficient Estimation of Word Representations in Vector Space", 2013. A. Radford et al., "Language Models are Unsupervised Multitask Learners", OpenAI 2019 (GPT-2; 50,257-token vocabulary, 768-dimensional smallest model). A. Vaswani et al., "Attention Is All You Need", 2017. #LLM #Embeddings #NumPy…more
A token ID is only a label. In Lecture 16 of the LLM Masterclass we turn every ID into a vector of learned numbers: the embedding table, the lookup (token IDs pull rows out of a table), why it equals a one-hot vector times the table, how training moves similar tokens close together, real sizes (GPT-2 small), and ChotuGPT's Embedding class in NumPy. 💻 Code for this lecture (branch lecture-16): https://github.com/programmingline/chotugpt/tree/lecture-16 Lecture 16 of 32 — LLM Masterclass · Module 3: Text to numbers ⚠️ ChotuGPT is a simplified teaching model. The ten-token vocabulary, the 4-dimensional table and the 'after training' picture are toy, illustrative values for teaching. In this lecture: • Why token IDs carry no meaning by themselves • The embedding table: one row per token, one column per dimension • Lookup = indexing: our 7 token IDs become a 7 × 4 grid • Why it is the same as a one-hot vector times the table (but faster) • Random at the start, learned during training: similar tokens move close together • Real sizes: GPT-2 small has 50,257 tokens × 768 dimensions ≈ 38.6 million numbers • ChotuGPT's Embedding class in NumPy (chotugpt/embedding.py) • The open problem: the same vector wherever a word appears, so word order is lost Chapters: 00:00 Lecture 15 quiz answer 00:14 Embeddings: meaning as geometry 00:26 Token IDs are only labels 00:46 Building the embedding layer 00:53 The embedding table 01:17 Lookup: IDs pull out rows 01:39 Same as one-hot × table 01:56 Learned, not written by hand 02:21 Real sizes: GPT-2 small 02:40 Embedding in NumPy 03:03 Quiz 03:23 One problem left: word order 03:37 Recap & next lecture ✅ Lecture 15 quiz answer: A, the most frequent pair of tokens. Each merge adds one new token to the vocabulary. ❓ Quiz: An embedding layer is really… A) A lookup table of learned vectors B) A dictionary of definitions C) A sorting algorithm. Comment your answer. I reveal it in Lecture 17! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 15 — Tokenization and BPE ⏭ Next: Lecture 17 — Positional encoding Sources: Y. Bengio et al., "A Neural Probabilistic Language Model", JMLR 2003. T. Mikolov et al., "Efficient Estimation of Word Representations in Vector Space", 2013. A. Radford et al., "Language Models are Unsupervised Multitask Learners", OpenAI 2019 (GPT-2; 50,257-token vocabulary, 768-dimensional smallest model). A. Vaswani et al., "Attention Is All You Need", 2017. #LLM #Embeddings #NumPy