1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:05,000
So we are going to continue our discussion with respect to graph database with Liang Chen.

3
00:00:05,000 --> 00:00:11,000
Already in our previous video, we saw that how we can quickly generate a simple Q&A, uh, where we

4
00:00:11,000 --> 00:00:14,000
are specifically chatting with the graph database itself.

5
00:00:15,000 --> 00:00:17,000
Here, the concept was very simple.

6
00:00:17,000 --> 00:00:25,000
With the help of LMS, we were creating our entire queries, right Cypher queries, and based on that,

7
00:00:25,000 --> 00:00:29,000
we were executing it and we were retrieving the results from the graph database.

8
00:00:29,000 --> 00:00:36,000
But understand, uh, there may be scenarios where, uh, the LM may not perform well, you know, with

9
00:00:36,000 --> 00:00:40,000
respect to different, different complex kind of queries.

10
00:00:40,000 --> 00:00:48,000
So it is better that, uh, we try to improve this graph database query generation mechanism.

11
00:00:48,000 --> 00:00:48,000
Right.

12
00:00:48,000 --> 00:00:54,000
Now here, uh, what we will be doing is that we will go with some prompting strategies, you know,

13
00:00:54,000 --> 00:00:58,000
uh, which will try to improve the graph database query generation.

14
00:00:58,000 --> 00:01:05,000
So we will largely focus on methods for getting relevant database specific information in your prompt.

15
00:01:05,000 --> 00:01:05,000
Okay.

16
00:01:05,000 --> 00:01:10,000
So for that, uh, I will just go ahead and quickly, let's say that I will go ahead and create one

17
00:01:10,000 --> 00:01:11,000
more file.

18
00:01:11,000 --> 00:01:16,000
And here I will just go ahead and write prompt strategies right Ipynb file.

19
00:01:17,000 --> 00:01:20,000
So here we are going to specifically go over here.

20
00:01:20,000 --> 00:01:23,000
Let me go ahead and select my kernel okay.

21
00:01:23,000 --> 00:01:27,000
Now as usual uh this will be very much common.

22
00:01:27,000 --> 00:01:31,000
So here I'm going to use the same import OS.

23
00:01:31,000 --> 00:01:33,000
I will copy and paste it over here.

24
00:01:33,000 --> 00:01:36,000
I could had probably done in the same notebook.

25
00:01:36,000 --> 00:01:39,000
But let's go and do this.

26
00:01:39,000 --> 00:01:41,000
So let's delete this.

27
00:01:41,000 --> 00:01:42,000
Let's create a code over here.

28
00:01:42,000 --> 00:01:44,000
Let's paste it.

29
00:01:44,000 --> 00:01:45,000
And again I'll paste this one.

30
00:01:45,000 --> 00:01:52,000
And similarly I will go ahead and set up my environment right over here right now.

31
00:01:52,000 --> 00:01:59,000
The next step uh quickly what we are basically going to do again you remember this is the graph queries.

32
00:01:59,000 --> 00:02:04,000
Uh, if you probably see we have already uploaded this entire graph.

33
00:02:04,000 --> 00:02:05,000
Right.

34
00:02:05,000 --> 00:02:08,000
Uh, just by executing this graph dot query.

35
00:02:08,000 --> 00:02:11,000
So we know that this data is already present.

36
00:02:11,000 --> 00:02:11,000
Okay.

37
00:02:11,000 --> 00:02:19,000
Now, uh, what we are going to do over here is that we are going to develop some prompting strategies.

38
00:02:19,000 --> 00:02:22,000
Now, before that, I go ahead and develop this prompting strategies.

39
00:02:22,000 --> 00:02:26,000
Let's go ahead and quickly include all the LM models that we have.

40
00:02:26,000 --> 00:02:32,000
So here are this line of code that I'm just going to copy it and paste it over here so that I will be

41
00:02:32,000 --> 00:02:34,000
able to access my LM models.

42
00:02:34,000 --> 00:02:35,000
Right.

43
00:02:35,000 --> 00:02:37,000
So let's quickly do this okay.

44
00:02:37,000 --> 00:02:41,000
So I have my LM model I'll go ahead and execute this okay.

45
00:02:41,000 --> 00:02:44,000
This we really need to go ahead and do it okay.

46
00:02:45,000 --> 00:02:53,000
Now uh, you will be seeing that uh, we will try to, you know, use some kind of prompting strategies.

47
00:02:53,000 --> 00:02:57,000
Now, what are the kind of prompting strategies that we are going to use?

