1
00:00:00,000 --> 00:00:06,000
This specific video, we are going to fine tune gamma model in Keras using the Lora technique.

2
00:00:06,000 --> 00:00:07,000
Created a lot of videos.

3
00:00:07,000 --> 00:00:08,000
How does fine tuning happen?

4
00:00:08,000 --> 00:00:12,000
What is Lora, what is Lora, what is quantization and many more things.

5
00:00:12,000 --> 00:00:15,000
So in this particular video we are going to fine tune the gamma model.

6
00:00:15,000 --> 00:00:20,000
And again remember guys gamma if you don't know it is a completely open source model that has been provided

7
00:00:20,000 --> 00:00:21,000
by Google.

8
00:00:21,000 --> 00:00:27,000
And we'll try to see that how we can actually, uh, you know, fine tune our LM models with respect

9
00:00:27,000 --> 00:00:29,000
to this, with, with our own custom data.

10
00:00:29,000 --> 00:00:30,000
So here, um, what?

11
00:00:30,000 --> 00:00:31,000
All things we are going to use.

12
00:00:31,000 --> 00:00:35,000
Everything, uh, step by step will go ahead and, uh, do it.

13
00:00:35,000 --> 00:00:35,000
Okay.

14
00:00:35,000 --> 00:00:39,000
Now, first of all, uh, you need to complete the setup instruction at gamma setup.

15
00:00:39,000 --> 00:00:44,000
So if you probably click over here you can probably watch this entire you can see this entire, uh,

16
00:00:44,000 --> 00:00:49,000
you know, the, the documentation that is specifically given the first thing that you specifically

17
00:00:49,000 --> 00:00:50,000
required is an API key.

18
00:00:50,000 --> 00:00:56,000
So first of all, go to AI studio.google.com google.com and then click on get API key right.

19
00:00:56,000 --> 00:01:01,000
And if you don't know guys you also have now access of Google Gemini 1.5 Pro which you can probably

20
00:01:01,000 --> 00:01:01,000
access it.

21
00:01:01,000 --> 00:01:02,000
Right.

22
00:01:02,000 --> 00:01:07,000
And then over here after uh going to this particular page you need to click on create API key.

23
00:01:07,000 --> 00:01:08,000
Right.

24
00:01:08,000 --> 00:01:13,000
Once you specifically create API key, you will be just allowed to give them a name, select the project,

25
00:01:13,000 --> 00:01:17,000
give the name, and automatically you'll be able to get an API key over here.

26
00:01:17,000 --> 00:01:18,000
Copy that API key.

27
00:01:18,000 --> 00:01:22,000
My API key is already I've created it, so I'll be specifically using that.

28
00:01:22,000 --> 00:01:22,000
Right.

29
00:01:22,000 --> 00:01:25,000
So you have to just go to AI studio.google.com okay.

30
00:01:25,000 --> 00:01:28,000
So this is the website that you will specifically go to.

31
00:01:28,000 --> 00:01:28,000
Okay.

32
00:01:28,000 --> 00:01:34,000
Then you need to go to kaggle.com and specifically get the access right.

33
00:01:34,000 --> 00:01:39,000
So you need to get the access of this um, you know the gamma setup itself, right.

34
00:01:39,000 --> 00:01:44,000
Uh, so if you go ahead and write Kaggle gamma.

35
00:01:45,000 --> 00:01:45,000
Right.

36
00:01:45,000 --> 00:01:47,000
Uh, axis.

37
00:01:47,000 --> 00:01:48,000
Right.

38
00:01:48,000 --> 00:01:51,000
If you just go ahead and write it over here, here you can see that gamma will be there.

39
00:01:51,000 --> 00:01:54,000
So you have to go to this particular page, log in into it.

40
00:01:54,000 --> 00:01:59,000
And here you will be seeing you have consented the license to uh, license for gamma.

41
00:01:59,000 --> 00:02:05,000
First of all, if you have not consented it here, they'll be asking you an option of request access.

42
00:02:05,000 --> 00:02:07,000
So once you need to click the request the access.

43
00:02:07,000 --> 00:02:12,000
And once you go ahead and select all the terms and condition, you will be able to get the license agreement

44
00:02:12,000 --> 00:02:12,000
right.

45
00:02:12,000 --> 00:02:16,000
So then you'll be able to get the license consent and then you'll be able to use it okay.

46
00:02:16,000 --> 00:02:17,000
So that is the first thing.

47
00:02:17,000 --> 00:02:22,000
And right now all these models are available over here with both uh and it can run on Jax TensorFlow

48
00:02:22,000 --> 00:02:23,000
and PyTorch okay.

