1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:04,000
So we are going to continue the discussion with respect to our Langton series.

3
00:00:04,000 --> 00:00:09,000
And in this video, we are going to create a generative AI application with the help of Lama uh, where

4
00:00:09,000 --> 00:00:10,000
we will be using open source models.

5
00:00:10,000 --> 00:00:14,000
So let me quickly go ahead and open my files.

6
00:00:14,000 --> 00:00:17,000
So here you can see these are my entire files over here okay.

7
00:00:17,000 --> 00:00:19,000
And I can do all this task which we did with OpenAI.

8
00:00:19,000 --> 00:00:21,000
But here I've created another folder.

9
00:00:21,000 --> 00:00:24,000
So let me just go ahead and create my app Dot Pi.

10
00:00:24,000 --> 00:00:26,000
And we'll try to create an end to end project.

11
00:00:26,000 --> 00:00:26,000
Okay.

12
00:00:26,000 --> 00:00:32,000
And this end to end project we will be using Streamlit and we'll be using some requirements.txt and

13
00:00:32,000 --> 00:00:32,000
all.

14
00:00:32,000 --> 00:00:32,000
Okay.

15
00:00:32,000 --> 00:00:37,000
So first of all, uh, as usual, uh, what I'm actually going to do quickly, first of all, let me

16
00:00:37,000 --> 00:00:40,000
just go ahead and open this over here, okay?

17
00:00:40,000 --> 00:00:42,000
I will be using all this information.

18
00:00:42,000 --> 00:00:43,000
Okay.

19
00:00:43,000 --> 00:00:48,000
Over here also, uh, because I really need to have I don't need to have OpenAI key.

20
00:00:48,000 --> 00:00:49,000
Okay, I'll remove this.

21
00:00:49,000 --> 00:00:55,000
But for my language tracking, I need to have all these particular values like API key and all and.

22
00:00:55,000 --> 00:00:55,000
All right.

23
00:00:55,000 --> 00:01:01,000
Now, uh, quickly, uh, what I am actually going to do is that, uh, from I will go ahead and, uh,

24
00:01:01,000 --> 00:01:05,000
import some of the libraries and for importing some of the libraries, I will go again over here.

25
00:01:05,000 --> 00:01:06,000
Okay.

26
00:01:06,000 --> 00:01:09,000
Let's go ahead and from Lang Chain okay.

27
00:01:09,000 --> 00:01:10,000
Underscore community.

28
00:01:10,000 --> 00:01:16,000
Now ulama is basically present inside this uh, library itself long chain underscore community because

29
00:01:16,000 --> 00:01:21,000
ulama Olama is something is just like a third party integration where you can use various models.

30
00:01:21,000 --> 00:01:22,000
Right.

31
00:01:22,000 --> 00:01:24,000
So Langston underscore community dot LMS.

32
00:01:24,000 --> 00:01:25,000
Okay.

33
00:01:25,000 --> 00:01:28,000
If you use this, I will be able to import Olama.

34
00:01:28,000 --> 00:01:28,000
Okay.

35
00:01:28,000 --> 00:01:35,000
And Olama will be specifically used in order to create my, uh, LM models.

36
00:01:35,000 --> 00:01:35,000
Okay.

37
00:01:35,000 --> 00:01:37,000
So here we have this olama.

38
00:01:37,000 --> 00:01:37,000
Okay.

39
00:01:38,000 --> 00:01:41,000
Um, along with this, you'll be able to see that I'm going to use Streamlit.

40
00:01:41,000 --> 00:01:45,000
So let's go ahead and write, uh, import Streamlit as st.

41
00:01:46,000 --> 00:01:50,000
And since we are working in the virtual environment right now, Streamlit is not available.

42
00:01:50,000 --> 00:01:54,000
So let me just quickly go ahead and install this also in the requirement dot txt.

43
00:01:54,000 --> 00:02:01,000
So here in my requirement dot txt I have this uh let's go ahead and install this so quickly we'll go

44
00:02:01,000 --> 00:02:05,000
ahead and write pip install minus r requirement dot txt.

45
00:02:05,000 --> 00:02:05,000
Okay.

46
00:02:05,000 --> 00:02:08,000
So here you can see all the installation will start taking place.