48
00:02:57,000 --> 00:02:58,000
We'll just have a go.

49
00:02:58,000 --> 00:02:59,000
Go ahead and have a look.

50
00:02:59,000 --> 00:02:59,000
Okay.

51
00:03:00,000 --> 00:03:01,000
Now, uh, let me do one thing.

52
00:03:01,000 --> 00:03:04,000
Let me also use this cipher key chain.

53
00:03:04,000 --> 00:03:04,000
Okay.

54
00:03:04,000 --> 00:03:08,000
So I will use this control C control v okay.

55
00:03:08,000 --> 00:03:11,000
And here I'm just going to create this specific chain.

56
00:03:11,000 --> 00:03:17,000
Let's go ahead and create this uh generate cipher QA chain.

57
00:03:17,000 --> 00:03:22,000
Uh sorry generate cipher Q and chain from underscore lm okay.

58
00:03:23,000 --> 00:03:26,000
And here, uh, the first parameter is nothing but graph.

59
00:03:26,000 --> 00:03:27,000
I will be using the same graph.

60
00:03:28,000 --> 00:03:31,000
Um, see, I, I also have.

61
00:03:31,000 --> 00:03:35,000
So here I'll also be giving my which lm model I'm actually going to use.

62
00:03:36,000 --> 00:03:40,000
Uh this also has a parameter which is called uh which is called as exclude types.

63
00:03:40,000 --> 00:03:46,000
Let's say you want to specifically exclude a kind of field and do not want to search based on that.

64
00:03:46,000 --> 00:03:48,000
Let's say I'm going to use genre, right.

65
00:03:48,000 --> 00:03:54,000
So I'll be using this and I'm telling basically do the all the searches by excluding this particular

66
00:03:54,000 --> 00:03:55,000
field.

67
00:03:55,000 --> 00:03:57,000
And I'll keep the verbose is equal to true okay.

68
00:03:57,000 --> 00:04:00,000
So once I go ahead and execute this will basically be my chain.

69
00:04:01,000 --> 00:04:06,000
So graph is not defined because I have not created the graph obviously for good.

70
00:04:06,000 --> 00:04:11,000
So good reasons because I have not uh, inserted any data.

71
00:04:11,000 --> 00:04:11,000
Right.

72
00:04:11,000 --> 00:04:14,000
So I will try to just insert this entire data itself.

73
00:04:14,000 --> 00:04:14,000
Right.

74
00:04:14,000 --> 00:04:18,000
So here, uh, again, we will go ahead and use the graph.

75
00:04:18,000 --> 00:04:19,000
Okay.

76
00:04:19,000 --> 00:04:20,000
Perfect.

77
00:04:20,000 --> 00:04:21,000
Over here.

78
00:04:21,000 --> 00:04:27,000
And again if we just go ahead and write graph dot query with movie query we will be able to insert the

79
00:04:27,000 --> 00:04:27,000
elements.

80
00:04:27,000 --> 00:04:30,000
But it is just going to probably okay.

81
00:04:30,000 --> 00:04:33,000
I have to also initialize this graph right.

82
00:04:33,000 --> 00:04:39,000
So if you remember where is the graph graph graph graph graph graph dot query.

83
00:04:39,000 --> 00:04:42,000
So graph should be on the top.

84
00:04:42,000 --> 00:04:44,000
Here is my graph okay.

85
00:04:44,000 --> 00:04:50,000
So I will just go ahead and quickly initialize this so that it will be able to communicate with the

86
00:04:50,000 --> 00:04:51,000
database okay.

87
00:04:51,000 --> 00:04:52,000
So this is my graph.

88
00:04:52,000 --> 00:04:53,000
I'm just trying to connect it.

89
00:04:53,000 --> 00:04:56,000
And then we will go ahead and execute this movie's query.

90
00:04:56,000 --> 00:04:58,000
It is just trying to insert again Okay.

91
00:04:58,000 --> 00:05:01,000
You can probably go ahead and see this right.

92
00:05:01,000 --> 00:05:02,000
All the steps are same.

93
00:05:02,000 --> 00:05:04,000
Nothing is different.

94
00:05:04,000 --> 00:05:07,000
We are doing the same thing over here with respect to this okay.

95
00:05:07,000 --> 00:05:08,000
Perfect.

96
00:05:09,000 --> 00:05:11,000
Now let's execute this.

97
00:05:11,000 --> 00:05:13,000
So this is my graph Cypher key chain.

98
00:05:13,000 --> 00:05:16,000
And I have all these things right.