49
00:02:23,000 --> 00:02:26,000
So this is the next step that you really need to do.

50
00:02:26,000 --> 00:02:26,000
Right.

51
00:02:26,000 --> 00:02:28,000
And then go ahead and configure it.

52
00:02:28,000 --> 00:02:34,000
I'm already using a paid Google Colab Pro account, so for me, I definitely require a lot of Ram because

53
00:02:34,000 --> 00:02:37,000
I really need to show you a good fine tuning technique.

54
00:02:37,000 --> 00:02:40,000
Okay, so quickly let's go ahead and configure it.

55
00:02:40,000 --> 00:02:43,000
As I said once, you probably go ahead and create a API key.

56
00:02:43,000 --> 00:02:45,000
Go to this particular secret key.

57
00:02:45,000 --> 00:02:49,000
And then you need to right over here as Kaggle key along with the API key.

58
00:02:49,000 --> 00:02:52,000
Otherwise you can also go ahead and write Google API key.

59
00:02:52,000 --> 00:02:52,000
Right.

60
00:02:52,000 --> 00:02:56,000
So I will just enable it so that I'll be able to use it over here okay.

61
00:02:56,000 --> 00:02:58,000
So this is the Google API key that I require.

62
00:02:58,000 --> 00:03:03,000
And if you really want to access it from the Kaggle itself you need to probably select this tool.

63
00:03:03,000 --> 00:03:03,000
Okay.

64
00:03:03,000 --> 00:03:08,000
So once it is done and uh if you want hugging face token, also if you want to use it you have to create

65
00:03:08,000 --> 00:03:08,000
it.

66
00:03:08,000 --> 00:03:08,000
Right.

67
00:03:08,000 --> 00:03:10,000
So all these things are selected.

68
00:03:10,000 --> 00:03:13,000
Now what I'm actually going to do is that import OS and how to okay.

69
00:03:13,000 --> 00:03:17,000
One more thing that you specifically required is Kaggle key and username.

70
00:03:17,000 --> 00:03:18,000
How do you create it.

71
00:03:18,000 --> 00:03:21,000
So you have to probably go to this particular settings button, right?

72
00:03:21,000 --> 00:03:24,000
If you go ahead and click on settings right.

73
00:03:24,000 --> 00:03:29,000
Or once you go ahead and click on settings, I think uh, somewhere the API will be there.

74
00:03:29,000 --> 00:03:31,000
So you can go ahead and create a new token, right?

75
00:03:31,000 --> 00:03:35,000
So once you create a new token you will be getting two important keys.

76
00:03:35,000 --> 00:03:37,000
One is Kaggle key and one is Kaggle username.

77
00:03:37,000 --> 00:03:38,000
So you have to set it up.

78
00:03:38,000 --> 00:03:44,000
So once you probably click on your token, generating a node token will automatically expire the previous

79
00:03:44,000 --> 00:03:44,000
one.

80
00:03:44,000 --> 00:03:46,000
So I'll not do that because I've already done it.

81
00:03:46,000 --> 00:03:51,000
So once you do that, uh, JSON file will get downloaded and there you'll be getting two keys.

82
00:03:51,000 --> 00:03:54,000
One key is the Kaggle key, and one key is the Kaggle username.

83
00:03:54,000 --> 00:03:57,000
So you have to make sure that you have to set all this up over here okay.

84
00:03:57,000 --> 00:04:03,000
Before you start this particular project then we will go ahead and select all the uh we'll go ahead

85
00:04:03,000 --> 00:04:04,000
and set up all the environment over here.

86
00:04:04,000 --> 00:04:06,000
One is the Kaggle username and one is the Kaggle key.

87
00:04:06,000 --> 00:04:08,000
So I will go ahead and execute this.

88
00:04:08,000 --> 00:04:14,000
Once this is basically getting executed, the next step is that we will go ahead and install Keras NLP.

89
00:04:14,000 --> 00:04:19,000
And I think this is the first kind of videos where I have specifically uploaded how you can fine tune

90
00:04:19,000 --> 00:04:21,000
the models in Keras using Laura.

91
00:04:21,000 --> 00:04:24,000
Okay, so Keras is also having this specific feature.

92
00:04:24,000 --> 00:04:28,000
So first of all, I will go ahead and install Keras, NLP and Keras greater than or equal to three.

93
00:04:28,000 --> 00:04:33,000
So once the installation will specifically take place because we are going to use Keras to do the entire

94
00:04:33,000 --> 00:04:34,000
fine tuning.

95
00:04:34,000 --> 00:04:34,000
Okay.

