Hi and welcome back to this birth course.
So now we are ready to finally build our final model class, that will be our squads, Burt's model,
and actually this won't be so hard as we already have all the tools to build it.
We first just need to call the best player in the same way that we did in our previous applications.
So when we used Berts as an embedded layer, we will do exactly the same thing.
Just we will have to take care when we create our layer.
We need to specify that it will be trainable.
So we want to fine tune the weights and after that we just have to plug the squad layer that we created
before and everything should work perfectly well.
So let's start right now by class that squads and this inherits from T.F. that us that module.
So we start with death in it's self.
We don't need anything except from maybe a fancy name if we feel like doing it.
So name equals that squad.
That's it.
Now we can call super that squads and self and from that we can use in its name equals name.
So that's it for Super.
Now let's create our best player.
So let's create self that that layer which will be had that Carus layer.
So once again I'm just copying, busting the UI that I have on the sides.
That's it.
So once again we'll use the light version of bots so that it's easier to train.
Of course once we see results and once you want to apply this to your personal or professional project,
you can upgrade its by using the first large layer.
But for the sake of this demonstration, we will use the light version of birds, so we call it.
And of course, important thing to do is to specify that trainable equals true.
So we will train the weights.
We will use bots in the fine tuning functions.
So now that we have our first layer, which is the best model we can create as quad layer, which will
be that squat layer that sits.
So we have all our players that have been declared.
Now we will define the function as we did before that will apply, but because we need to manipulate
the inputs so that it fits the bird's inputs shape.
So let's do it with def apply that which takes self and the inputs.
And this time also, as we have seen while creating the square layer, we are working at a word or token
level.
So that means that we will need a vector for each token.
So we want to use the first outputs of birds and we call the second one sequence outputs equal self
that that layer.
And so the way Google handled the data processing Phase four squads is that the inputs is actually a
dictionary.
So we want to access the inputs, IDs and input Muskan segment IDs by calling the first, the second
or the third ID of a dimension.
What we need to do is just that we want from the inputs, the inputs, ideas.
So that's the result of the first function that we wrote in the previous applications to create our
input.
That and now we need to do the same thing to get the input mask for the padding and finally inputs segment
IDs, so to know where the adduction is from the first or the second sentence.
So that's it for applying.
But of course, all we have to do is to return the results.
So the sequence outputs, that's it.
We have created the the function that will apply, but at the beginning of our model.
So let's just finish the job by defining code, which takes selfs and inputs.
And we of course start by calling output, which is the result of the application of apply that to the
inputs inputs and then we can.
Use those that representation of the words as input for our vertical layer and our base layer, which
tends to tenses, so it will return, I will start logits.
So this course to be the beginning of the answer and and logits.
So this course to be the end of the answer.
And we get them by calling self that squad layer applied to SEC outputs and that's it.
That's as simple as that is.
All we have to do is to return our two list of scores.
So starts Logits and and Logits and that it we have a good model to tackle this quite task, which is
so a standard question answering task.
Let's see how we train.
That's how we use a special optimizer and all that to finally be able to evaluate the results with the
squad, evaluate scripts.
So let's go through the training phase and use an.