99
00:05:16,000 --> 00:05:20,000
You can also go ahead and see the entire chain dot schema okay.

100
00:05:20,000 --> 00:05:22,000
If you want if you are interested.

101
00:05:22,000 --> 00:05:26,000
And you'll be able to see, hey, what kind of schema it is basically holding.

102
00:05:26,000 --> 00:05:26,000
Right.

103
00:05:26,000 --> 00:05:32,000
And uh, if you want the entire graph schema that also you will be able to execute, execute it.

104
00:05:32,000 --> 00:05:37,000
So here you can see node properties are the following um CEO this this this are there.

105
00:05:37,000 --> 00:05:43,000
And what all nodes like what all relationships everything will be able to see it over here okay.

106
00:05:43,000 --> 00:05:47,000
Now let's include some of the natural language questions.

107
00:05:47,000 --> 00:05:51,000
and we'll try to convert that into a valid Cypher queries.

108
00:05:51,000 --> 00:05:51,000
Okay.

109
00:05:51,000 --> 00:05:56,000
So obviously with respect to prompting strategies we'll give some of the examples.

110
00:05:56,000 --> 00:05:58,000
Now let's take this some of the examples.

111
00:05:58,000 --> 00:06:01,000
Now this is a very big list okay.

112
00:06:01,000 --> 00:06:05,000
Let's say one of the question is like how many artists are there okay.

113
00:06:05,000 --> 00:06:12,000
So we are matching a with person acted in movie and we are returning this count distinct a when I say

114
00:06:12,000 --> 00:06:15,000
artist, I'm specifically talking about actors.

115
00:06:15,000 --> 00:06:19,000
Okay then which actors played in the movie casino?

116
00:06:19,000 --> 00:06:19,000
Right.

117
00:06:19,000 --> 00:06:21,000
So here you if you see.

118
00:06:21,000 --> 00:06:21,000
Right.

119
00:06:21,000 --> 00:06:28,000
Uh, if I just go ahead and probably in our previous one, if I just go ahead and ask the same question.

120
00:06:28,000 --> 00:06:29,000
Okay.

121
00:06:29,000 --> 00:06:31,000
I'll say the same question over here.

122
00:06:31,000 --> 00:06:33,000
How many artists are there?

123
00:06:33,000 --> 00:06:33,000
Okay.

124
00:06:33,000 --> 00:06:37,000
So here you'll be able to see what kind of answer we will be getting.

125
00:06:37,000 --> 00:06:43,000
So if I just go ahead and execute it here you can see match p person count P as artist.

126
00:06:43,000 --> 00:06:44,000
So 1240 artist.

127
00:06:44,000 --> 00:06:48,000
But when we talk about artist we are specifically talking about actors.

128
00:06:48,000 --> 00:06:48,000
Right.

129
00:06:48,000 --> 00:06:52,000
So here we are just seeing that hey which all person has acted in the movie.

130
00:06:52,000 --> 00:06:57,000
So whenever we try to give this kind of queries, obviously we are not going to get that exact answer.

131
00:06:57,000 --> 00:07:01,000
What we are looking at based on the natural language processing Text.

132
00:07:01,000 --> 00:07:01,000
Right.

133
00:07:01,000 --> 00:07:06,000
So here what we are going to do is that we are going to define some prompting strategies where I will

134
00:07:06,000 --> 00:07:08,000
be writing in the form of question and queries.

135
00:07:08,000 --> 00:07:10,000
So here you can see how many artists are there.

136
00:07:10,000 --> 00:07:11,000
This is the query.

137
00:07:11,000 --> 00:07:15,000
Then there is another question which says which act is played in the movie casino.

138
00:07:15,000 --> 00:07:15,000
Right.

139
00:07:15,000 --> 00:07:18,000
So we have matched that with movie title.

140
00:07:18,000 --> 00:07:21,000
Title is equal to casino acted in a return a dot name.

141
00:07:21,000 --> 00:07:27,000
So we are giving some examples over here with respect to different different questions and cypher queries.

142
00:07:27,000 --> 00:07:29,000
So how many movie has Tom Hanks acted in.

143
00:07:29,000 --> 00:07:35,000
So let's try to experiment with this also okay so this is one I'll copy this.

144
00:07:35,000 --> 00:07:39,000
We are just using the previous strategies over here directly by using the LM model.

145
00:07:39,000 --> 00:07:41,000
How we will be able to get the response.

146
00:07:41,000 --> 00:07:42,000
Let's see this okay.

147
00:07:42,000 --> 00:07:48,000
So if I just go ahead and execute it and let's see the response.