96
00:04:34,000 --> 00:04:36,000
So this is going to take some amount of time.

97
00:04:36,000 --> 00:04:39,000
Uh, then we can go ahead and select the back end.

98
00:04:39,000 --> 00:04:42,000
You can use Jax Torch TensorFlow.

99
00:04:42,000 --> 00:04:45,000
So it already provides all the specific features right.

100
00:04:45,000 --> 00:04:49,000
So in the environment I will be selecting Keras backend as Jax.

101
00:04:49,000 --> 00:04:50,000
Right.

102
00:04:50,000 --> 00:04:51,000
Uh, Jax.

103
00:04:51,000 --> 00:04:56,000
The best thing is that our to to uh again it's just like TensorFlow and torch.

104
00:04:56,000 --> 00:04:57,000
But again it is an completely open source.

105
00:04:57,000 --> 00:05:00,000
You can also use this specific thing okay.

106
00:05:00,000 --> 00:05:05,000
So till the installation is taking place uh then we are going to uh avoid memory fragmentation on the

107
00:05:05,000 --> 00:05:06,000
Jax back end.

108
00:05:06,000 --> 00:05:10,000
So we are going to set this XLA Python client memory fraction.

109
00:05:10,000 --> 00:05:11,000
Okay.

110
00:05:11,000 --> 00:05:13,000
So here we will be setting it to 1.0.

111
00:05:13,000 --> 00:05:17,000
So this is the initial environment that we really need to select okay.

112
00:05:17,000 --> 00:05:21,000
So you are now connected to GPU runtime but not utilizing the GPU.

113
00:05:21,000 --> 00:05:24,000
Don't worry, we will be utilizing because I need to probably do the entire fine tuning with the help

114
00:05:24,000 --> 00:05:25,000
of GPU.

115
00:05:25,000 --> 00:05:31,000
Okay, so initially Kaggle username Kaggle key, then install all the Keras libraries that is specifically

116
00:05:31,000 --> 00:05:31,000
required.

117
00:05:31,000 --> 00:05:34,000
And then you select the back end that is called as Jax.

118
00:05:34,000 --> 00:05:34,000
Okay.

119
00:05:34,000 --> 00:05:36,000
So here we are getting some error.

120
00:05:36,000 --> 00:05:39,000
I think uh, it is a conflict but no worries.

121
00:05:39,000 --> 00:05:40,000
I think it is working fine.

122
00:05:40,000 --> 00:05:44,000
Then we'll go and execute this where we are selecting the back end and this okay.

123
00:05:44,000 --> 00:05:48,000
Now let's go ahead and import Keras and NLP okay.

124
00:05:48,000 --> 00:05:50,000
Keras NLP okay.

125
00:05:50,000 --> 00:05:53,000
Here uh to fine tuning the gamma model.

126
00:05:53,000 --> 00:05:53,000
Right.

127
00:05:53,000 --> 00:05:59,000
Uh, what we need to do is that we need to set up our data set in the form of JSON all file.

128
00:05:59,000 --> 00:05:59,000
Okay.

129
00:05:59,000 --> 00:06:03,000
Where you will be able to see this, I will just go ahead and click this particular link.

130
00:06:03,000 --> 00:06:05,000
And here you will be able to see this okay.

131
00:06:05,000 --> 00:06:07,000
How the data will specifically look like.

132
00:06:07,000 --> 00:06:13,000
So this data is specifically present in hugging face if you go ahead and open it okay.

133
00:06:13,000 --> 00:06:17,000
So I think uh I will go ahead and open it.

134
00:06:17,000 --> 00:06:18,000
Okay.

135
00:06:18,000 --> 00:06:25,000
So here, uh, let's see whether I'll be able to read the JSON, all JSON all format okay.

136
00:06:26,000 --> 00:06:29,000
So JSON format I will just try to load it over here.

137
00:06:30,000 --> 00:06:30,000
Okay.

138
00:06:30,000 --> 00:06:33,000
JSON lines, JSON all.

139
00:06:33,000 --> 00:06:36,000
I think here you'll be able to find out how you can load it.

140
00:06:36,000 --> 00:06:37,000
Okay.

141
00:06:38,000 --> 00:06:40,000
Uh, whether it is asking me to drop it over here.

142
00:06:40,000 --> 00:06:41,000
Let's see.

143
00:06:45,000 --> 00:06:47,000
I can drop it or what?

144
00:06:47,000 --> 00:06:49,000
Okay, so this is how the file looks like.

145
00:06:49,000 --> 00:06:52,000
Here you can see there is a JSON file has two important things.

146
00:06:52,000 --> 00:06:54,000
One is instruction.

