WEBVTT

00:01.400 --> 00:05.420
Let's now review the react prompt engineering technique.

00:05.600 --> 00:11.750
Like most of the prompt engineering techniques, it came from a research paper that you can see right

00:11.750 --> 00:12.290
now.

00:12.320 --> 00:18.320
Now react is basically based on reasoning and acting reasoning enacting.

00:18.320 --> 00:20.810
And this is where the name comes from.

00:20.810 --> 00:24.920
One part is reasoning the re and the act is for acting.

00:25.670 --> 00:28.220
So how does it relate to us humans?

00:28.670 --> 00:35.390
It is very natural for humans when we have a complex task, is to reason and think about the steps we

00:35.390 --> 00:41.780
need to do in order to accomplish this task, perform these steps, and then move on to the next step.

00:41.810 --> 00:44.570
So we break it down to multiple steps.

00:44.570 --> 00:45.800
We reason it down.

00:45.800 --> 00:47.510
We act upon those steps.

00:47.510 --> 00:52.070
And then after we complete everything, we can complete the entire task.

00:52.820 --> 01:00.770
So what those researchers found out is that if we take the chain of thoughts and we combine it with

01:00.770 --> 01:07.810
the ability to perform those actions and get, for example, information from external sources.

01:08.170 --> 01:13.090
The LM model can generate its task that it needs to do.

01:13.120 --> 01:19.690
This is the reason part, and we saw it earlier in the chain of thought that it is capable of doing

01:19.690 --> 01:20.230
that.

01:20.230 --> 01:28.810
And if it's able to perform and execute those tasks in overall, they will be able to resolve the entire

01:28.810 --> 01:29.710
task.

01:29.950 --> 01:36.190
So here we are combining the ability of the LM to generate its own task, the reasoning to track it

01:36.190 --> 01:43.210
and to update the plan accordingly, and to also execute those steps to get additional information from

01:43.210 --> 01:44.320
external sources.

01:44.350 --> 01:48.430
So, so this is found out as a very, very powerful technique.

01:49.330 --> 01:57.790
It is pretty much the basis for LM applications that are way more factual than ChatGPT and can use external

01:57.790 --> 01:59.350
APIs and tools.

01:59.560 --> 02:05.770
So this is pretty much what pioneered is something that is called link chain, which is a very popular

02:05.770 --> 02:09.370
framework for building LLM applications.

02:10.090 --> 02:17.170
So let's review and analyze this research paper that will demonstrate us the react paradigm.

02:17.200 --> 02:20.830
So we have here a prompt with a question.

02:20.830 --> 02:29.620
So aside from the Apple remote what other device can control the program of the Apple remote was originally

02:29.680 --> 02:31.930
intended to interact with.

02:33.880 --> 02:38.920
So here we can see that for the prompt above we got iPad which is not the true.

02:38.950 --> 02:45.400
This was the simple zero shot prompt, and with the chain of thought where we asked it to describe the

02:45.400 --> 02:53.350
way it was thinking, then the LLM responded us with some other outputs iPhone, iPad, iPod, etc.

02:53.440 --> 02:56.200
but it wasn't correct as well.

02:56.890 --> 03:02.920
So the last attempt was something which is called act only, and this is available only on Llms that

03:02.920 --> 03:05.140
can interact with the outside world.

03:05.140 --> 03:07.210
So there is the syntax of search.

03:07.210 --> 03:15.900
So basically right over here, um, the the prompt says to search for Apple remote and then to list

03:15.900 --> 03:16.980
its observations.

03:17.280 --> 03:23.700
So we can see over here the final result was yes, which is simply not the answer for the question.

03:23.700 --> 03:28.140
And basically all those three examples that we saw before are wrong.

03:28.860 --> 03:37.620
And we can see that when we had models that were based on the react paradigm, and the answer that we

03:37.620 --> 03:42.330
got from them was the correct answer, which is, by the way, the keyboard function keys.

03:42.720 --> 03:49.650
So let's now analyze what's happening with the reason and the acting of the LMS when it comes to react.