148
00:07:48,000 --> 00:07:50,000
So acted in movie it shows three.

149
00:07:50,000 --> 00:07:51,000
Right.

150
00:07:51,000 --> 00:07:54,000
And obviously the result may be right because the LM is able to understand.

151
00:07:54,000 --> 00:08:01,000
But by using this prompting strategies, the LM model will completely get an idea like whenever we are

152
00:08:01,000 --> 00:08:02,000
asking this kind of questions.

153
00:08:02,000 --> 00:08:03,000
Right?

154
00:08:03,000 --> 00:08:08,000
So here also it shows list all the genres of the movie Schindler's List, right.

155
00:08:08,000 --> 00:08:10,000
And here you have this entire query.

156
00:08:10,000 --> 00:08:12,000
Again you do not run.

157
00:08:12,000 --> 00:08:13,000
You do not understand.

158
00:08:13,000 --> 00:08:15,000
If you are not able to understand this particular query, it is fine.

159
00:08:15,000 --> 00:08:18,000
So you can at the end of the day, your model is generating.

160
00:08:18,000 --> 00:08:22,000
This is what we have actually created, uh, with respect to the sample queries.

161
00:08:22,000 --> 00:08:26,000
So you can go ahead and have a look with respect to all the other queries, which directors have made

162
00:08:26,000 --> 00:08:29,000
movies with at least three different actors name.

163
00:08:29,000 --> 00:08:30,000
Uh, John.

164
00:08:30,000 --> 00:08:30,000
Right.

165
00:08:30,000 --> 00:08:32,000
So this kind of queries are complex queries.

166
00:08:32,000 --> 00:08:37,000
So we are trying to match this director with this particular actor in this, and we are trying to match

167
00:08:37,000 --> 00:08:43,000
with the person where a dot name starts with John, with d count distinct as a John counts, where John

168
00:08:43,000 --> 00:08:45,000
counts is greater than or equal to three.

169
00:08:45,000 --> 00:08:45,000
Right.

170
00:08:45,000 --> 00:08:49,000
So this kind of complex queries, we are trying to just make a list of it, okay.

171
00:08:49,000 --> 00:08:53,000
That is the pure idea about it right by using this prompt strategies.

172
00:08:53,000 --> 00:08:56,000
So once we go ahead and execute it.

173
00:08:56,000 --> 00:08:58,000
So this has got executed.

174
00:08:58,000 --> 00:09:01,000
Now we are what we are going to do is that in long chain itself.

175
00:09:01,000 --> 00:09:09,000
So if I go ahead and write from long chain, long chain underscore core dot prompts.

176
00:09:09,000 --> 00:09:09,000
Right.

177
00:09:09,000 --> 00:09:15,000
I'm just going to import few short prompt template okay.

178
00:09:15,000 --> 00:09:20,000
And then we are just going to have this prompt template because I have to probably create my prompt

179
00:09:20,000 --> 00:09:21,000
template also.

180
00:09:21,000 --> 00:09:24,000
So here I will say hey this is my example prompt.

181
00:09:24,000 --> 00:09:27,000
And let's go ahead and define my prompt template.

182
00:09:27,000 --> 00:09:33,000
And here I'm just going to use dot from underscore templates.

183
00:09:33,000 --> 00:09:34,000
Okay.

184
00:09:34,000 --> 00:09:37,000
And here we are basically going to use this important things.

185
00:09:37,000 --> 00:09:40,000
One is user input okay.

186
00:09:40,000 --> 00:09:45,000
And then we are also going to have this entire question.

187
00:09:45,000 --> 00:09:46,000
Okay.

188
00:09:46,000 --> 00:09:52,000
And I'm going to say hey um by just giving this question I should be getting my Cypher query.

189
00:09:52,000 --> 00:09:56,000
And this we will give another input parameter, which is called as query.

190
00:09:56,000 --> 00:09:56,000
Okay.

191
00:09:57,000 --> 00:10:01,000
Now see this is fine right.

192
00:10:01,000 --> 00:10:04,000
You have an example prompt template is over there.

193
00:10:04,000 --> 00:10:07,000
Now why this few short prompt template will be useful.

194
00:10:07,000 --> 00:10:10,000
So now let me just go ahead and create my prompt.

195
00:10:10,000 --> 00:10:13,000
I will go ahead and use this few, uh, short prompt template.

196
00:10:13,000 --> 00:10:17,000
And inside this let me go ahead and give some examples.