147
00:06:54,000 --> 00:06:56,000
See I will just zoom out a little bit.

148
00:06:56,000 --> 00:06:58,000
So here you have something like instruction.

149
00:06:58,000 --> 00:07:00,000
Then you have something like context.

150
00:07:00,000 --> 00:07:03,000
So in this you specifically have one is instruction.

151
00:07:03,000 --> 00:07:04,000
One is context.

152
00:07:04,000 --> 00:07:06,000
Instruction is what is the question.

153
00:07:06,000 --> 00:07:08,000
And context is basically what is the answer.

154
00:07:08,000 --> 00:07:15,000
So if you probably see all the, all the all the all the inputs and outputs are specifically in this

155
00:07:15,000 --> 00:07:16,000
particular structure.

156
00:07:16,000 --> 00:07:17,000
Right.

157
00:07:17,000 --> 00:07:19,000
Because I'm going to use this structure itself.

158
00:07:19,000 --> 00:07:25,000
And for gamma also for even for OpenAI you definitely require in the form of, uh, just JSON all file.

159
00:07:25,000 --> 00:07:25,000
Right?

160
00:07:25,000 --> 00:07:27,000
JSON L right.

161
00:07:27,000 --> 00:07:32,000
So where you have two important information instruction and then you have context.

162
00:07:32,000 --> 00:07:37,000
So based on this you can also create your own file since uh, since I'm showing you a fine tuning technique.

163
00:07:37,000 --> 00:07:41,000
So I will be downloading this uh Dall-E 15 k dot JSON file.

164
00:07:41,000 --> 00:07:44,000
So here you have 15,000 records with respect to this.

165
00:07:44,000 --> 00:07:48,000
As soon as this file will get downloaded, you will be able to see over here.

166
00:07:48,000 --> 00:07:48,000
Okay.

167
00:07:48,000 --> 00:07:50,000
So here you can see Dolly.

168
00:07:50,000 --> 00:07:52,000
Uh, Databricks Dolly 15kg Journal.

169
00:07:52,000 --> 00:07:55,000
Again, it is an open source data set just to show it to you.

170
00:07:55,000 --> 00:07:56,000
You can definitely use it.

171
00:07:56,000 --> 00:08:01,000
Now the next thing over here, you'll be able to see that the code that we are specifically writing

172
00:08:01,000 --> 00:08:02,000
import JSON data.

173
00:08:02,000 --> 00:08:04,000
And then we are opening the JSON file.

174
00:08:04,000 --> 00:08:07,000
Then we are loading all the JSON file into JSON itself.

175
00:08:07,000 --> 00:08:12,000
Then we are reading the context if the feature context does not exist, we will continue.

176
00:08:12,000 --> 00:08:17,000
Otherwise we will create this kind of template right where my instruction will have the instruction

177
00:08:17,000 --> 00:08:20,000
data and response will have the response data okay.

178
00:08:20,000 --> 00:08:24,000
And then we are going to append it inside this particular list of data okay.

179
00:08:24,000 --> 00:08:29,000
Once we do this this is what my first top thousand data looks like.

180
00:08:29,000 --> 00:08:31,000
And here you can see that it is read it.

181
00:08:31,000 --> 00:08:34,000
And here you will be able to see this is my entire data.

182
00:08:34,000 --> 00:08:37,000
uh, uh, with respect to the top 1000.

183
00:08:37,000 --> 00:08:37,000
Okay.

184
00:08:37,000 --> 00:08:39,000
So we are going to just use the top 1000 data.

185
00:08:39,000 --> 00:08:45,000
And uh, the format that we specifically want is basically written over here in this format.

186
00:08:45,000 --> 00:08:47,000
That is instruction with instruction, response with response.

187
00:08:47,000 --> 00:08:47,000
Okay.

188
00:08:47,000 --> 00:08:54,000
Whatever content is present in that JSON file, then, uh, it's time that we will be loading the model

189
00:08:54,000 --> 00:08:54,000
of gamma.

190
00:08:54,000 --> 00:09:00,000
So here we can write Keras underscore NLP dot models dot gamma casual LM from preset.

191
00:09:00,000 --> 00:09:01,000
And there are two types of model.

192
00:09:01,000 --> 00:09:05,000
One is gamma 2 billion parameters and one is gamma 7 billion parameters.

193
00:09:05,000 --> 00:09:06,000
How I'm saying it.

194
00:09:06,000 --> 00:09:10,000
So if you go over here if you go down okay.

195
00:09:10,000 --> 00:09:14,000
So here we have the excess of gamma 2 billion.