03:49.830 --> 03:57.840
Now with this particular problem, the LMS first comes up with a thought, a breakdown of what it needs

03:57.840 --> 03:58.500
to do.

03:58.530 --> 04:00.720
Like we simply know with the chain of thoughts.

04:00.720 --> 04:06.690
So the LMS says, okay, we need to search for the Apple remote and find what program it was originally

04:06.690 --> 04:08.160
designed to interact with.

04:08.880 --> 04:15.750
So it derived an act, something, something that it needs to do to access an external resource, which

04:15.780 --> 04:16.200
he received.

04:16.200 --> 04:18.480
The syntax of search for the Apple remote.

04:18.510 --> 04:24.300
Once he does that and searches for the Apple remote and gets information from it from outside sources,

04:24.300 --> 04:25.740
it makes an observation.

04:25.740 --> 04:32.070
And the observation was that according to the external source, then the Apple remote was originally

04:32.070 --> 04:34.830
designed to control the front row media center.

04:34.860 --> 04:39.660
Now this creates another thought to the LM model.

04:39.780 --> 04:44.790
This is similar to the chain of thoughts, but we can act upon those thoughts.

04:44.910 --> 04:51.090
The second one is that okay, now the LM knows that there is something to do with the front row media

04:51.120 --> 04:56.400
center, and that's why it's determining that the next act should be to search for something which is

04:56.400 --> 04:57.930
called the front row.

04:58.020 --> 04:59.070
For some reason.

04:59.070 --> 05:01.440
Now it observed that it didn't find anything.

05:01.440 --> 05:04.800
It did find something similar to front row software.

05:04.800 --> 05:09.450
So now it creates a new thought that it should examine the front row software.

05:09.450 --> 05:13.610
So the act deriving from it would be to search for the front row software.

05:13.640 --> 05:19.190
It makes one observation after upon the act and it not so it's not so relevant.

05:19.190 --> 05:25.820
But the final thought is what is bringing us closer to the answer, because the final thought is that

05:25.820 --> 05:32.060
the front row software is controlled by the Apple remote or the Apple key function keys.

05:32.060 --> 05:36.350
So this is from the external sources that we got on the previous step.

05:36.440 --> 05:41.450
So from this it understands that the answer is the keyboard function keys.

05:41.540 --> 05:47.180
So this is mind blowing because it is simulating the human thought.

05:47.180 --> 05:53.000
And if I needed to answer this question this is exactly what I would have done.

05:53.000 --> 05:55.910
So this is crazy crazy crazy.

05:55.910 --> 05:57.680
And this is super powerful.

05:58.850 --> 06:02.990
Now you might be thinking, whoa, this is some sort of magic.

06:02.990 --> 06:04.130
How does this happen?

06:04.130 --> 06:07.430
I mean, I haven't really told you what's what's happening behind the scenes.

06:07.460 --> 06:09.620
I mean, how how does this even work?

06:09.650 --> 06:17.280
So basically, what's happening is simply integrating some kind of code with the chain of thoughts we

06:17.280 --> 06:24.150
saw earlier, that the chain of thoughts can create thoughts and can create steps, and the LM is totally

06:24.150 --> 06:26.220
capable of generating those steps.

06:26.220 --> 06:30.300
The next thing to do is to simply act upon those steps.

06:30.300 --> 06:32.430
So this can be done by code.

06:32.520 --> 06:39.210
And it's not even that hard as you may think, because doing so only involves taking the output step,

06:39.480 --> 06:45.000
which describes what we need to do, and looking up for keywords like search and finding the topic.

06:45.030 --> 06:47.100
So this can be easily done by code.

06:47.130 --> 06:55.710
And then to rerun the prompt with the observations that we got and do it over and over until we get

06:55.710 --> 06:56.670
the solution.

06:56.670 --> 06:58.890
So this is pretty much mind blowing.

06:58.890 --> 07:07.020
And this is exactly the basis for something which is called the link chain, which is the most popular

07:07.020 --> 07:14.270
framework right now to implement LM applications which can handle and do complex stuff like interacting

07:14.270 --> 07:18.410
with external sources, persisting data, and a lot more.