197
00:10:17,000 --> 00:10:25,000
So here I will see saying hey examples is equal to example examples of let's say I will go ahead and

198
00:10:25,000 --> 00:10:27,000
take some five examples.

199
00:10:27,000 --> 00:10:28,000
The top five examples okay.

200
00:10:28,000 --> 00:10:33,000
From here not all, but I'll give some sample of five examples.

201
00:10:33,000 --> 00:10:37,000
Then I will say hey use this example prompt okay.

202
00:10:37,000 --> 00:10:40,000
And this will basically be my example prompt okay.

203
00:10:40,000 --> 00:10:46,000
So here what we are doing is that inside this prompt template from our prompt template I'm giving this

204
00:10:46,000 --> 00:10:48,000
user input questions over here.

205
00:10:48,000 --> 00:10:48,000
Right.

206
00:10:48,000 --> 00:10:52,000
So here you can see that I'm giving some examples over here.

207
00:10:52,000 --> 00:10:54,000
And I'm also providing this particular example prompt okay.

208
00:10:54,000 --> 00:10:56,000
Now see what will happen.

209
00:10:56,000 --> 00:10:59,000
It will you'll be able to understand I will create a prefix okay.

210
00:10:59,000 --> 00:11:05,000
The prefix will say what what the LM model has to do.

211
00:11:05,000 --> 00:11:10,000
So I'll say hey, you are a neo four J expert.

212
00:11:10,000 --> 00:11:23,000
Okay, then I'll say given an input question, create a syntax syntactically.

213
00:11:25,000 --> 00:11:26,000
Very accurate.

214
00:11:28,000 --> 00:11:32,000
Cypher query okay, so So I'm just going to write Cypher query.

215
00:11:32,000 --> 00:11:34,000
So once I probably create this.

216
00:11:34,000 --> 00:11:37,000
So this basically becomes my prefix right.

217
00:11:37,000 --> 00:11:43,000
And now here itself with respect to the suffix.

218
00:11:43,000 --> 00:11:46,000
So there is also one more parameter that we will be using.

219
00:11:46,000 --> 00:11:47,000
I will just provide this.

220
00:11:47,000 --> 00:11:49,000
Hey this is the user input.

221
00:11:49,000 --> 00:11:50,000
This is the question.

222
00:11:50,000 --> 00:11:52,000
This is Cypher query that we are getting right.

223
00:11:52,000 --> 00:11:55,000
This query needs to be supplied right.

224
00:11:55,000 --> 00:11:58,000
And with respect to this, you know that the input variables.

225
00:11:58,000 --> 00:12:00,000
What are the input variables I'm using over here?

226
00:12:00,000 --> 00:12:04,000
One I can definitely see something called as question okay.

227
00:12:04,000 --> 00:12:05,000
The question.

228
00:12:05,000 --> 00:12:09,000
And second we will also be giving schema.

229
00:12:09,000 --> 00:12:13,000
Now why do you think we have to give schema over here.

230
00:12:13,000 --> 00:12:15,000
Let's execute this okay.

231
00:12:15,000 --> 00:12:19,000
So let's make a new code cell and let's see the prompt.

232
00:12:19,000 --> 00:12:24,000
So now I will just go ahead and execute this.

233
00:12:24,000 --> 00:12:25,000
Let's see the prompt.

234
00:12:25,000 --> 00:12:28,000
So now with respect to the prompt you can see input variable.

235
00:12:28,000 --> 00:12:30,000
Is this how many artists are there.

236
00:12:30,000 --> 00:12:33,000
See this is the list of things it has made.

237
00:12:33,000 --> 00:12:35,000
So few shot template prompt template.

238
00:12:35,000 --> 00:12:38,000
When we give the specific examples you have considered that.

239
00:12:38,000 --> 00:12:39,000
How many examples is there?

240
00:12:39,000 --> 00:12:41,000
The top five examples, right?

241
00:12:42,000 --> 00:12:42,000
Right.

242
00:12:42,000 --> 00:12:45,000
Then prefix is basically added okay.

243
00:12:45,000 --> 00:12:47,000
And then suffix is also added.

244
00:12:47,000 --> 00:12:48,000
Right.

245
00:12:48,000 --> 00:12:56,000
So give you are a given an uh syntax I have to probably use the spelling correct syntax.

246
00:12:56,000 --> 00:12:59,000
Uh syntactically.

247
00:12:59,000 --> 00:13:00,000
Okay.

248
00:13:00,000 --> 00:13:00,000
Perfect.

249
00:13:01,000 --> 00:13:02,000
Very accurate Cypher query.