196
00:09:14,000 --> 00:09:16,000
Yes 2 billion parameters 7 billion.

197
00:09:16,000 --> 00:09:19,000
Also if you go and search for hugging face this one you'll be able to see.

198
00:09:19,000 --> 00:09:22,000
And this is what is the performance matrix looks like okay.

199
00:09:22,000 --> 00:09:24,000
So here uh you can go ahead and execute this.

200
00:09:24,000 --> 00:09:27,000
And this will load the model from the Kaggle itself.

201
00:09:28,000 --> 00:09:31,000
Uh and then it will be loading into our colab notebook.

202
00:09:31,000 --> 00:09:33,000
All the models are basically getting loaded.

203
00:09:33,000 --> 00:09:35,000
All the weights are specifically getting loaded.

204
00:09:35,000 --> 00:09:37,000
And you can create this model.

205
00:09:37,000 --> 00:09:39,000
I will also show you till the inferencing part.

206
00:09:39,000 --> 00:09:41,000
Each and every thing will be shown over here.

207
00:09:41,000 --> 00:09:47,000
And once it specifically gets loaded, you will be also able to see the entire, uh, how that entire

208
00:09:47,000 --> 00:09:51,000
model is basically created, how many layers it has, how many parameters it has.

209
00:09:51,000 --> 00:09:53,000
And obviously we can see 2 billion parameters.

210
00:09:53,000 --> 00:09:58,000
But just by downloading it, once we download this entire thing in our colab notebook, here you can

211
00:09:58,000 --> 00:10:00,000
see we have this tokenizer called as gamma tokenizer.

212
00:10:00,000 --> 00:10:04,000
Along with this padding mask layer and token id, everything is given over here.

213
00:10:04,000 --> 00:10:05,000
And here.

214
00:10:05,000 --> 00:10:10,000
The total number of parameters are somewhere around 2.5 billion and it is 9.34 GB.

215
00:10:10,000 --> 00:10:15,000
One thing you have to take care guys, if you really want to run this, you really need to have a paid

216
00:10:15,000 --> 00:10:16,000
Google Colab Pro account.

217
00:10:16,000 --> 00:10:19,000
Okay, then, uh, let's go and see this.

218
00:10:19,000 --> 00:10:21,000
And this is just the model.

219
00:10:21,000 --> 00:10:22,000
I've still not fine tuned it.

220
00:10:22,000 --> 00:10:24,000
So without fine tuning we will run this.

221
00:10:24,000 --> 00:10:25,000
Okay.

222
00:10:25,000 --> 00:10:26,000
So we will create template dot format.

223
00:10:26,000 --> 00:10:30,000
And the instruction will be what should I do on a trip to Europe?

224
00:10:30,000 --> 00:10:30,000
Okay.

225
00:10:30,000 --> 00:10:35,000
I'm just asking a generic question to a gamma model and response is completely empty.

226
00:10:35,000 --> 00:10:38,000
Then we take the same Keras underscore NLP.

227
00:10:38,000 --> 00:10:43,000
So here you can see Keras underscore NLP dot sampler top k sampler k is equal to five.

228
00:10:43,000 --> 00:10:46,000
So I'm saying that try to provide me five results out of there.

229
00:10:46,000 --> 00:10:49,000
And whatever gamma underscore lm I have actually done.

230
00:10:49,000 --> 00:10:52,000
We are going to compile a compile with this particular sampler okay.

231
00:10:52,000 --> 00:10:57,000
So once we sample compile it then we can use this gamma underscore LM to generate the prompt.

232
00:10:57,000 --> 00:11:00,000
And it is probably going to give me some five responses.

233
00:11:00,000 --> 00:11:02,000
So if you probably go ahead and see this.

234
00:11:02,000 --> 00:11:07,000
So if you're following my playlist on all the fine tuning playlist, you will definitely be able to

235
00:11:07,000 --> 00:11:09,000
understand how things are going over here.

236
00:11:09,000 --> 00:11:09,000
Right?

237
00:11:09,000 --> 00:11:14,000
So once I execute it, I will be able to see the prompt definitely over here.

238
00:11:14,000 --> 00:11:16,000
But just understand what are the steps?

239
00:11:16,000 --> 00:11:20,000
Initially we create the prompt, then we create a sampler okay.

240
00:11:20,000 --> 00:11:24,000
This sampler will basically say that how much top five results we want.

241
00:11:24,000 --> 00:11:26,000
And then we are going to compile with this sampler.

242
00:11:26,000 --> 00:11:28,000
And then we are going to generate okay.

243
00:11:28,000 --> 00:11:30,000
So here you can see the response is easy.

