Save this video free

The matrix math behind transformer neural networks, one step at a time!!!

StatQuest with Josh Starmer · 23:43 · Watch on YouTube

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

StatQuest with Josh Starmer breaks down the matrix mathematics underpinning Transformer neural networks, focusing on an encoder-decoder architecture for translation. The explanation details how word embeddings, positional encodings, self-attention (query, key, value matrices, dot products, scaling, softmax), residual connections, and encoder-decoder attention are computed using matrix operations, culminating in the final output probabilities.

Key takeaways

Chapters

0:00 Input Processing: Word Embeddings and Positional Encoding
7:11 Self-Attention Calculation: Queries, Keys, Values, and Similarity
18:23 Decoder Operations: Masked Self-Attention and Encoder-Decoder Attention

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 we're going to do a lot of math row by column aray stat Quest hello I'm Josh starmer and welcome to stat Quest today we're going to talk about the Matrix math behind Transformer neural networks and we're going to go through it one step at a time this stat Quest is brought to you by the letters a b and c a always b b c be curious always be curious note this stack Quest assumes that you already understand the basics of how a Transformer neural network works and that you are already familiar with the essential Matrix algebra that is used with neural networks if not check out the quests in this stack Quest

0:50 we're going to learn how the math associated with an encoder decoder Transformer can be written in Matrix notation hey Josh why would we want to learn this Matrix notation because understanding The Matrix notation will make it infinitely easier to understand how to code Transformers and neural networks in general bam specifically we're going to walk through the Matrix arithmetic used by a Transformer neural network that can translate a simple English sentence let's go into Spanish vamos note we're specifically going through an in encoder decoder Transformer and not an encoder only or decoder only Transformer because encoder decoder Transformers cover everything

1:39 we'll need for any type of Transformer so the first thing we need to do is convert the input phrase let's go into word embeddings actually in this example we're going to start our input phrase with the SOS or start of sequence token so that means we need to determine the word embedding value for SOS lets and go for all three tokens we use the exact same word embedding Network that looks like this where each input has two

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, StatQuest with Josh Starmer.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.