250
00:13:02,000 --> 00:13:04,000
So this is your prefix.

251
00:13:04,000 --> 00:13:06,000
Uh, this is your suffix.

252
00:13:06,000 --> 00:13:08,000
Suffix is also added.

253
00:13:08,000 --> 00:13:11,000
Uh, and here you can see that your question is going right.

254
00:13:11,000 --> 00:13:13,000
All the other information is specifically going.

255
00:13:13,000 --> 00:13:15,000
So this looks very good right.

256
00:13:15,000 --> 00:13:18,000
It's, it's it's perfect mostly.

257
00:13:18,000 --> 00:13:20,000
Now let me do this thing okay.

258
00:13:20,000 --> 00:13:23,000
I will just go ahead and ask this particular question.

259
00:13:23,000 --> 00:13:27,000
And here I'm giving some kind of schema okay.

260
00:13:27,000 --> 00:13:29,000
Schema like foo okay.

261
00:13:29,000 --> 00:13:32,000
Just take as an example here I'm actually going to give the schema.

262
00:13:32,000 --> 00:13:36,000
So it is first of all going to give me a error saying that key error questions okay.

263
00:13:36,000 --> 00:13:39,000
So questions is there a question is there.

264
00:13:39,000 --> 00:13:40,000
Let's see.

265
00:13:40,000 --> 00:13:41,000
Print format question.

266
00:13:41,000 --> 00:13:43,000
How many artists are there.

267
00:13:43,000 --> 00:13:43,000
Questions okay.

268
00:13:43,000 --> 00:13:45,000
This should be question okay.

269
00:13:45,000 --> 00:13:46,000
Perfect.

270
00:13:46,000 --> 00:13:48,000
Now let's execute this.

271
00:13:49,000 --> 00:13:52,000
So here you can see you are a new forge expert.

272
00:13:52,000 --> 00:13:53,000
These are my user inputs.

273
00:13:53,000 --> 00:13:55,000
Everything is visible over here.

274
00:13:55,000 --> 00:13:57,000
How many artists are there?

275
00:13:57,000 --> 00:14:00,000
And here you are specifically getting the Cypher query, right.

276
00:14:00,000 --> 00:14:04,000
So all this information, you are able to see it right.

277
00:14:04,000 --> 00:14:11,000
And through this, this is your entire information with respect to the, uh, things that we have given

278
00:14:11,000 --> 00:14:13,000
over here in a few shot prompt template.

279
00:14:13,000 --> 00:14:17,000
But now it's time that let's go ahead and execute this and see.

280
00:14:17,000 --> 00:14:23,000
And then you will be able to understand that how this will specifically work with graph Cypher.

281
00:14:23,000 --> 00:14:23,000
Shane.

282
00:14:23,000 --> 00:14:24,000
Okay.

283
00:14:24,000 --> 00:14:27,000
Now my LM model is obviously there.

284
00:14:27,000 --> 00:14:27,000
Right.

285
00:14:27,000 --> 00:14:29,000
So you have your LM model.

286
00:14:29,000 --> 00:14:31,000
So my LM model is nothing but this one.

287
00:14:32,000 --> 00:14:32,000
Let's see.

288
00:14:32,000 --> 00:14:33,000
Okay.

289
00:14:33,000 --> 00:14:35,000
Now at least we should be able to get a good accuracy.

290
00:14:35,000 --> 00:14:40,000
So this is my linear model okay I will go ahead and create my chain okay.

291
00:14:40,000 --> 00:14:43,000
Now chain will be nothing but graph Cypher key chain.

292
00:14:43,000 --> 00:14:46,000
Here I will say hey dot from underscore LMS.

293
00:14:46,000 --> 00:14:51,000
The reason why I'm initializing this because my prompt has been changed now.

294
00:14:51,000 --> 00:14:52,000
So I will go ahead and write.

295
00:14:52,000 --> 00:14:55,000
Graph is equal to graph LM is equal to lm.

296
00:14:55,000 --> 00:14:58,000
And now I'm going to use my cipher prompt.

297
00:14:58,000 --> 00:15:05,000
See before inside this chain when we created this chain we did not give any prompt.

298
00:15:05,000 --> 00:15:07,000
But now we have to give some cipher prompt.

299
00:15:07,000 --> 00:15:08,000
Now cipher prompt is nothing.

300
00:15:08,000 --> 00:15:12,000
But we will give this particular prompt, which is my few short prompt template.

301
00:15:12,000 --> 00:15:17,000
This just to give an LM some ideas about how kind of what kind of questions we are asking and what kind