244
00:11:30,000 --> 00:11:31,000
You should just need to follow the steps.

245
00:11:31,000 --> 00:11:34,000
So and so what are the benefits of travel agency.

246
00:11:34,000 --> 00:11:35,000
What how do I choose.

247
00:11:35,000 --> 00:11:40,000
So five different records will be probably over here over here along with the response okay.

248
00:11:40,000 --> 00:11:43,000
But still we have not fine tuned it with our data set.

249
00:11:43,000 --> 00:11:44,000
So one more example is over here.

250
00:11:44,000 --> 00:11:48,000
Explain the process of photosynthesis in a way that child could understand.

251
00:11:48,000 --> 00:11:52,000
And here again we are using gamma underscore lm dot generate.

252
00:11:52,000 --> 00:11:53,000
And we have already created the sampler.

253
00:11:53,000 --> 00:11:58,000
So here we will be able to see the entire response with respect to the question that we have given and

254
00:11:59,000 --> 00:11:59,000
understand.

255
00:11:59,000 --> 00:12:01,000
Multiple response will be able to get it.

256
00:12:01,000 --> 00:12:06,000
So explain the process of photosynthesis in a way that a child could understand.

257
00:12:06,000 --> 00:12:08,000
So here you can see all the responses are there.

258
00:12:08,000 --> 00:12:09,000
Chlorophyll is a pigment.

259
00:12:09,000 --> 00:12:14,000
Explain how plant absorbs plant capture sunlight energy through the leaves and use it.

260
00:12:14,000 --> 00:12:16,000
Okay, so all these things are definitely there.

261
00:12:16,000 --> 00:12:19,000
But the main thing is with respect to the fine tuning.

262
00:12:19,000 --> 00:12:20,000
Now, lower fine tuning.

263
00:12:20,000 --> 00:12:23,000
I hope you know about the mathematical intuition.

264
00:12:23,000 --> 00:12:27,000
If you have not known, you have very late because I have already uploaded a video in my playlist,

265
00:12:27,000 --> 00:12:27,000
right?

266
00:12:27,000 --> 00:12:28,000
How does Laura work?

267
00:12:28,000 --> 00:12:32,000
Laura works and all that is the prerequisite that if definitely you need to know.

268
00:12:32,000 --> 00:12:36,000
Okay, so this tutorial uses a lot of rank for uh, what is rank?

269
00:12:36,000 --> 00:12:37,000
What is the importance of rank?

270
00:12:37,000 --> 00:12:38,000
Everything I've actually included.

271
00:12:38,000 --> 00:12:43,000
Okay, so here we are going to enable Laura with rank is equal to four.

272
00:12:43,000 --> 00:12:45,000
And now if you go ahead and see the summary okay.

273
00:12:46,000 --> 00:12:49,000
So enable Laura for the model and set the rank to four.

274
00:12:49,000 --> 00:12:50,000
So here you can see the parameters.

275
00:12:50,000 --> 00:12:54,000
Trainable parameters becomes less when compared to the all the parameters over here.

276
00:12:54,000 --> 00:12:57,000
So hardly 1 million parameters are there from billion to million.

277
00:12:57,000 --> 00:12:58,000
Right.

278
00:12:58,000 --> 00:13:01,000
So that many number of trainable parameters only 5.20 MB.

279
00:13:01,000 --> 00:13:07,000
0MB and then note that enabling Laura reduces the number of training parameters significantly from two

280
00:13:07,000 --> 00:13:09,000
point billion to 1.3 million.

281
00:13:09,000 --> 00:13:09,000
Okay.

282
00:13:09,000 --> 00:13:13,000
Then we are going to set the input sequence length to five to L.

283
00:13:13,000 --> 00:13:13,000
Okay.

284
00:13:13,000 --> 00:13:15,000
Again you can change it to 1024.

285
00:13:15,000 --> 00:13:19,000
Also we are going to select the optimizer called as Adam Adam w okay.

286
00:13:19,000 --> 00:13:20,000
In Keras it is already there.

287
00:13:20,000 --> 00:13:24,000
So keras optimizer dot Adam w learning rate is so 0.0005.

288
00:13:24,000 --> 00:13:26,000
Weight decay is 0.01.

289
00:13:26,000 --> 00:13:26,000
Okay.

290
00:13:27,000 --> 00:13:30,000
Uh, this is how we basically set optimizers in Keras.

291
00:13:30,000 --> 00:13:36,000
And then we are also going to exclude from uh, weight uh weight decay, exclude layer norm and bias

292
00:13:36,000 --> 00:13:37,000
terms for decay.