47
00:02:08,000 --> 00:02:13,000
Uh, and uh my Streamlit library which is the recent one that will also get installed.

48
00:02:13,000 --> 00:02:13,000
Okay.

49
00:02:13,000 --> 00:02:15,000
So let this installation takes place.

50
00:02:15,000 --> 00:02:18,000
It will probably take some amount of time with respect to this.

51
00:02:18,000 --> 00:02:19,000
Now I'll go to my app Dot Pi.

52
00:02:19,000 --> 00:02:22,000
And since you know that I have imported Streamlit as St.

53
00:02:22,000 --> 00:02:30,000
Along with this, I will go ahead and uh, from lang che dot from lang chain underscore core.

54
00:02:30,000 --> 00:02:33,000
I'm going to basically use long chain underscore core dot prompts.

55
00:02:33,000 --> 00:02:38,000
Okay I'm going to just import chart prompt template okay.

56
00:02:38,000 --> 00:02:40,000
Chart prompt template.

57
00:02:40,000 --> 00:02:43,000
So chart prompt template is basically to design my own chart prompt.

58
00:02:43,000 --> 00:02:47,000
Uh like what I really want this open source models to do.

59
00:02:47,000 --> 00:02:53,000
So that entire thing I will be defining in this particular chart prompt template like how we did it

60
00:02:53,000 --> 00:02:54,000
in the simple app.

61
00:02:54,000 --> 00:02:54,000
Right?

62
00:02:54,000 --> 00:02:57,000
We also imported this C over here somewhere.

63
00:02:57,000 --> 00:02:58,000
We have used chart prompt.

64
00:02:58,000 --> 00:02:59,000
Right.

65
00:02:59,000 --> 00:03:03,000
So if I go and show you down this is what is my chart prompt template.

66
00:03:03,000 --> 00:03:03,000
Right.

67
00:03:03,000 --> 00:03:06,000
So I'm going to also going to use it over here.

68
00:03:06,000 --> 00:03:14,000
Now once this is done uh now let's quickly go ahead and right from uh from line chain okay.

69
00:03:14,000 --> 00:03:17,000
So I think the installation has been done right.

70
00:03:17,000 --> 00:03:18,000
It's complete.

71
00:03:18,000 --> 00:03:19,000
Perfect.

72
00:03:19,000 --> 00:03:20,000
Uh, so we are good to go.

73
00:03:20,000 --> 00:03:21,000
Let me do one thing.

74
00:03:21,000 --> 00:03:24,000
Let me just hide my face so that you'll be able to clearly see the text.

75
00:03:24,000 --> 00:03:25,000
Okay, then.

76
00:03:25,000 --> 00:03:28,000
Uh, quickly, I'll go ahead and write from Langston.

77
00:03:28,000 --> 00:03:31,000
Underscore code, dot output parser.

78
00:03:31,000 --> 00:03:39,000
I'll also be using this string output parser SDR output parser.

79
00:03:39,000 --> 00:03:39,000
Okay.

80
00:03:39,000 --> 00:03:41,000
So all these things are there.

81
00:03:41,000 --> 00:03:41,000
Okay.

82
00:03:41,000 --> 00:03:47,000
Now quickly let me just close this file and again open it, uh, so that I'll be able to load all these

83
00:03:47,000 --> 00:03:48,000
libraries.

84
00:03:48,000 --> 00:03:49,000
Uh, clearly.

85
00:03:49,000 --> 00:03:50,000
Right.

86
00:03:50,000 --> 00:03:54,000
I don't know why this libraries are not getting loaded, because, uh, we'll just be able to see some

87
00:03:54,000 --> 00:03:56,000
green color, something like that.

88
00:03:56,000 --> 00:03:56,000
Okay.

89
00:03:56,000 --> 00:03:59,000
Uh, but since we are using Streamlit, uh, let me do one thing.

90
00:03:59,000 --> 00:04:01,000
Let me just quickly run this.

91
00:04:01,000 --> 00:04:05,000
So in order to run Streamlit, I will just go ahead and write Streamlit, run.app.py.

92
00:04:05,000 --> 00:04:05,000
pi.

