WEBVTT

1
00:00:00.330 --> 00:00:01.680
<v Maximilian>So we got a Modelfile.</v>

2
00:00:01.680 --> 00:00:05.490
How can we now build an actual model based on that file?

3
00:00:05.490 --> 00:00:09.690
Well, for that, Ollama gives us the create command,

4
00:00:09.690 --> 00:00:10.890
because, as we learned here,

5
00:00:10.890 --> 00:00:13.647
this creates a model from a Modelfile.

6
00:00:14.490 --> 00:00:16.680
Now, for that, you must make sure that,

7
00:00:16.680 --> 00:00:18.600
in your command line, in your terminal,

8
00:00:18.600 --> 00:00:21.840
you navigate into the folder where you got that Modelfile,

9
00:00:21.840 --> 00:00:24.150
which in my case is the case.

10
00:00:24.150 --> 00:00:26.910
And then you can run ollama create,

11
00:00:26.910 --> 00:00:31.200
then any name of your choice, like service-agent,

12
00:00:31.200 --> 00:00:32.940
but that is entirely up to you.

13
00:00:32.940 --> 00:00:36.120
That will be the name of the model you are creating.

14
00:00:36.120 --> 00:00:38.070
And then -f

15
00:00:38.070 --> 00:00:41.160
and then ./Modelfile.

16
00:00:41.160 --> 00:00:45.330
And here you simply specify the path to that Modelfile.

17
00:00:45.330 --> 00:00:47.820
And since here, for me, it sits in the same directory,

18
00:00:47.820 --> 00:00:49.290
it's a very simple path.

19
00:00:49.290 --> 00:00:51.060
If you had it in some other directory,

20
00:00:51.060 --> 00:00:53.580
you could specify the full absolute path

21
00:00:53.580 --> 00:00:55.053
to that Modelfile here.

22
00:00:56.580 --> 00:00:57.930
So now if you save that,

23
00:00:57.930 --> 00:01:01.317
it will build a new model based on that Modelfile.

24
00:01:02.571 --> 00:01:05.040
And therefore, if thereafter you run ollama list,

25
00:01:05.040 --> 00:01:07.293
you should see that model here.

26
00:01:08.550 --> 00:01:11.100
Now again, this size is kind of wrong

27
00:01:11.100 --> 00:01:14.070
because of course, this service-agent model,

28
00:01:14.070 --> 00:01:16.590
thanks to this command we just executed,

29
00:01:16.590 --> 00:01:18.480
is based on this Modelfile,

30
00:01:18.480 --> 00:01:20.970
which builds a model based on this Gemma model,

31
00:01:20.970 --> 00:01:24.450
and therefore Ollama will not technically copy that model,

32
00:01:24.450 --> 00:01:27.510
it will not copy the weights or parameters of that model,

33
00:01:27.510 --> 00:01:29.850
it will also not change them, by the way.

34
00:01:29.850 --> 00:01:31.710
Instead it will use that as a base

35
00:01:31.710 --> 00:01:35.580
and just adjust that metadata, so to say.

36
00:01:35.580 --> 00:01:38.640
So that these settings are always set

37
00:01:38.640 --> 00:01:41.340
when we now run our customized model.

38
00:01:41.340 --> 00:01:42.173
But under the hood,

39
00:01:42.173 --> 00:01:45.423
we're still using the unchanged Gemma 3 model.

40
00:01:46.770 --> 00:01:51.010
But of course therefore here I can ollama run service-agent

41
00:01:52.140 --> 00:01:56.073
like this and this will now load my own model.

42
00:01:57.150 --> 00:01:58.350
And here we also see

43
00:01:58.350 --> 00:02:01.920
that chat history we added to that model.

44
00:02:01.920 --> 00:02:04.410
And if I type /show system, I for example,

45
00:02:04.410 --> 00:02:06.210
also see that system message,

46
00:02:06.210 --> 00:02:08.277
which I added to that Modelfile.

47
00:02:09.180 --> 00:02:12.180
And that's therefore another maybe more convenient way

48
00:02:12.180 --> 00:02:16.410
of building customized models based on existing models,

49
00:02:16.410 --> 00:02:21.120
not by using /set and /save, which you can also do,

50
00:02:21.120 --> 00:02:22.770
which has the same effect,

51
00:02:22.770 --> 00:02:25.410
but instead by using such a Modelfile.

52
00:02:25.410 --> 00:02:28.230
And of course, the great thing about such a Modelfile

53
00:02:28.230 --> 00:02:30.540
is that you can also share it with other people.

54
00:02:30.540 --> 00:02:33.540
You can upload it to GitHub, share it through your website,

55
00:02:33.540 --> 00:02:35.520
and therefore allow other people

56
00:02:35.520 --> 00:02:37.470
that are also using Ollama

57
00:02:37.470 --> 00:02:41.910
to easily copy your customized model version.

58
00:02:41.910 --> 00:02:44.970
Now for completeness sake, I also wanna mention

59
00:02:44.970 --> 00:02:48.570
that when it comes to sharing customized versions of models,

60
00:02:48.570 --> 00:02:51.720
you can also use the ollama push command.

61
00:02:51.720 --> 00:02:54.990
And this pushes a model to a registry.

62
00:02:54.990 --> 00:02:58.560
A registry like the official Ollama models registry,

63
00:02:58.560 --> 00:03:00.270
for example.

64
00:03:00.270 --> 00:03:02.760
But that's not something I'll do in this course here,

65
00:03:02.760 --> 00:03:04.650
not something you have to do.

66
00:03:04.650 --> 00:03:05.640
As I just explained,

67
00:03:05.640 --> 00:03:08.220
if you wanna share a customized version of a model,

68
00:03:08.220 --> 00:03:10.440
you could also just share the Modelfile

69
00:03:10.440 --> 00:03:13.260
and have people create that model based on

70
00:03:13.260 --> 00:03:16.200
that Modelfile locally on their systems.

71
00:03:16.200 --> 00:03:18.900
But it's worth noting that ollama push exists

72
00:03:18.900 --> 00:03:20.880
and can therefore be an interesting way

73
00:03:20.880 --> 00:03:24.153
of sharing an adjusted model with other people.

