Hello guys.
So we are going to continue the discussion with respect to Transformers.
Now it's time to probably understand about the entire working of decoders.
Already in our previous video we have seen about encoders.
We have understood the in-depth architecture, intuition and how exactly encoder works.
Now let's go ahead and let's try to understand about decoder to cover decoder in transformers.
Uh, here I will be providing you a plan of action how we are going to specifically cover this topics.
So here you can see on the right hand side you have this entire decoder working.
Now inside just one decoder you have this three important components okay.
Masked Multi-head attention Multi-head attention and feed forward neural network.
I hope you know about Multi-head attention, how it exactly works in encoder and all.
You know that you also know about feed forward neural network, but one information that you will be
able to see from the encoders.
Right.
And in the research paper we know that there are six encoders like this.
So the output of the encoder is basically passed to the decoder.
Multi-head attention.
Okay.
So one line you will be able to see it over here.
So we will discuss more about this what exactly it is okay.
So first of all let's go ahead and see the definition.
So here it shows the transformer decoder is responsible for generating the output sequence one token
at a time using the encoder output encoder output and the previously generated token.
So from here also we will be generating some tokens okay.
When I talk about decoder there are three main components and we will be discussing them step by step.
The first main component is mast multi head self attention.
So we will try to understand about this.
How does mast Multi-head self-attention works and why do we use this over here okay so this is the first
important component.
The second important component is multi head attention.
I hope everybody knows what exactly is multi-head attention from the encoder, but we also say this
as encoder decoder attention.
Encoder decoder attention.
So we will also try to understand about this coming to the third one which is basically called as feed
forward neural network.
So these are the most important components that, uh, you need to know about if you really need to
understand about decoders.
Just to give you an idea what exactly how how does encoder and decoder work over here?
So let's say if I am giving if I am giving some information to my encoder.
So if this is my encoder and you know what is exactly there inside your encoder.
So if I'm giving this inputs, let's say I want to translate this entire information right into some
other language.
So what will happen whenever I give some kind of input.
This input from this output from the encoders will probably go to the decoder.
And it should be able to give your output one by one.
So this will be my x one, uh, y one word.
This can be your y two word.
This can be your y three word.
This is the basic difference between encoder and decoder.
Here X1X2X3.
Whichever is the words that I'm actually passing in the form of embedding layer, uh in the form of
embedding vectors, these are all passed all at once okay.
All at once.
But when we see with respect to generation, you'll be able to see that my output will be generated
based on timestamp.
So one word at a time at t is equal to one.
This will get generated t is equal to two.
This will get generated t is equal to three.
This will get generated right.
So that is the basic difference between encoder and decoder and how this is getting generated.
We will talk about this.
So we will try to understand decoder based on two mechanism.
One is training mechanism and one is through the inference mechanism okay.
Inference mechanism like during training how this entire decoder is basically trained and during inferencing
how I will be able, if I give any input to my encoder, how it is basically translating directly to
some other words.
Because while training we will also be giving our real output over here.
Right.
So this will let's say this will be my this is y one hat y two hat y three hat.
Now I will give y one over here, y two over here and y three over here.
And we will do some kind of masking also or padding and masking.
That is what we are going to discuss about.
Okay.
So uh, so this is what we are specifically going to discuss about in the next video.
We are going to probably start with something called as masking.
Uh, the first important thing masking multi-head attention.
So let me just go ahead and write down the topics, what all things we will be discussing over here.
So here the first component that we are going to discuss is something called as.
Masked.
Multi-head.
Self-attention.
Okay, so we are going to discuss about this topic which is the first component in decoder.
Okay.
And remember over here we will also go ahead and divide this.
Let's say the first topic will be input embedding okay.
And then we will again have this positional embedding.
Positional embedding.
Second step we will specifically do the linear projection.
Now I hope you know why linear projection is used for calculating your q k v okay.
Third we will be doing something called as scaled dot product attention.
This also you know why we need to do it okay then over here we will do mask application.
And this is what is the additional step in masked multi-head self-attention when compared to the self-attention
fifth step, we will go ahead and create this multi-head attention mechanism.
Then, coming to the sixth step, it is nothing but concatenation.
And final linear projection.
And coming to the seventh important step is nothing but residual connection and layer normalization.
So if you probably see a self-attention model and if you see a mask, multi-head self-attention.
If I take multi-head self-attention, see in in your encoder.
Also, you had multi-head attention right?
Multi-head self-attention.
So what is the difference between multi-head self-attention and masked multi-head self-attention?
That is, there is one more step which is called as mask application that is getting added.
We will try to understand the importance of this, the importance.
Okay, so in our next video let's go ahead and explore this masked multi-head self-attention step by
step, by taking an example and seeing that.
What is the use of this masked multi-head self-attention?
Okay.
Uh, and here you'll be able to understand the basic difference between, uh, this one.
Right.
Because, see, over here, also, you have multi-head attention here also, you have multi-head attention.
But what is the use of this masked multi-head?
Uh, attention.
Right.
And we will try to understand with respect to training mechanism, first of all.
Okay.
And then I will also be showing that during inferencing with respect to a new data, how this masking
will separately happen.
So yes, this was it from my side.
I will see you all in the next video where we'll discuss about all these points.