93
00:04:05,000 --> 00:04:08,000
So quickly you'll be able to see.

94
00:04:08,000 --> 00:04:10,000
Okay app dot Pi does not exist.

95
00:04:10,000 --> 00:04:14,000
It's okay because I need to go inside this particular folder lang chain and then Olama.

96
00:04:14,000 --> 00:04:15,000
Okay.

97
00:04:15,000 --> 00:04:22,000
So here I will go ahead and write CD, uh CD one lang chain.

98
00:04:22,000 --> 00:04:24,000
So inside this particular folder I'll go.

99
00:04:24,000 --> 00:04:27,000
Please make sure that you see this, how I'm running this particular file.

100
00:04:27,000 --> 00:04:34,000
Because this app dot Pi is available inside this 1.20 llama folder, right inside one lang chain and

101
00:04:34,000 --> 00:04:35,000
1.20 llama.

102
00:04:35,000 --> 00:04:39,000
So I will go again back to this 1.20 llama okay.

103
00:04:39,000 --> 00:04:44,000
And here I'm just going to write Streamlit run app dot pi okay.

104
00:04:44,000 --> 00:04:45,000
So we'll go ahead and execute it.

105
00:04:45,000 --> 00:04:47,000
See any error is probably coming up.

106
00:04:48,000 --> 00:04:50,000
So this is the Streamlit app right now.

107
00:04:50,000 --> 00:04:51,000
No error is there.

108
00:04:51,000 --> 00:04:52,000
It is a blank page.

109
00:04:52,000 --> 00:04:55,000
So I think uh whatever things we are doing, it is working absolutely fine.

110
00:04:55,000 --> 00:04:59,000
Okay, so, uh, this is the local host where it is specifically running.

111
00:04:59,000 --> 00:05:00,000
Running.

112
00:05:00,000 --> 00:05:00,000
Okay.

113
00:05:01,000 --> 00:05:03,000
Uh, so let me just close this again.

114
00:05:03,000 --> 00:05:08,000
Uh, we'll go ahead and close this particular terminal and we'll continue our coding.

115
00:05:08,000 --> 00:05:09,000
Uh, with respect to this.

116
00:05:09,000 --> 00:05:09,000
Okay.

117
00:05:09,000 --> 00:05:15,000
Now we have actually done this, we have also used this length metric, uh, tracking.

118
00:05:15,000 --> 00:05:19,000
Now, the thing is that we need to use this LM model.

119
00:05:19,000 --> 00:05:19,000
So.

120
00:05:19,000 --> 00:05:21,000
Which have actually imported it over here.

121
00:05:21,000 --> 00:05:23,000
Okay, so let's quickly do this.

122
00:05:23,000 --> 00:05:27,000
Uh, first of all, I will go ahead and design my prompt template.

123
00:05:27,000 --> 00:05:27,000
Okay.

124
00:05:27,000 --> 00:05:30,000
Now, inside this prompt template I will go ahead and create my prompt.

125
00:05:30,000 --> 00:05:33,000
This will be my chat prompt template okay.

126
00:05:34,000 --> 00:05:38,000
Template dot from underscore message okay.

127
00:05:39,000 --> 00:05:44,000
And inside this uh I'm going to I'm going to basically define my prompts.

128
00:05:44,000 --> 00:05:48,000
So first of all, I will go ahead and say this will be my system prompt write system basically means

129
00:05:48,000 --> 00:05:51,000
what I really want the AI assistant to do.

130
00:05:51,000 --> 00:05:52,000
So I'll put a message over here.

131
00:05:52,000 --> 00:05:57,000
Hey, you are a helpful assistant, okay.

132
00:05:57,000 --> 00:06:00,000
Please respond.

133
00:06:01,000 --> 00:06:06,000
Respond to the question asked.

134
00:06:06,000 --> 00:06:09,000
Okay, so this is a simple prompt that I'm writing over here.

135
00:06:09,000 --> 00:06:09,000
Okay.

136
00:06:09,000 --> 00:06:12,000
So this basically becomes for my system.

137
00:06:12,000 --> 00:06:19,000
And now with respect to the user, I will give an input to the user saying that, hey, uh, this will

138
00:06:19,000 --> 00:06:20,000
be my question okay.

