Vectors, Matrices & Dot Products: The Math Behind LLMs | LLM Course #11
Module 2 begins: just enough maths. In Lecture 11 of the LLM Masterclass: why everything inside an LLM is numbers, vectors as lists of numbers and arrows, the dot product (chai · tea = 1.47, chai · car = 0.345), matrices and their shape, why a matrix multiplication is really many dot products, and all of it in NumPy with the @ operator. 💻 Code for this lecture (branch lecture-11): https://github.com/programmingline/chotugpt/tree/lecture-11 Lecture 11 of 32 — LLM Masterclass · Module 2: Just enough maths ⚠️ ChotuGPT is a simplified teaching model. The word vectors (chai, tea, car) and the small 'hot drink? / vehicle?' matrix are toy numbers for teaching only. In this lecture: • Everything becomes numbers: token IDs (lecture 2) and word vectors (lecture 5) • A vector is a list of numbers; its length is its number of dimensions • The dot product: multiply matching numbers and add — big when two vectors point the same way • Why cosine similarity divides by the lengths • Matrices: a grid of numbers with a shape (rows × columns); learned weights live in matrices • Matrix × vector: each output is one dot product; matrix × matrix: row times column, inner sizes must match • NumPy: @ for matrix multiplication, words @ words.T gives every pair's dot product at once • Why GPUs matter, and how attention scores are dot products (lecture 18) Chapters: 00:00 Lecture 10 quiz answer 00:12 Module 2: just enough maths 00:24 Everything becomes numbers 00:40 Vectors 01:05 Starting to click? 01:10 The dot product 01:43 Matrices and shape 02:02 Matrix multiplication = many dot products 02:42 NumPy: the @ operator 03:07 Quiz 03:27 Why this matters: Transformers and GPUs 03:47 Recap & next lecture ✅ Lecture 10 quiz answer: B, training on human feedback to follow instructions. The big change was not size. ❓ Quiz: A matrix multiplication is really many… A) Additions B) Dot products C) Divisions. Comment your answer. I reveal it in Lecture 12! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 10 — From GPT-3 to ChatGPT: the modern era ⏭ Next: Lecture 12 — A neural network from scratch Sources: NumPy documentation: numpy.matmul and the @ operator (numpy.org/doc); G. Strang, "Introduction to Linear Algebra" (Wellesley-Cambridge Press); toy word vectors from Lecture 5 of this course. #LLM #LinearAlgebra #NumPy…more
Module 2 begins: just enough maths. In Lecture 11 of the LLM Masterclass: why everything inside an LLM is numbers, vectors as lists of numbers and arrows, the dot product (chai · tea = 1.47, chai · car = 0.345), matrices and their shape, why a matrix multiplication is really many dot products, and all of it in NumPy with the @ operator. 💻 Code for this lecture (branch lecture-11): https://github.com/programmingline/chotugpt/tree/lecture-11 Lecture 11 of 32 — LLM Masterclass · Module 2: Just enough maths ⚠️ ChotuGPT is a simplified teaching model. The word vectors (chai, tea, car) and the small 'hot drink? / vehicle?' matrix are toy numbers for teaching only. In this lecture: • Everything becomes numbers: token IDs (lecture 2) and word vectors (lecture 5) • A vector is a list of numbers; its length is its number of dimensions • The dot product: multiply matching numbers and add — big when two vectors point the same way • Why cosine similarity divides by the lengths • Matrices: a grid of numbers with a shape (rows × columns); learned weights live in matrices • Matrix × vector: each output is one dot product; matrix × matrix: row times column, inner sizes must match • NumPy: @ for matrix multiplication, words @ words.T gives every pair's dot product at once • Why GPUs matter, and how attention scores are dot products (lecture 18) Chapters: 00:00 Lecture 10 quiz answer 00:12 Module 2: just enough maths 00:24 Everything becomes numbers 00:40 Vectors 01:05 Starting to click? 01:10 The dot product 01:43 Matrices and shape 02:02 Matrix multiplication = many dot products 02:42 NumPy: the @ operator 03:07 Quiz 03:27 Why this matters: Transformers and GPUs 03:47 Recap & next lecture ✅ Lecture 10 quiz answer: B, training on human feedback to follow instructions. The big change was not size. ❓ Quiz: A matrix multiplication is really many… A) Additions B) Dot products C) Divisions. Comment your answer. I reveal it in Lecture 12! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 10 — From GPT-3 to ChatGPT: the modern era ⏭ Next: Lecture 12 — A neural network from scratch Sources: NumPy documentation: numpy.matmul and the @ operator (numpy.org/doc); G. Strang, "Introduction to Linear Algebra" (Wellesley-Cambridge Press); toy word vectors from Lecture 5 of this course. #LLM #LinearAlgebra #NumPy