So I'm now going to talk about five important hyperparameters for the training process.
And some of these we've talked about briefly before.
But many of these will be somewhat new to you unless you've worked in other data science projects of
this sort.
And the first one I'll mention is epochs, which we did briefly mention some some time ago.
So epochs are referring to how many times are you going to go through your entire data set, uh, as
part of the training process.
So you might imagine that when you're training, you take each of your training data points and you
go through the set once and then you're done.
But in fact, it turns out that you can get more mileage by going back a second time and going through
all of your training data again with your model.
Now you might think, why?
Why does it help to go through a second time when the model already saw it once?
So you're just giving it the same data a second time?
Well, remember when we go through the training optimization process involves going through each of
these points and then making a very small step in the direction of making the model a little bit better,
shifting the weights in our in our Laura matrices a little tiny bit so that next time it does a bit
better.
Um, so every time we go through all of the training data set, we have an opportunity to get a little
tiny bit better.
Um, and presumably once it's gone through, once the model is now in a bit of a different state.
So when it sees it again, it can allow it to refine and do a little bit better.
There is another reason why it often makes sense to have multiple epochs, and that comes down to batch
size.
The next hyperparameter batch size, is saying that often we don't take one data point and put it through
the forward pass of the model to predict the next token, calculate the loss, and then go backwards
and figure out the gradients of how much does that loss?
Is that affected by the different weights in the parameter in the model?
And then optimize the model by doing a little step in the right direction?
Uh, it sometimes makes sense to do that at the same time with a bunch of data points together.
Like often you pick a four or 8 or 16 and you do it together for for all 16.
One reason for doing that is, is performance, that it means that you can just get through everything
faster.
You can do it all together.
If you can fit 16 data points on your GPU, then that's a good thing to do.
There are some other reasons why it might actually be better to do it in batches, than to do it step
by step.
Um, uh, but but, uh, but the basic reason is for performance.
When you do multiple epochs with each epoch, it's typical that you resort or you juggle up all of the
batches.
So they're different batches, different sets of these 16 data points that the model sees with each
of your epochs.
So actually in some ways the data is different for each of these epochs because it's seeing a different
sample of your data points as it goes through them.
And that's another reason why multiple epochs can be good.
Now there's one very common technique which is to at the end of each epoch, you typically save your
model.
And it's quite common to run a bunch of epochs and then test how your model performed at the end of
each of those epochs, and what you often find is that the model was getting better and better as it
learned more and more in each epoch, but then you reach a certain point where the model starts to overfit,
which we talked about last time, where it starts to get so used to seeing this training data that it
starts to solve just for exactly that training data.
And then when you test it, the performance gets worse because it's not expecting points outside its
training data set.
So you start to see like better, better, better, better, worse, worse, worse.
And then the results get continually worse.
And what you do is you run this and you quite simply pick the epoch which gave you the best model,
the best outcome.
And that's the one that you consider the results of your training.
That's the version of the fine tuned model and that's what you take forwards.
So it's common to run a larger number of epochs and then use that kind of testing to pick which one
was your best model.
With that, I will pause and continue with these parameters in the next video.