139
00:06:20,000 --> 00:06:22,000
So this will be my question.

140
00:06:22,000 --> 00:06:26,000
And this question will be I'll be using an input variable which is like question over here.

141
00:06:26,000 --> 00:06:26,000
Okay.

142
00:06:26,000 --> 00:06:29,000
So this basically becomes my chat prompt template.

143
00:06:29,000 --> 00:06:30,000
Very much simple over here.

144
00:06:30,000 --> 00:06:31,000
Right.

145
00:06:31,000 --> 00:06:34,000
And uh this is my language tracking.

146
00:06:34,000 --> 00:06:34,000
Everything is fine.

147
00:06:34,000 --> 00:06:37,000
And I've also created my chart prompt template.

148
00:06:37,000 --> 00:06:37,000
Perfect.

149
00:06:37,000 --> 00:06:40,000
Now let's go ahead and design my Streamlit framework okay.

150
00:06:40,000 --> 00:06:45,000
So here I will go ahead and write Streamlit framework okay.

151
00:06:45,000 --> 00:06:49,000
And inside the string framework let me go ahead and write my s t dot title.

152
00:06:49,000 --> 00:06:58,000
Now with respect to the title I'll say hey this is my launch and demo with let's say I want to go ahead

153
00:06:58,000 --> 00:07:03,000
and use, uh, llama two or Google Gamma model, or let's go ahead and say, right, Google gamma model,

154
00:07:03,000 --> 00:07:06,000
okay, Google Gamma or let's go ahead and see llama two.

155
00:07:06,000 --> 00:07:07,000
Okay.

156
00:07:07,000 --> 00:07:08,000
I have also installed llama two.

157
00:07:08,000 --> 00:07:12,000
Llama two is a model LM model but from Facebook okay.

158
00:07:12,000 --> 00:07:14,000
So llama two okay.

159
00:07:14,000 --> 00:07:17,000
Now again you can go ahead and use llama three.

160
00:07:17,000 --> 00:07:18,000
Whatever you want.

161
00:07:18,000 --> 00:07:20,000
You can go ahead and use it okay.

162
00:07:20,000 --> 00:07:22,000
So I'll just go ahead and write my input underscore text.

163
00:07:22,000 --> 00:07:26,000
And here I'll be saying hey this is my text underscore input okay.

164
00:07:27,000 --> 00:07:28,000
Uh with respect to this.

165
00:07:28,000 --> 00:07:30,000
So here you can see everything is got loaded.

166
00:07:30,000 --> 00:07:31,000
You know it will take some time.

167
00:07:31,000 --> 00:07:34,000
But right now you can see everything is in green color.

168
00:07:34,000 --> 00:07:41,000
Now inside this text dot input I will say, hey, uh, uh, what what question you have in mind.

169
00:07:41,000 --> 00:07:42,000
Okay.

170
00:07:42,000 --> 00:07:45,000
Something you have in mind?

171
00:07:45,000 --> 00:07:47,000
Okay, so this is my first question.

172
00:07:50,000 --> 00:07:51,000
It is a text input over here.

173
00:07:51,000 --> 00:07:53,000
So I will probably write any question over here.

174
00:07:53,000 --> 00:07:56,000
And I will go ahead and ask my LM models and shot.

175
00:07:56,000 --> 00:07:56,000
Okay.

176
00:07:56,000 --> 00:08:02,000
Then uh, quickly, uh, what I'm actually going to do over here is that I will just go ahead and call

177
00:08:02,000 --> 00:08:04,000
my llama llama two model.

178
00:08:04,000 --> 00:08:06,000
Now, see, this is the most important thing.

179
00:08:06,000 --> 00:08:08,000
How do I specifically call it?

180
00:08:08,000 --> 00:08:08,000
Right?

181
00:08:08,000 --> 00:08:12,000
You know that llama is basically present in long chain underscore communities dot lm.

182
00:08:12,000 --> 00:08:18,000
So I can use this class of llama and I can create my own llama.

183
00:08:18,000 --> 00:08:21,000
I can go ahead and create my llama two model okay.

184
00:08:21,000 --> 00:08:26,000
So if I go ahead and write llama two so that basically it will go and search in the local, whether

