A motion.
Prompting is one of my favorite techniques because it's quite fun and easy and it just works.
Quite often it's only a small percentage increase, typically in accuracy, maybe around 10% 5 to 10%.
But it's very easy to implement.
And what we're talking about when we talk about emotion prompting is specifically this paper.
Large language models understanding can be enhanced by emotional stimuli.
So the trick is essentially use things from psychology that motivate people emotionally and apply them
to llms.
And the reason this works is because they've learned from the internet that when someone puts this is
very important to my career in a message, then the response that follows is slightly more diligent,
right?
Like it is, people actually do pay attention to emotional cues and in terms of how important a task
is and then how much they should respond.
Another thing that falls in this bucket is when people put instructions in all caps locks, or they
threaten to kill a person if we don't have this response return in JSON.
Things like that.
That was a lot more common back in the day.
It's less needed now.
To be honest.
It's much better at instruction following, but it's still something that's worth testing.
Um, one of the really famous ones was developer used to put.
please output the full code because I don't have any fingers and and it did actually work in terms of
getting GPT four to output the full code.
So anyway, that's a really fun one for you to test, but I'm just going to give you a really simple
example here.
So we just have a get completion function.
Just returns the response.
And what we've asked for is a 2000 word detailed explanation of photosynthesis.
What you'll find quite often is that when you count the words.
So this is our evaluation metric.
Just splitting the text and then counting the length.
So that should give us a rough approximate approximation of the words, is that it doesn't get anywhere
near 2000 words.
Most LMS will only write about 1000 words, or just over a thousand.
And you can see that here.
We're only getting 700 words on photosynthesis, But our emotion prompt is working.
It is actually much better.
It's 1069 words and this is non-deterministic.
So if you run this again you're going to get a different result.
But we want to see on average does the emotion prompt improve performance.
And there's two things by the way that make this an emotion prompt.
One is that it's all in caps locks, this kind of interpreted or it's interpreted as a shouting in,
in text, like on the internet, if you put something in all caps.
And then we've also said all someone dies.
So here we go, 739 words.
And let's see if the emotion prompt does better.
Yeah.
So it does better.
Again 949 words.
All right.
This isn't a real test though.
We want to run this multiple times.
Quite often I will do something like this where we set the runs to 30.
And then we'll test the standard prompt 30 times.
So you're going to test the emotion prompt 30 times and then average the results.
And the reason why you do this asynchronous is that it would take a really long time to do one after
another, whereas this allows us to test all 30 at the same time.
And they all come back roughly at the same time as well.
So it's much quicker.
I'm just going to hit this and run, and Asyncio will handle the async part for us, which is nice,
and we're going to get this nice average word count at the end for this standard prompt and for the
emotion prompt.
So this is just running.
It should take about half a minute something like that.
Okay.
So that took a little bit longer than expected.
It's being slow today I guess at one minute 40s.
But we can see that over the 30 runs we are getting 12% improvement in length just by adding this one
little threat to the end here or someone dies.
So that is emotion prompting.
It's really easy to implement.
You can test different threats if you'd like to, but essentially it's the same thing when you are looking
for a small boost.
You can sometimes get it from putting a bit of human emotion or motivation into the prompt.