293
00:13:37,000 --> 00:13:38,000
So here we are going to set this up.

294
00:13:38,000 --> 00:13:43,000
And then finally we are going to compile with this specific loss that is sparse categorical cross entropy.

295
00:13:43,000 --> 00:13:48,000
Again since it is a multi-class classification I'm basically using form logits is equal to true.

296
00:13:48,000 --> 00:13:49,000
Then you have optimizers.

297
00:13:49,000 --> 00:13:54,000
then you have weighted parametrics again over the sparse categorical accuracy is given.

298
00:13:54,000 --> 00:13:59,000
And then we do the fit of the entire data with epoch is equal to one and batch size is equal to one.

299
00:13:59,000 --> 00:14:04,000
So this is probably going to take if you're doing it in the paid colab, it is going to take somewhere

300
00:14:04,000 --> 00:14:06,000
around 10 to 15 seconds.

301
00:14:06,000 --> 00:14:09,000
Uh, you can also do along with my execution okay.

302
00:14:09,000 --> 00:14:10,000
It is probably going to start.

303
00:14:10,000 --> 00:14:13,000
And again it is going to take around 10 to 15 minutes.

304
00:14:13,000 --> 00:14:16,000
So we will wait till this entire processing will start.

305
00:14:16,000 --> 00:14:20,000
But we'll wait at least till the first epochs should get started, you know.

306
00:14:20,000 --> 00:14:24,000
And it is going to based on the 1000 data points, I think it is going to take 1000 epochs.

307
00:14:24,000 --> 00:14:24,000
Okay.

308
00:14:24,000 --> 00:14:29,000
Because batch size is only one, because we are going to send the sentence for every, every sentence.

309
00:14:29,000 --> 00:14:34,000
We are going to do the front, forward and backward propagation with the help of Adam w optimizers.

310
00:14:34,000 --> 00:14:34,000
So yes.

311
00:14:34,000 --> 00:14:35,000
Uh, let's wait.

312
00:14:35,000 --> 00:14:37,000
Uh, and I think it should start now.

313
00:14:37,000 --> 00:14:38,000
It has started.

314
00:14:38,000 --> 00:14:44,000
It is hardly going to take somewhere around, uh, nine, nine minutes, 17 seconds.

315
00:14:44,000 --> 00:14:47,000
So we'll wait till this particular thing is getting executed.

316
00:14:47,000 --> 00:14:48,000
And then once it probably takes.

317
00:14:48,000 --> 00:14:49,000
Okay, it shows one hour.

318
00:14:49,000 --> 00:14:50,000
Okay.

319
00:14:50,000 --> 00:14:52,000
But I think it will hardly take 15 to 20 minutes.

320
00:14:52,000 --> 00:14:53,000
Okay.

321
00:14:53,000 --> 00:14:54,000
15 to 20 minutes.

322
00:14:54,000 --> 00:14:57,000
So here you will be able to see as as you keep on going.

323
00:14:57,000 --> 00:14:58,000
The loss is also getting decreased.

324
00:14:58,000 --> 00:15:02,000
The sparse categorical accuracy will also keep on increasing okay.

325
00:15:02,000 --> 00:15:04,000
so we'll wait till this particular happens again.

326
00:15:04,000 --> 00:15:07,000
You can increase the number of epochs to get a more accurate model.

327
00:15:07,000 --> 00:15:11,000
Okay, so let's wait till this particular entire training happens.

328
00:15:11,000 --> 00:15:13,000
And then we are going to see the inferencing part.

329
00:15:13,000 --> 00:15:14,000
Thank you.

330
00:15:14,000 --> 00:15:16,000
So guys finally the fine tuning is done.

331
00:15:16,000 --> 00:15:17,000
And here uh hardly.

332
00:15:17,000 --> 00:15:20,000
It took around ten minutes 10 to 11 minutes okay.

333
00:15:20,000 --> 00:15:25,000
So here you can probably see all the fine tuning accuracy if you increase the number of epochs.

334
00:15:25,000 --> 00:15:27,000
So definitely this accuracy will keep on increasing.

335
00:15:27,000 --> 00:15:30,000
But let's check whether it is working perfectly fine.

336
00:15:30,000 --> 00:15:33,000
We'll also try to understand how to specifically do the inferencing.

337
00:15:33,000 --> 00:15:37,000
So here uh you will be able to see uh, now I'm giving the same question.

338
00:15:37,000 --> 00:15:40,000
What should I do on a trip to Europe?

339
00:15:40,000 --> 00:15:43,000
Now it will be able to give the response based on the data set.