185
00:08:26,000 --> 00:08:30,000
llama two is model is present or not, if it is not present, then you have to probably go ahead and

186
00:08:30,000 --> 00:08:35,000
use your command prompt and go ahead and just write Llama Run llama two along with llama two.

187
00:08:35,000 --> 00:08:37,000
You can also go ahead and explore any other model that you want.

188
00:08:37,000 --> 00:08:41,000
Let's say in this particular case I will be writing.

189
00:08:41,000 --> 00:08:42,000
So llama two is here.

190
00:08:42,000 --> 00:08:44,000
I will just use gamma to be okay.

191
00:08:44,000 --> 00:08:47,000
So if you want this I will also show you this.

192
00:08:47,000 --> 00:08:50,000
So here you can see this is my model I'm going to use gamma.

193
00:08:50,000 --> 00:08:54,000
Gamma is my uh Google open source model okay.

194
00:08:54,000 --> 00:08:56,000
Again it is an LM model altogether.

195
00:08:56,000 --> 00:08:58,000
Right now let's say that I have used this particular LM model.

196
00:08:58,000 --> 00:09:04,000
So I'll just go ahead and update this gamma model itself okay.

197
00:09:04,000 --> 00:09:06,000
And let's call this.

198
00:09:06,000 --> 00:09:07,000
And you can call any other model right.

199
00:09:07,000 --> 00:09:09,000
Whatever model name is over there.

200
00:09:09,000 --> 00:09:10,000
You can just go ahead and write it over here okay.

201
00:09:10,000 --> 00:09:17,000
But please make sure that you do the, you do the, uh, installation or you download that particular

202
00:09:17,000 --> 00:09:21,000
model in your local just by writing to run that specific model name.

203
00:09:21,000 --> 00:09:27,000
Now, I'll go ahead and probably create my output parser to just show that how my output should be displayed.

204
00:09:27,000 --> 00:09:29,000
And then finally I'll go ahead and create my chain.

205
00:09:29,000 --> 00:09:31,000
Now I have already in chain what I'll do.

206
00:09:31,000 --> 00:09:33,000
First I will go ahead and use my prompt.

207
00:09:33,000 --> 00:09:40,000
Then after using prompt, I'm just going to use my LM and after using my LM I'll be using output parser.

208
00:09:40,000 --> 00:09:40,000
Right.

209
00:09:40,000 --> 00:09:41,000
So all these things will be there.

210
00:09:42,000 --> 00:09:47,000
Now finally, in order to run it, I'll say, hey, if I put any thing in my input text and if I press

211
00:09:47,000 --> 00:09:54,000
enter, right, what it should do, it should basically take this particular chain and invoke invoke

212
00:09:54,000 --> 00:10:00,000
my invoke this chain by giving this input parameter of question.

213
00:10:00,000 --> 00:10:04,000
And whatever input is basically coming, it will basically come from this input text.

214
00:10:04,000 --> 00:10:05,000
Okay.

215
00:10:06,000 --> 00:10:09,000
Now with respect to this, I will be getting some kind of response.

216
00:10:09,000 --> 00:10:15,000
And this response I will just go ahead and write it in my in my system.

217
00:10:15,000 --> 00:10:16,000
Okay.

218
00:10:16,000 --> 00:10:18,000
So here you can see I'm writing it in my system.

219
00:10:18,000 --> 00:10:22,000
So here this is what I have actually done it right.

220
00:10:22,000 --> 00:10:23,000
And this is a beautiful thing.

221
00:10:23,000 --> 00:10:25,000
I've used the open source model over here.

222
00:10:25,000 --> 00:10:27,000
No open API and all.

223
00:10:27,000 --> 00:10:30,000
You'll also be able to see that we'll be keeping the track in the Lange Smith.

224
00:10:30,000 --> 00:10:32,000
And this time you will not be having any cost involved.

225
00:10:32,000 --> 00:10:35,000
So let me go ahead and execute this.

226
00:10:35,000 --> 00:10:40,000
So here, first of all, I will just go ahead and open my command prompt okay.

227
00:10:40,000 --> 00:10:43,000
Let me quickly delete this okay.

228
00:10:43,000 --> 00:10:47,000
Now I will go ahead and write Streamlit run app dot Pi.