302
00:15:17,000 --> 00:15:19,000
of cipher queries been generated.

303
00:15:19,000 --> 00:15:20,000
Okay.

304
00:15:20,000 --> 00:15:24,000
And then finally I will go ahead and write verbose is equal to true okay.

305
00:15:24,000 --> 00:15:25,000
So once I execute this.

306
00:15:25,000 --> 00:15:29,000
So once we have executed this chain we have our chain ready.

307
00:15:29,000 --> 00:15:34,000
Now we will just go ahead and take some of the examples okay.

308
00:15:34,000 --> 00:15:39,000
Let's say I'll go ahead and write list all the genres of the movie.

309
00:15:39,000 --> 00:15:39,000
So and so.

310
00:15:40,000 --> 00:15:42,000
And I've just taken the top five queries.

311
00:15:42,000 --> 00:15:46,000
You can take any number of queries in your few shot prompt template.

312
00:15:46,000 --> 00:15:46,000
Okay.

313
00:15:46,000 --> 00:15:56,000
So I'll just go ahead and write chain dot invoke give this entire statement and it says uh of M this

314
00:15:56,000 --> 00:15:57,000
match is not happening.

315
00:15:57,000 --> 00:16:01,000
Let's see why this match is not happening.

316
00:16:01,000 --> 00:16:04,000
Okay, I will execute this.

317
00:16:05,000 --> 00:16:06,000
Okay.

318
00:16:06,000 --> 00:16:09,000
Signed Schindler's list.

319
00:16:09,000 --> 00:16:09,000
Okay.

320
00:16:09,000 --> 00:16:12,000
Schindler's List, if I remove this particular list.

321
00:16:16,000 --> 00:16:17,000
Okay.

322
00:16:17,000 --> 00:16:18,000
There is no matching records.

323
00:16:18,000 --> 00:16:18,000
Let's see.

324
00:16:18,000 --> 00:16:21,000
We are not able to get any information.

325
00:16:21,000 --> 00:16:24,000
Uh, but I will try like this.

326
00:16:24,000 --> 00:16:25,000
How many artists are there?

327
00:16:25,000 --> 00:16:27,000
Which actors played in the movie casino.

328
00:16:28,000 --> 00:16:35,000
Okay, let's try this one and we'll see whether we are able to get some kind of response or not.

329
00:16:36,000 --> 00:16:38,000
So here I'll go ahead and execute it.

330
00:16:39,000 --> 00:16:45,000
So here it shows Robert De Niro Joe Pesci this is coming as right.

331
00:16:45,000 --> 00:16:45,000
Okay.

332
00:16:45,000 --> 00:16:46,000
Let's see some more examples.

333
00:16:47,000 --> 00:16:52,000
Um, how many movies Tom Hanks acted in?

334
00:16:52,000 --> 00:16:53,000
Okay.

335
00:16:55,000 --> 00:17:01,000
So I will just go ahead and search for it and paste it over here.

336
00:17:01,000 --> 00:17:06,000
Chain dot invoke and I will write this particular query.

337
00:17:07,000 --> 00:17:10,000
So here you can see count is three.

338
00:17:10,000 --> 00:17:12,000
But I don't know the answer why Why.

339
00:17:13,000 --> 00:17:15,000
Oh return em.

340
00:17:15,000 --> 00:17:16,000
So count is three over here.

341
00:17:16,000 --> 00:17:19,000
This query is basically getting matched.

342
00:17:19,000 --> 00:17:21,000
Let's execute this one.

343
00:17:21,000 --> 00:17:24,000
Here you can see the count is three okay.

344
00:17:24,000 --> 00:17:31,000
But when we try to ask this in our prompt template what was the answer that we are getting.

345
00:17:31,000 --> 00:17:32,000
Okay.

346
00:17:32,000 --> 00:17:36,000
So here also the same type of query is generated okay.

347
00:17:36,000 --> 00:17:42,000
So let me go ahead and execute this uh match.

348
00:17:42,000 --> 00:17:42,000
Okay.

349
00:17:42,000 --> 00:17:43,000
This query is wrong.

350
00:17:43,000 --> 00:17:45,000
That is the problem.

351
00:17:45,000 --> 00:17:46,000
Right?

352
00:17:47,000 --> 00:17:49,000
Uh, this was the problem.

353
00:17:49,000 --> 00:17:51,000
So I'll go ahead and execute this.

354
00:17:51,000 --> 00:17:52,000
Uh.

