What's important is that for every token generation step we always feed the whole sequence of previously generated tokens into the decoder, not just the last one. So you start with the token and generate now new token, then feed + into the decoder, so basically just appending the generated token to the sequence of decoder inputs. That might have not been clear in the video. Otherwise great work. Love your channel!
I usually don't write comments, but this channel really deserves one! Thank you so much for such a great tutorial. I watched your first video about Transformers and the Attention mechanism, which was really informative, but this one is even more detailed and useful.
Thanks so much for the compliments! This is the first in a series of videos called “Transformers from scratch “. Hope you’ll check the rest of the playlist out
Thank you so much, I searched so many places, this is the first place finally have a nice person willing to spend time really dig in step by step. I'm going to value this channel as good as Fireship now.
What can I say, dude! God bless you This is the only content on the whole youtube that really explain the self-attention mechanism in a brilliant way. Thank you very much. I'd like to know if the key, query, and value matrixes are updated via backpropagation during the training phase.
Thanks for the kind words. These matrices I mentioned in the code represent the actual data. So no. However, the 3 weight matrices that map a word vector to Q,K,V are indeed updated via backprop. Hope that lil nuance makes sense
This is great! I've been trying to learn attention but it's hard to get past the abstraction in a lot of the papers that mention it, much clearer this way!
I was legit searching for self attention concept vids and thinking that it sucked that you didn't cover it yet. And voila here we are. Thankyou so much for uploading!!
One video to understand them all! Dude thanks I've tried to watch like 10 other videos on transformers and attention, yours was really super clear and much more intuitive!
What are the prerequisites for this video? Do we need to know about encoder decoder architecture before hand? The video feels like I jumped right in the middle of something without any context. I'm confused
Hahahaha your words are too kind! Please check the rest of the Transformers from scratch” playlist for more (it’s fine to miss the metro for education lol)
Excellent video . If you can please make a hello world on self attention like first showing pca representation before self attention and after self attention to show how context impacts the overall embedding
Dear Ajay. Thank you so much for your videos! I have a quick question here. Why did you transpose the values in the softmax function? Also... why did you specify axis=-1? I'm a newbie at this and I'd like to have strong and clear foundations. have a lovely weekend :D
Got it, thank you very much, but one question: What I still don't understand: We are talking about neural networks, and they are trained. So all the math you show here, how do we (know|make sure) that it actually happens inside the network? You don't train specific regions of the NN to specific tasks (like calculating a dot product), right?
The weight matrices that map the original word vectors to these 3 vectors are trainable parameters. So they would be updated by back propagation during training
"query" , "key" , and "value" terms come from the world of databases! So how do individual words in "My name is Ajay" each map to their own query and key and value semantically? that remains a bit foggy. i know you've shown random numbers in the example, but is there any semantic meaning to it? is this the "embeddings" of the LLM?
how do we actually choose the dimensions of Q, K and V? Also, are they parameters that are fixed for each word in the English language, and do we get them from training the model? That part is a little confusing since you just mentioned that Q, V and K are initialized at random, so I assume they have to change in the training of the model.
Thanks, @CodeEmporium / Ajay for the great explanation! One quick question- can you please explain how the true values of Q, K, and V are actually computed? I understand that we start with random initialization but do these get updated through something like backpropagation? If you already have a video of this then would be great if you can state the name/redirect! Thanks once again for helping me speed up my AI journey! :)
That's correct back prop will update these weights. For exact details, you can continue watching this playlist "Transformers From Scratch" where we will build a working transformer. This video was the first in that series. Hope you enjoy it :)
I stop the video sometimes and roll it back some seconds to hear you explaining something again and I am like: "No way that this works, this is insane", some explanations on AI techniques are not enough and yours are truly simple and easy to understand, thank you. Do you collab with anyone when making these videos, or is it done all by yourself?
I have a question, since we generated q k and v randomly, how does the output that you are getting in your jupyter notebook have correct matrix values? like how is the value corresponding to my and name in matrix high, without any training?
Sir, I have my assigment to write report on, " Large Language Model are few shot clinical information extractor" and I have to make such LLM,,, and I reach here to your video. Sir can you please guide me.? Always be thankful!
Each of the q,k,v vectors will be a function of each word (or byte pair encoding) in the sentences. I say a “function” of the sentences since to the word vectors, we add position encoding and then convert into q,k,v vectors via feed forward layers. Some of the later videos in this “Transformers from scratch”playlist show some code on exactly how it’s created. So you can check those out for more intel :)
Ajay, I don't think the point of capturing the context in terms of words 'after' has a significance in language modelling. In language modelling you are predicting only the next word. Yes, for a task like machine translation, yes. Thus I don't think Bi-directional RNNs have anything better to offer for language modelling than the regular (one-way) RNNs. . Let me know what you think
I have a few doubts 1. Do we use multiple ffnn after the attention layer? So suppose we have 100 input words for the encoder then 100 ffnn will get trained ? One for each of the word, i checked the source code but they were using only one, so I'm confused how one FFNN can handle multiple embedding specially with batch size. 2. In decoder do we pass multiple input also, just like encoder layer specially in training part?
Hi I noticed this has been added to the transformer playlist, but there are 2 unavailable tracks - do i need them in order to get the full end to end grasp?
You can follow the order of “transformers from scratch” playlist. This should be the first video in the series. Hope this helps and thanks for watching ! (It’s still being created so you can follow along :) )
@1:41 here you have said that you want the context of the words that will be coming in the future but in masking part of the video you have said that it will be cheating know the context of the words that will be coming in the future
I felt the q, k, v parameter is not explained very well.. similar search analogy would be better to get a intuition of these parameter then explaining as what I can offer, what I actual offer
This is the first video in a series of videos called “Transformers from scratch”. Later videos show how the entire architecture is training. Hope you enjoy the videos
If you think I deserve it, please consider liking the video and subscribing for more content like this :)
do have any idea how transformers generates new data ?
You are amazing man! Of course you deserve it! You are building transformers from the ground up! That's insane!
@@tomoki-v6ousing decoder 😮😮😊
I have learnt so much between yourself, ChatGPT, and Alexander & Ava Amini iat MIT 6.S191. Thank you all.
What's important is that for every token generation step we always feed the whole sequence of previously generated tokens into the decoder, not just the last one. So you start with the token and generate now new token, then feed + into the decoder, so basically just appending the generated token to the sequence of decoder inputs. That might have not been clear in the video. Otherwise great work. Love your channel!
Your videos are way better than Stanford lecture cs224n
Words I am not worthy of. Thank you :)
I usually don't write comments, but this channel really deserves one! Thank you so much for such a great tutorial. I watched your first video about Transformers and the Attention mechanism, which was really informative, but this one is even more detailed and useful.
Thanks so much for the compliments! This is the first in a series of videos called “Transformers from scratch “. Hope you’ll check the rest of the playlist out
It's one of the best videos I have watched. The concepts are explained very much, specially with codes.
ನಮಸ್ಕಾರ ಅಜಯ್, ನೀವು ಕನ್ನಡಿಗ ಎಂದು ತಿಳಿದು ತುಂಬ ಸಂತೋಷವಾಯಿತು!
Thank you so much, I searched so many places, this is the first place finally have a nice person willing to spend time really dig in step by step. I'm going to value this channel as good as Fireship now.
Thanks for the compliments and glad you are sticking around!
What can I say, dude!
God bless you
This is the only content on the whole youtube that really explain the self-attention mechanism in a brilliant way.
Thank you very much.
I'd like to know if the key, query, and value matrixes are updated via backpropagation during the training phase.
Thanks for the kind words. These matrices I mentioned in the code represent the actual data. So no. However, the 3 weight matrices that map a word vector to Q,K,V are indeed updated via backprop. Hope that lil nuance makes sense
I definitely agree.
ನಮಸ್ಕಾರ ಅಜಯ್, ನೀವು ಕನ್ನಡಿಗ ಎಂದು ತಿಳಿದು ತುಂಬ ಸಂತೋಷವಾಯಿತು! ನಿಮ್ಮ ವಿಡಿಯೋಗಳು ತುಂಬ ಚನ್ನಾಗಿ ಮೂಡಿಬರುತ್ತಿವೆ.
Glad you liked this and thanks for watching! :)
This is great! I've been trying to learn attention but it's hard to get past the abstraction in a lot of the papers that mention it, much clearer this way!
I was legit searching for self attention concept vids and thinking that it sucked that you didn't cover it yet. And voila here we are. Thankyou so much for uploading!!
Glad I could deliver. Will be uploading more such content shortly :)
This is exactly what I needed! Can't believe self-attention is that simple!
I still not understand how to perform a backward pass on the self-attention
One video to understand them all! Dude thanks I've tried to watch like 10 other videos on transformers and attention, yours was really super clear and much more intuitive!
Thanks so much for this compliment! Means a lot :)
This is pure gold man!
Transformers are complex but this video really gives me hope.
What are the prerequisites for this video? Do we need to know about encoder decoder architecture before hand? The video feels like I jumped right in the middle of something without any context. I'm confused
@pratyushrao7979 there are Playlists for different topics
This Has been a most wonderful series on this channel so far
Thanks a ton! Super glad you enjoyed the series :D
The best explaination on the internet, thank you!
Thanks so much for the comment. Glad you liked it :)
With all my heart, you deserve a lot of respect
Thanks for the content. Damn I missed my metro station because of you.
Hahahaha your words are too kind! Please check the rest of the Transformers from scratch” playlist for more (it’s fine to miss the metro for education lol)
Extremely well explained. Kudos !!!!
Best video explaining this that ive seen by far
thanks, this is the only video I found useful on attention.
very happy to see kannada here
Great 😍Love from kannadigas
Best contents ever I've seen. Thanks for this video.
Excellent , how well you explained. NO other video on youtube explained like this , Really done good job.
search CampusX
Excellent video . If you can please make a hello world on self attention like first showing pca representation before self attention and after self attention to show how context impacts the overall embedding
waiting for your future videos. This was amazing. especially the masked attention part.
Thanks so much! Will be making more over the coming weeks
Nice explanation. Thanks a lot Kannadiga :)
Bro You're The Best, Mad Respect For You, I'm Subscribing
Thanks a lot for making the video!! This deserves more views.
Thanks for watching. Hope you enjoy the rest of the playlist as I code the entire transformer out !
Great walkthrough of the theory and then relating it to the code.
Thanks so much! Will be making more of these over the coming weeks
Good video Bro.
Studying Transformer this week but still a little confused before I met your video.
Thanks
Thanks for the kind words. I really appreciate it :)
best video found about the topic, great
Thanks a ton for watching
Thank you for making this concept so easy to understand. Can’t thank you enough 😊
My pleasure. Thank you for watching
Great! This is exactly what I was looking for in all of the other videos of yours
Thanks for the comment! There is more to come :)
This is brilliant, I've been looking for a bit more hands on demonstration of how the process is structured.
Thanks so much! Happy you liked it :)
My god, that was amazing, you have a gift my friend;
Love from Brazil :D
Thanks a ton :) Hope you enjoy the channel
Huge respect ❤️
Thanks so much!
Awesome! Well illustrated. Thanks
Wonderful works you've done! I really love your video and have studied twice. Thank you so much!
Thanks so much for watching! More to come :)
Fantastic explanation! Wow! You have a new subscriber. :) Keep up the great work
you made me cry brother
Thanks! U r very deserved and underdog!
Thank you for this very clear and helpful demonstration!
You are so welcome! And be on the lookout for more :)
Thank you for explaining in such an easy way. It would be great if you could upload some codes on GCN algorithm.
I shall explore that possibility!
Absolutely brilliant! Thumba chennagidhay :)
Thanks a ton! Super glad you like this. I hope you like the rest of this series :)
u have saved me. thank u.
Thank you for teaching this.❤
My pleasure! Hope you enjoy the series
Mashallah, man you are a rocket.
Thanks for the kind words :)
Really Appreciate Your Efforts. Love from Gujarat India.
Simply wow..
This is an incredible video, thank you!
Thanks so much for watching and commenting!
Amazing video! Thank you😊😊
You are very welcome
Dear Ajay. Thank you so much for your videos!
I have a quick question here. Why did you transpose the values in the softmax function? Also... why did you specify axis=-1? I'm a newbie at this and I'd like to have strong and clear foundations.
have a lovely weekend :D
Great video. Thank you very much.
Thanks so much!
Thanks!
Thanks for the donation! And you are very welcome!
Amazing work! Very glad I subscribed
Thanks so much for commenting!
why is it d_k in both Q and K in the np.random.randn ?
this is amazing!
Thanks a lot!
Got it, thank you very much, but one question: What I still don't understand: We are talking about neural networks, and they are trained. So all the math you show here, how do we (know|make sure) that it actually happens inside the network? You don't train specific regions of the NN to specific tasks (like calculating a dot product), right?
How did we get the values of q, k and v vectors after initializing them as randoms. Great video btw. Waiting for more such videos.
The weight matrices that map the original word vectors to these 3 vectors are trainable parameters. So they would be updated by back propagation during training
@@CodeEmporium Thanks for clarification
you save my life!!!!!
It’s what I do best :)
this is very helpful
Glad! And thank you!
Brilliant Mate
Thanks a ton! :)
Thank you very much for this great video! Can you please upload a video on Self Attention code using Graph Convolutional Network (GCN)?!
I’ll look into this at some point. Thanks for the tips.
why we need to stabilise the variance of attention vector with query and key vectors.
"query" , "key" , and "value" terms come from the world of databases! So how do individual words in "My name is Ajay" each map to their own query and key and value semantically? that remains a bit foggy. i know you've shown random numbers in the example, but is there any semantic meaning to it? is this the "embeddings" of the LLM?
appreciate!
I really like how you use Kannada language examples in your explanations.
Thx for your efforts!
Super welcome :)
how do we actually choose the dimensions of Q, K and V? Also, are they parameters that are fixed for each word in the English language, and do we get them from training the model? That part is a little confusing since you just mentioned that Q, V and K are initialized at random, so I assume they have to change in the training of the model.
Q - query, V - value and K - key
Thanks, @CodeEmporium / Ajay for the great explanation!
One quick question- can you please explain how the true values of Q, K, and V are actually computed? I understand that we start with random initialization but do these get updated through something like backpropagation? If you already have a video of this then would be great if you can state the name/redirect!
Thanks once again for helping me speed up my AI journey! :)
That's correct back prop will update these weights. For exact details, you can continue watching this playlist "Transformers From Scratch" where we will build a working transformer. This video was the first in that series. Hope you enjoy it :)
which phase does the model take the pretrianed info to decide the output?
Ustad 🙏
too kind :)
Kannada Represent!! 🖐
Haha! Yes 🙌
Ayo yellaru hegiddra?
I stop the video sometimes and roll it back some seconds to hear you explaining something again and I am like: "No way that this works, this is insane", some explanations on AI techniques are not enough and yours are truly simple and easy to understand, thank you.
Do you collab with anyone when making these videos, or is it done all by yourself?
Haha yea. Things aren’t actually super complicated. :) I make these videos on my own. Scripting, coding, research, editing. Fun stuff
I have a question, since we generated q k and v randomly, how does the output that you are getting in your jupyter notebook have correct matrix values? like how is the value corresponding to my and name in matrix high, without any training?
I watched the video around 3 times but I still don't understand.
Why are these awesome videos so unknown?
wow
Sir, I have my assigment to write report on, " Large Language Model are few shot clinical information extractor"
and I have to make such LLM,,, and I reach here to your video.
Sir can you please guide me.?
Always be thankful!
In the demonstration, you generated the q, k & v vectors randomly, but in reality, what will the actual source of those values be?
Each of the q,k,v vectors will be a function of each word (or byte pair encoding) in the sentences. I say a “function” of the sentences since to the word vectors, we add position encoding and then convert into q,k,v vectors via feed forward layers. Some of the later videos in this “Transformers from scratch”playlist show some code on exactly how it’s created. So you can check those out for more intel :)
thx
My pleasure :)
Ajay, I don't think the point of capturing the context in terms of words 'after' has a significance in language modelling. In language modelling you are predicting only the next word. Yes, for a task like machine translation, yes. Thus I don't think Bi-directional RNNs have anything better to offer for language modelling than the regular (one-way) RNNs. . Let me know what you think
I have a few doubts
1. Do we use multiple ffnn after the attention layer? So suppose we have 100 input words for the encoder then 100 ffnn will get trained ? One for each of the word, i checked the source code but they were using only one, so I'm confused how one FFNN can handle multiple embedding specially with batch size.
2. In decoder do we pass multiple input also, just like encoder layer specially in training part?
How could someone hack my brain wave and convoluted this by evaluate inner voice?
May I know this procedure?
#Thanks
Haha ikr. I felt the same. Was looking for a good Self attention video.
Hi I noticed this has been added to the transformer playlist, but there are 2 unavailable tracks - do i need them in order to get the full end to end grasp?
You can follow the order of “transformers from scratch” playlist. This should be the first video in the series. Hope this helps and thanks for watching ! (It’s still being created so you can follow along :) )
i still dont understand the difference between Q K V, can someone explain?
Good job bro, JESUS IS COMING BACK VERY SOON; WATCH AND PREPARE
What is the name of the text book you are using?
if u watch the vid carefully, the url shows the books are "online" free access bibles of the field.
@1:41 here you have said that you want the context of the words that will be coming in the future but in masking part of the video you have said that it will be cheating know the context of the words that will be coming in the future
I felt the q, k, v parameter is not explained very well.. similar search analogy would be better to get a intuition of these parameter then explaining as what I can offer, what I actual offer
Guru aarama? Nanu kooda Kannada ne!
Doin super well ma guy. Thanks for watching and commenting! :)
Bro it's 100% better than your ppt vides
Thanks so much! Just exploring different styles :)
You forgot to show the most important thing, how to train self-attention with backpropagation? You forgot about backward pass
This is the first video in a series of videos called “Transformers from scratch”. Later videos show how the entire architecture is training. Hope you enjoy the videos
@@CodeEmporium thank you, i subscribe
Seriously, are u from karnataka ? your accent is so different dude.
Lots of time on the mask, but none on training the attention matrix 🤔
Bro why can't you encounter an example while explaining