229
00:10:47,000 --> 00:10:50,000
This is how you run a Streamlit file.

230
00:10:50,000 --> 00:10:52,000
Uh, please make sure that this will give me an error.

231
00:10:52,000 --> 00:10:54,000
The reason is very simple.

232
00:10:54,000 --> 00:10:58,000
I am not inside the right folder where app dot Pi is present, right?

233
00:10:58,000 --> 00:11:04,000
App dot Pi is basically present in 1.20 folder, which is inside one lang chain.

234
00:11:04,000 --> 00:11:06,000
Many people will find this as a confusion.

235
00:11:06,000 --> 00:11:10,000
They are not able to run it and it shows file does not exist over here, right?

236
00:11:10,000 --> 00:11:19,000
So what we will do, we will go to this location CD one Lang chain, then CD uh, one point let's say

237
00:11:19,000 --> 00:11:21,000
two Olama.

238
00:11:21,000 --> 00:11:23,000
And here I'll create the screen.

239
00:11:23,000 --> 00:11:29,000
Now, before I run this, I will just make one changes over here inside this olama, I'm just going

240
00:11:29,000 --> 00:11:31,000
to give my model parameter okay.

241
00:11:31,000 --> 00:11:32,000
So this will be my model parameter.

242
00:11:32,000 --> 00:11:34,000
Otherwise it will give us an error okay.

243
00:11:35,000 --> 00:11:40,000
Uh, the reason is very simple because, uh, you know, uh, it will say that, hey, you have given

244
00:11:40,000 --> 00:11:42,000
one additional parameter or something like that.

245
00:11:42,000 --> 00:11:42,000
Okay.

246
00:11:42,000 --> 00:11:44,000
So let's go ahead and now run it.

247
00:11:44,000 --> 00:11:49,000
Uh, for running it, uh, I have to make sure that I have to just go ahead and write Streamlit.

248
00:11:49,000 --> 00:11:50,000
Run.

249
00:11:50,000 --> 00:11:51,000
App.py.

250
00:11:51,000 --> 00:11:53,000
Now, let's go ahead and run this entire thing.

251
00:11:53,000 --> 00:11:57,000
Now, here you can actually see this is what it is.

252
00:11:57,000 --> 00:11:59,000
They're launching demo with gamma model.

253
00:11:59,000 --> 00:12:00,000
Now what question I have in mind.

254
00:12:00,000 --> 00:12:05,000
So I'll just go ahead and ask hey what is generative AI so quickly?

255
00:12:05,000 --> 00:12:06,000
I'll go ahead and press enter.

256
00:12:06,000 --> 00:12:09,000
You'll be able to see that I will be able to quickly get the response.

257
00:12:09,000 --> 00:12:12,000
Uh, and again, everything is running over here.

258
00:12:12,000 --> 00:12:15,000
You can see we will be communicating with this gamma model.

259
00:12:15,000 --> 00:12:18,000
And finally you can see that I am able to see that entire response.

260
00:12:18,000 --> 00:12:19,000
Right.

261
00:12:19,000 --> 00:12:26,000
So I hope you are able to understand that how we can probably use Lama and, uh, create our entire

262
00:12:26,000 --> 00:12:32,000
end to end AI application with any custom, uh, with any open source models like llama three, llama

263
00:12:32,000 --> 00:12:37,000
two, gamma, or any other models that is available or supportable by llama.

264
00:12:37,000 --> 00:12:39,000
So yes, this was it for my side.

265
00:12:39,000 --> 00:12:45,000
So let me quickly go ahead and close this particular connection so that, you know, I will be able

266
00:12:45,000 --> 00:12:46,000
to open some more things.

267
00:12:46,000 --> 00:12:47,000
Okay.

268
00:12:47,000 --> 00:12:52,000
And now in my next video I'll be discussing about more amazing things, uh, with respect to developing

269
00:12:52,000 --> 00:12:53,000
generative AI application.

270
00:12:53,000 --> 00:12:55,000
But yes, this was it from my side.

271
00:12:55,000 --> 00:12:56,000
I will see you in the next video.

272
00:12:56,000 --> 00:12:56,000
Thank you.