340
00:15:43,000 --> 00:15:43,000
Okay.

341
00:15:43,000 --> 00:15:47,000
So here you can see the previous response was something like this.

342
00:15:47,000 --> 00:15:49,000
Uh, yeah.

343
00:15:49,000 --> 00:15:51,000
It's easy just you just need to follow the steps first.

344
00:15:51,000 --> 00:15:54,000
You must book your trip with the travel agency and all.

345
00:15:54,000 --> 00:16:00,000
But now you think, like it'll be a different response altogether based on the data set we have again

346
00:16:00,000 --> 00:16:01,000
over here.

347
00:16:01,000 --> 00:16:04,000
Same thing sampler gamma underscore lm dot compile.

348
00:16:04,000 --> 00:16:07,000
And then we are going to generate the same thing right.

349
00:16:07,000 --> 00:16:09,000
So now let's go ahead and see the response.

350
00:16:09,000 --> 00:16:12,000
Uh after the fine tuning how the response looks like okay.

351
00:16:12,000 --> 00:16:18,000
So yes I think we should be able to get the response now in just some seconds.

352
00:16:18,000 --> 00:16:24,000
Uh, and similarly uh, the same other example also will try to see explain the process of photosynthesis

353
00:16:24,000 --> 00:16:25,000
in a way a child could understand.

354
00:16:25,000 --> 00:16:28,000
So here you can see now the response is completely different.

355
00:16:28,000 --> 00:16:31,000
The first thing is to get a passport and vision.

356
00:16:31,000 --> 00:16:35,000
Then plan what to do if you're traveling to Europe I have recommended starting out in Paris.

357
00:16:35,000 --> 00:16:36,000
Uh, France.

358
00:16:36,000 --> 00:16:36,000
Paris, France.

359
00:16:36,000 --> 00:16:37,000
France is.

360
00:16:37,000 --> 00:16:39,000
Paris is a great city to start out.

361
00:16:39,000 --> 00:16:43,000
Uh, at, because it's the largest city in France and has tons of things to do.

362
00:16:43,000 --> 00:16:44,000
And all everything is.

363
00:16:44,000 --> 00:16:47,000
You'll be able to see over here right now.

364
00:16:47,000 --> 00:16:51,000
Similarly, with respect to the photosynthesis, uh, so many different kind of answers you saw over

365
00:16:51,000 --> 00:16:57,000
there, but now you'll be able to see that how quickly you are able to get a quick response, and you'll

366
00:16:57,000 --> 00:17:00,000
be able to get a better response, you know, after the fine tuning, the same thing you really need

367
00:17:00,000 --> 00:17:01,000
to do.

368
00:17:01,000 --> 00:17:03,000
Anyhow, I will be giving you the entire materials.

369
00:17:03,000 --> 00:17:04,000
Just go ahead and execute it.

370
00:17:04,000 --> 00:17:08,000
Just the prerequisite is that you really need to understand about the fine tuning techniques.

371
00:17:08,000 --> 00:17:11,000
I will be putting the fine tuning playlist in the description of this particular video.

372
00:17:11,000 --> 00:17:15,000
So here you can see explain the process of photosynthesis enough in a way that child could understand.

373
00:17:15,000 --> 00:17:21,000
Photosynthesis is the process by which plants and some other photos and synthetic organisms uses light

374
00:17:21,000 --> 00:17:23,000
from the sun as a source of energy.

375
00:17:23,000 --> 00:17:24,000
So and so, so and so.

376
00:17:24,000 --> 00:17:26,000
All the information is given, right?

377
00:17:26,000 --> 00:17:29,000
So you can also increase the size of the fine tuning data set.

378
00:17:29,000 --> 00:17:35,000
Train for more steps, setting up a higher lower ranks to increase the probably the uh performance of

379
00:17:35,000 --> 00:17:39,000
this models modify the hyperparameters such as learning rate and weight decay, but I hope you have

380
00:17:39,000 --> 00:17:44,000
understood how you can probably fine tuning fine tuning a gamma model using.

381
00:17:44,000 --> 00:17:47,000
And we have what we have done using, uh, Keras.

382
00:17:47,000 --> 00:17:48,000
And again the technique was used.

383
00:17:48,000 --> 00:17:48,000
Laura.

384
00:17:48,000 --> 00:17:50,000
So I hope you like this particular video.

385
00:17:50,000 --> 00:17:51,000
I'll see you all in the next video.

386
00:17:51,000 --> 00:17:52,000
Have a great day and thank you all.

387
00:17:52,000 --> 00:17:53,000
Take care.

388
00:17:53,000 --> 00:17:53,000
Bye bye.

