00:00:00
prompting a model is basically all about
00:00:03
asking the question that you want the
00:00:06
model to answer simple enough right but
00:00:08
it's actually a lot more nuanced than
00:00:11
that there are a number of techniques
00:00:13
you can use to get the model to provide
00:00:16
the answer you actually want otherwise
00:00:19
you may get answers that are downright
00:00:22
frustrating all of these techniques
00:00:24
actually boil down to one main thing
00:00:27
that you need to remember the key to
00:00:29
getting the model to work for you is to
00:00:32
not assume that the model knows what
00:00:35
you're talking about you need to be
00:00:38
explicit about what you're looking for
00:00:40
and that usually means spelling out your
00:00:42
needs in more detail than you might
00:00:45
initially think so in this video in the
00:00:47
olama course we're going to look at the
00:00:50
most common prompting techniques that
00:00:52
you can use to help get better answers
00:00:54
from your models I'm Matt Williams and I
00:00:57
was a founding maintainer of the olama
00:01:00
project it was amazing being there at
00:01:02
the beginning but now I am focused on
00:01:04
building out this Channel and getting
00:01:06
all of you up to speed with all things
00:01:09
local AI you can find out more about
00:01:12
olama by visiting the ama.com
00:01:15
homepage clicking the big button in the
00:01:17
middle of the page and getting it
00:01:19
installed on your system if you need
00:01:21
help using olama look at the rest of the
00:01:23
videos in this free course okay let's
00:01:27
start with the simplest kind of prompt
00:01:29
the zero shot prompt this is what most
00:01:33
folks use all the time it's a simple
00:01:36
question this works well when the model
00:01:38
has been trained on the topic in the
00:01:41
question for instance my zero shot
00:01:43
prompt might be determine the sentiment
00:01:46
of the following text movies are
00:01:49
expensive this is a great starting point
00:01:51
but shows one of the problems that come
00:01:52
up with simple questions the model
00:01:55
couldn't read my mind so didn't know
00:01:58
that I wanted it to answer only with a
00:02:00
single word sentiment I can edit the
00:02:03
prompt to say what I actually want to
00:02:05
see and now run it again and it gives me
00:02:08
a good answer change the text and again
00:02:10
it answers correctly let's try one other
00:02:13
bit of text so these all worked great
00:02:16
and it was all just a matter of giving
00:02:17
the model just a little bit more detail
00:02:20
what kinds of details could you add well
00:02:24
there's lots of things one is the
00:02:26
Persona you want the model to emulate
00:02:29
tell the model
00:02:31
you're a surgeon or you're an
00:02:33
experienced YouTube SEO expert or you're
00:02:36
a lethargic idiot who sits on your butt
00:02:38
all the time uh well maybe not that last
00:02:41
one maybe that's just uh that old friend
00:02:44
from high school and not someone you
00:02:46
actually want to emulate there's also
00:02:48
the context to help the model know
00:02:50
exactly what you're talking about and
00:02:52
tone is the feeling you're going for in
00:02:55
the answer but sometimes a zero shot
00:02:58
prompt can't cover everything so a few
00:03:01
shot prompt can be useful the main idea
00:03:04
here is giving the model examples of how
00:03:06
to answer essentially you're training
00:03:08
the model to answer in a specific way
00:03:11
with a question and prepared answer or
00:03:13
answers there was a paper that discussed
00:03:16
this back in 2020 and it gave some
00:03:18
examples some strange examples the first
00:03:22
takes a sentence where there is
00:03:24
something wrong with the way it's said
00:03:26
and the model should simply correct it
00:03:29
it isn't in the form of a question so
00:03:30
the model should see the input sentence
00:03:32
of I'd be more than happy to work with
00:03:35
you in another project and correct it to
00:03:39
I'd be more than happy to work with you
00:03:41
on another project sometimes you don't
00:03:44
actually need multiple examples but can
00:03:46
instead use just a single example like
00:03:49
this one it defines a new word a watpo
00:03:52
and provides an example of how to use it
00:03:55
in a sentence and then it defines a far
00:03:58
duttle and expect another example
00:04:00
sentence which the model is able to do
00:04:03
you know what needs no definition or
00:04:06
example sentence liking and subscribing
00:04:09
you've heard it so often that's almost
00:04:10
cliche right but it really helps a
00:04:14
channel like mine so if you enjoy
00:04:16
content like this please like And
00:04:18
subscribe okay back to the prompts in
00:04:20
most cases coming up with a single
00:04:22
example is always easier than coming up
00:04:25
with many examples some will refer to
00:04:27
this as a single shot prompt but others
00:04:30
will call even a single example a few
00:04:32
shot prompt let's move on to the next
00:04:35
prompting technique Chain of Thought
00:04:37
which you might see as
00:04:40
Co the paper that talks about this is
00:04:42
from 2022 and one of the main examples
00:04:45
ask the model to figure out how many
00:04:47
apples a cafeteria has at the end of the
00:04:50
day to do this the model is asked to
00:04:53
think about the process to come up with
00:04:55
an answer step by step so here's the
00:04:58
prompt Roger has five tennis bowls he
00:05:00
buys two more cans of tennis bowls each
00:05:03
can has three tennis bowls how many
00:05:05
tennis balls does he have now and then
00:05:07
an example answer is given working
00:05:09
through the problem Roger starts with
00:05:11
five balls two cans of three tennis
00:05:14
balls each is six balls 5 + 6 = 11 the
00:05:18
answer is 11 and finally the actual
00:05:21
question is asked the cafeteria has 23
00:05:24
apples it used 20 to make lunch and
00:05:27
bought six more how many apples do they
00:05:29
have so the model will try to replicate
00:05:32
the example in the prompt in the paper
00:05:35
an answer is given of the cafeteria had
00:05:37
23 apples originally they used 20 to
00:05:40
make lunch so they had 23 - 20 equal 3
00:05:43
they bought six more apples so they have
00:05:45
3 + 6 = 9 the answer is 9 the paper
00:05:50
provides a few more examples of using
00:05:52
this style of prompt but then there was
00:05:54
another paper from that year that
00:05:56
suggested that just adding the phrase
00:05:58
let's think step by step step or some
00:06:00
variation of it might be just as
00:06:03
effective sometimes the problem is a bit
00:06:05
more complicated than what can be
00:06:07
described in Chain of Thought since we
00:06:10
saw that providing the instruction of
00:06:12
think step by step is sometimes just as
00:06:14
good we can also ask the model to think
00:06:17
of all the sub problems that must be
00:06:18
solved first before answering the
00:06:21
question then to think step byep through
00:06:24
each of the sub problems and finally to
00:06:26
use all of that to answer the original
00:06:28
question a paper in 2023 referred to
00:06:32
this as least to most prompting
00:06:35
sometimes this can be answered in a
00:06:36
single prompt and other times you may
00:06:38
have more success using a an agentic
00:06:41
approach of generating the sub problems
00:06:43
in one prompt than ask them the model
00:06:45
separately to solve the sub problems and
00:06:48
finally to use all the information to
00:06:50
come up with the final answer hopefully
00:06:53
as you've watched all the videos in this
00:06:54
course you'll have learned how models
00:06:56
work they simply predict the next most
00:06:59
statistically likely word to show up
00:07:02
given the context when you ask the same
00:07:05
question multiple times you're likely to
00:07:07
get a different answer each time so you
00:07:09
could try asking the model to give you a
00:07:12
few variations of the answer how many
00:07:15
variations well it might be hard for you
00:07:17
to process an infinite number but three
00:07:20
is a good set of answers to be able to
00:07:22
go through these are probably each of
00:07:24
the most fundamental prompt techniques
00:07:26
used today but there are many others
00:07:29
that are
00:07:30
variations and combinations of them
00:07:32
you'll hear names like meta prompting
00:07:34
sequential symbolic reasoning react and
00:07:37
others that take these core ideas and
00:07:41
and tweak them a bit definitely worth
00:07:43
looking into some articles about each to
00:07:46
give you inspiration on how to get
00:07:47
better answers from your models you
00:07:50
wouldn't be that far off if you realize
00:07:52
a lot of this is mostly just common
00:07:55
sense but it's often great to get
00:07:57
reminded of even the most obvious things
00:08:00
when working with
00:08:02
llms some folks like to call this prompt
00:08:05
engineering though I'm sure every
00:08:07
engineering school will think that it's
00:08:09
a disgusting title since the rigors of
00:08:11
engineering hardly apply Microsoft got
00:08:14
sued over the use of the title sales
00:08:17
Engineers but you can call it whatever
00:08:19
you like are there other techniques that
00:08:21
you like to use when working with
00:08:23
prompts share them in the comments below
00:08:25
thanks so much for watching goodbye