355
00:17:52,000 --> 00:17:53,000
Remember this?

356
00:17:53,000 --> 00:17:54,000
Okay.

357
00:17:54,000 --> 00:17:57,000
This was the right thing, but you can see, right.

358
00:17:57,000 --> 00:18:00,000
It is been able to generate perfectly over here.

359
00:18:00,000 --> 00:18:02,000
So I will just remove this.

360
00:18:03,000 --> 00:18:03,000
Okay.

361
00:18:03,000 --> 00:18:06,000
Double double titles were used over here.

362
00:18:08,000 --> 00:18:09,000
I'll just go ahead and use this.

363
00:18:09,000 --> 00:18:09,000
Like this.

364
00:18:09,000 --> 00:18:10,000
Yeah.

365
00:18:10,000 --> 00:18:11,000
Perfect.

366
00:18:12,000 --> 00:18:14,000
But, uh, we need to think over this.

367
00:18:14,000 --> 00:18:15,000
Why?

368
00:18:15,000 --> 00:18:20,000
This had actually come as count of M is equal to three.

369
00:18:20,000 --> 00:18:20,000
Okay.

370
00:18:20,000 --> 00:18:24,000
How many movies acted in?

371
00:18:25,000 --> 00:18:27,000
Tell me the number.

372
00:18:27,000 --> 00:18:29,000
Okay, I'll just go ahead and execute this.

373
00:18:29,000 --> 00:18:30,000
Let's see.

374
00:18:30,000 --> 00:18:33,000
I don't know the answer, but it is able to provide the full context.

375
00:18:33,000 --> 00:18:33,000
Okay.

376
00:18:34,000 --> 00:18:37,000
We really need to see to this why these things are happening.

377
00:18:37,000 --> 00:18:40,000
Okay, but let's try to ask one more question.

378
00:18:40,000 --> 00:18:41,000
Um.

379
00:18:44,000 --> 00:18:50,000
Uh, provide, uh, tell about the actors or provide display the actors.

380
00:18:54,000 --> 00:18:58,000
Who acted in multiple movies?

381
00:18:59,000 --> 00:19:02,000
I think now it should be able to generate this.

382
00:19:04,000 --> 00:19:06,000
Okay.

383
00:19:06,000 --> 00:19:10,000
Where size current generated statement is not valid.

384
00:19:10,000 --> 00:19:11,000
Okay.

385
00:19:12,000 --> 00:19:14,000
Cipher.

386
00:19:14,000 --> 00:19:15,000
Let's see what query this is.

387
00:19:15,000 --> 00:19:20,000
Again these are the problems that usually happens right.

388
00:19:20,000 --> 00:19:29,000
And here you can actually see what all problems we are getting or size of this one where size of a.

389
00:19:31,000 --> 00:19:33,000
Pattern should only be used.

390
00:19:33,000 --> 00:19:35,000
So this is basically generated by the LM model.

391
00:19:35,000 --> 00:19:43,000
And this is one of the disadvantage that you can see display all the actors or I'll just say actors.

392
00:19:45,000 --> 00:19:54,000
And here it shows size of a, I don't know, actors who acted in multiple movies.

393
00:19:56,000 --> 00:19:58,000
I don't know why the size of A is basically taken.

394
00:19:58,000 --> 00:20:02,000
So these are the scenarios where your LM model can also go wrong.

395
00:20:02,000 --> 00:20:03,000
Okay.

396
00:20:03,000 --> 00:20:05,000
But no worries at all.

397
00:20:05,000 --> 00:20:10,000
Uh, because we also, uh, whenever we create some kind of applications, not everything is perfectly

398
00:20:10,000 --> 00:20:10,000
right.

399
00:20:10,000 --> 00:20:10,000
Right.

400
00:20:10,000 --> 00:20:14,000
So these are some of the examples that you can actually check it out.

401
00:20:14,000 --> 00:20:19,000
Uh, but yes, uh, I hope you got an idea with respect to the prompting strategies.

402
00:20:19,000 --> 00:20:21,000
Uh, but just go ahead and check it out.

403
00:20:21,000 --> 00:20:25,000
Uh, but I just want to keep this error like this so that you will be able to see it.

404
00:20:25,000 --> 00:20:25,000
Okay.

405
00:20:26,000 --> 00:20:26,000
So.

406
00:20:26,000 --> 00:20:28,000
Yes, uh, this was it for my side.

407
00:20:28,000 --> 00:20:29,000
I will see you all in the next video.

408
00:20:29,000 --> 00:20:29,000
Thank you.

