1
00:00:03,410 --> 00:00:06,470
Let's talk about models in land change.

2
00:00:06,470 --> 00:00:13,340
So when land change talks about models in the land change documentation, what are they talking about?

3
00:00:14,180 --> 00:00:20,990
They are talking about the foundational models upon which LM applications are built.

4
00:00:20,990 --> 00:00:30,860
So what we call foundation models, foundation LM models so long chain connects with two types of models.

5
00:00:30,860 --> 00:00:37,970
So in the long chain world a long chain connects with two kinds of models.

6
00:00:37,970 --> 00:00:45,200
First what they call LMS and second, what they call chat models.

7
00:00:46,100 --> 00:00:54,620
LMS for long chain are models that receive text and respond with text and chat models.

8
00:00:54,620 --> 00:01:02,120
For long chain a receive a chat message and respond with a chat message.

9
00:01:02,120 --> 00:01:12,950
So in the code on the right side of the screen, we are going to try an example a connecting long chain

10
00:01:12,950 --> 00:01:21,950
with the OpenAI LM model, and also connecting long chain with llama to an open source model.

11
00:01:22,550 --> 00:01:33,590
So the first thing we do, as always, is to, uh, connect with the env file in order to load the OpenAI

12
00:01:33,590 --> 00:01:34,190
key.

13
00:01:34,580 --> 00:01:44,870
And after that, what we do is we load the OpenAI module, we create an instance of our LM, and we

14
00:01:44,870 --> 00:01:52,220
just send any question to that instance, and we will have the response from a chat.

15
00:01:52,220 --> 00:01:57,710
GPT in this case we can do the same thing for llama too.

16
00:01:57,710 --> 00:02:01,040
In the case of llama too, we have two options.

17
00:02:01,040 --> 00:02:07,430
We can run llama to locally, or we can use llama to in the cloud.

18
00:02:08,270 --> 00:02:09,199
It's best.

19
00:02:09,199 --> 00:02:10,340
The second option.

20
00:02:10,340 --> 00:02:11,360
The first option.

21
00:02:11,360 --> 00:02:15,950
Here you have a link to do that using a llama I.

22
00:02:15,980 --> 00:02:22,490
But it's too complex and uh, I would not recommend recommend that way.

23
00:02:22,490 --> 00:02:26,570
Right now this is much easier and simpler.

24
00:02:26,570 --> 00:02:32,600
You know, just use an external API, uh, that you can do with replicate.

25
00:02:32,600 --> 00:02:38,870
And here we provide you a link where you can get your free, uh, API token.

26
00:02:39,050 --> 00:02:50,630
So once you have that, you load the replicate module, you, uh, create the, the LM, uh, llama

27
00:02:50,630 --> 00:02:58,880
to lm an instance of that llama to LM, and then you can use it in the same way we have been using the

28
00:02:58,880 --> 00:02:59,660
OpenAI.

29
00:02:59,660 --> 00:03:01,550
What is going to be the difference?

30
00:03:01,550 --> 00:03:06,680
The difference is going to be the quality of the response and the speed of the response.

31
00:03:06,680 --> 00:03:12,560
Llama two is a very good model in in some cases is similar in quality than OpenAI.

32
00:03:12,560 --> 00:03:16,040
In some other cases is a little bit lower in quality.

33
00:03:17,180 --> 00:03:18,740
Second case.

34
00:03:19,730 --> 00:03:20,930
We can use.

35
00:03:20,930 --> 00:03:33,920
Well, here you have a just a quick note saying that you can achieve this same functionality with two

36
00:03:33,920 --> 00:03:36,620
other alternative ways.

37
00:03:36,620 --> 00:03:44,660
First, we can use instead of using this my Elm question, we can use my LM dot predict question or

38
00:03:44,660 --> 00:03:46,340
dot invoke question.

39
00:03:46,340 --> 00:03:50,120
This is going to generate exactly the same output.

40
00:03:50,120 --> 00:03:53,870
These are different ways that long chain provide us.

41
00:03:56,400 --> 00:04:02,970
In order to connect with a chat model a see that we are loading here.

42
00:04:02,970 --> 00:04:10,800
The chat OpenAI module is not the OpenAI module, now is the chat OpenAI module.

43
00:04:10,800 --> 00:04:17,370
And we are also need to load human message and system message.

44
00:04:18,550 --> 00:04:22,240
In this case to create an instance of a.

45
00:04:22,900 --> 00:04:25,600
The OpenAI chat is very easy.

46
00:04:25,600 --> 00:04:30,580
And to create the content, the question is a little bit more elaborate than before.

47
00:04:30,580 --> 00:04:36,460
In this case, we have the option to tell a OpenAI the chat.

48
00:04:37,060 --> 00:04:43,960
We have the option to instruct about the role that he's going to play.

49
00:04:43,960 --> 00:04:51,790
In this case, we are using System message to tell ChatGPT you are a helpful and concise assistant.

50
00:04:52,390 --> 00:04:57,190
And here in Human Messages where we include our question.

51
00:04:57,190 --> 00:05:03,310
So in this case we say name the most popular for us first ladies.

52
00:05:03,520 --> 00:05:07,510
The way to get the response is very similar in this case.

53
00:05:07,510 --> 00:05:11,290
But you see that the response is printed in a different way.

54
00:05:11,290 --> 00:05:13,150
See the content here.

55
00:05:13,150 --> 00:05:13,840
Right.

56
00:05:14,080 --> 00:05:21,640
So if we print the type of the response it's very interesting because now we are getting a class.

57
00:05:21,640 --> 00:05:31,060
And before if you bring the type of the response that an LM is getting is is sending is a string, okay,

58
00:05:31,060 --> 00:05:31,990
this is important.

59
00:05:31,990 --> 00:05:42,730
And you will see then that in this uh, scenario is where we may think about using what we call output

60
00:05:42,730 --> 00:05:43,570
parsers.

61
00:05:43,570 --> 00:05:52,900
We will talk about them later, but in short, output parsers allow us to format the response we get

62
00:05:52,900 --> 00:05:56,320
from the LM model in a different way.

63
00:05:56,320 --> 00:06:02,260
We can say, okay, instead of strings, I want to have the output in a Json dictionary, or I want

64
00:06:02,260 --> 00:06:05,350
to have the output in Python list or whatever.

65
00:06:06,040 --> 00:06:07,150
So.

66
00:06:08,360 --> 00:06:13,910
This is how we connect with a chat model.

67
00:06:15,750 --> 00:06:25,800
And here you have a link to the LMS with native integration with a long chain, and also the chat models

68
00:06:25,800 --> 00:06:28,920
with native integration with long chain.

