Okay.
Next up let's work on the prompts.
So we're going to improve the system message.
And let me read you what we've got.
And note again I'm using this trick of just using a global variable.
So it's automatically going to apply everywhere earlier.
So system message you're a helpful assistant in a clothes store.
You should try to gently encourage the customer to try items that are on sale.
Hats are 60% off and most other items are 60% or 50% off.
For example, if the customer says, I'm looking to buy a hat, you could reply with something like
wonderful!
We have lots of hats, including several that are part of our sales event.
Encourage the customer to buy hats if they're unsure what to get.
Okay, so there's a lot of things going on in that system prompt.
We're giving it information.
We're setting the context.
We're also giving it a tone.
And this approach is saying if the customer says then you should reply that's giving like an example
question answer.
And that would be what we would call one shot prompting, giving it one question and answer that it
should be able to replicate.
And we mentioned that before, I think.
So with that new system message, I can just relaunch the chat and I can say hi there.
And of course it has the context.
Welcome to the store.
How can I assist you today.
Are you looking for anything special by the way?
These models are super eager to to to give you their information.
We have an amazing sale going on with most items at 50% off.
Our hats are incredible, 60% off.
I'm not sure what to get.
Maybe a shirt.
Uh.
Great choice.
We have fantastic selection of shirts.
Most of them are currently 50% off during our sale, but if you're open to it, I recommend checking
out our hats.
So it's doing what we asked for.
It's encouraging the hats.
Uh, and you can see that it's that it's very it's persistent and it's reflecting the information we
gave it and also the tone.
All right.
Let's keep going.
We're going to add to the system message some more information If the customer asks for shoes, you
should respond that shoes are not on sale today, but remind the customer to look for hats.
Okay.
Uh, so this this, uh, because it's giving more examples.
This is the beginning of what you might call multi-shot prompting, because we're starting to give it
different examples of how it should handle different situations.
So I could say, hi there and welcome to the store, a fantastic sales event including hats.
Uh, I'd like to buy some shoes.
Right.
Some shoes.
Uh, we don't have shoes on sale today, but I encourage you to look at our amazing collection of hats.
There we go.
All right, we get the message.
Thank you.
All right, let's do one little bit more.
So you can also dynamically change the system prompt depending on what's happening in the conversation.
Uh, you can probably imagine this.
This might be a bit of an aha moment, but look, this is super hacky and you wouldn't do something
like this in real life.
It's it's is to show the point.
And this is a doorway.
This is a path to many bigger things we'll be doing soon.
But look at this.
Look at what I'm going to do here.
I'm taking a new system message called Relevant system message.
If the word belt appears in the message that the user is making, then I'm going to change the system
message to add in this this extra bit of information.
The store does not sell belts.
If you are asked for belts, be sure to point out other items on sale.
Uh, so that only goes in if they ask for belt.
Now.
Obviously, as I said, this is a silly example because it's only a little bit of text.
You might as well always put it in, but I want to highlight the point, so I put that in there.
Otherwise this is exactly the same.
Oh look I see I'm missing that, that that cleanup thing which if you're on Gemini that would annoy
you.
So let's just go and add that in right here.
Uh, this little line here that that scrubs the history.
We should have that as well.
It's good for you to see me doing this.
Just put it right up at the top there like that.
Okay, so now let's run this.
And now we will do this again.
And we will say hi there.
Okay.
And it says welcome to our store.
How can I assist you a fantastic sale especially hats.
Are you looking for anything special.
So I'll say uh, how are your shoes?
Are shoes are great quality.
Very comfortable.
I should mention not on sale today, but if you're interested, we have a great selection of hats.
Stylish hats.
Perfect addition to your wardrobe.
Actually, I think I want a belt.
We actually don't carry belts in our store.
But I'd love to help you find something else you might like.
Fantastic sale going on and hats are incredible.
60% off.
All right, all right.
It got the message.
And so you can see, of course, the what happened here is that because I had the word belt in my my
message.
The system prompt had this inserted in there, this extra piece of information.
So, so really that's that's a wrap on the lab.
And I just want to, to just press home how important what we just did was this, this last little step
of adding in a bit of extra context, if we needed to, to to equip the model with more information.
This is your first glimpse into the world of rag.
Rag which?
Which people?
It sounds like it's something so sophisticated.
It's not anything much more than just saying, let's try and figure out a smart way to shove relevant
information into the prompt, into the system prompt, which is going to equip our model to give better
answers.
And all of the trickery and Rag is about figuring out how can you do something a little bit better than
something janky like this?
If belt is, if the text belt is somehow in the user's question, obviously that's going to be very
hacky and sometimes it will work.
But if the user doesn't use the word belt, but says something else.
Then it's just not going to work.
And it relied on me turning it to lowercase.
And so, you know, there's so much about this that's hokey, and rag is about doing something a bit
more bulletproof and smart to select relevant context.
And you might say, why not just always put this in the system prompt?
You could do.
But if this was a store which had a thousand different products, then your prompt would become bigger
and bigger and bigger.
With all of this information and the model's accuracy would start to degrade and you'd be spending extra
tokens and it wouldn't be worth it.
So this idea of selecting relevant context and adding it to the prompt a powerful technique.
It is an inference time technique.
It's got nothing to do with training the model.
We're using the same model.
We're finding clever ways to insert relevant information into the prompt to to educate the model, to
give it expertise so it can answer questions accurately.
Taking advantage of the fact, in this case, that the store doesn't sell any belts.
And it brings me to the final point, which is the business applications of this are never ending.
Conversational agents, conversational assistants, of course, super popular use case and the frontier
models are so good out of the box at giving good answers, and the way that you can add value for your
business is by adding expertise into the prompts.
Of course.
So, you know, that's how this becomes something better than salespeople.
Just go to ChatGPT because you're able to add things, add content into the prompting to make it applicable
to your business, and so that that is the to do for you.
Figure out how could you build something, use this for your business or for your your home work or
whatever, but it should be super easy to knock up a demo of having something which is answering questions,
maybe doing a sidekick for some work that you do have something which which takes information in and
is able to give expertise and be applied, applied specifically to your business area, to your business
problems, with expertise in the prompt and a lot of what we're going to be doing over the course of
the next eight weeks is about figuring out how can we, in an automatic way, improve these prompts
to to educate our model better and better about our business and our situation?
These are all the inference time techniques that allow you to get more from a model.
But you've got enough right now to be building something.
And so you should you should build something.
You should put it in community contributions.
You should share it.
You also know now that in Gradio you can just put share equals true and other people can use it.
You can use auth equals to add in some user ID and password should you wish.
Uh and you should not only should you, you must go and do this.
I insist and share it.
Post it on LinkedIn so I can weigh in and I'll have a play with it as well, which I always enjoy.
And I can't wait to see what you build.
And I'll see you for the wrap up.
And so that's it for week two, day three.
And I would describe week two, day three as short and sweet.
It was it was quite short and it was very sweet.
At least I thought so.
So you have reached the 20% point and hopefully you feel like a bit About 20%.
You feel like you've got.
You've got some material under your belt.
Talking about belts.
Uh, so, you know, you've got some skills, you know, the foundations of the sort of transformer
space.
Talk about tokens and contacts, windows and all that kind of stuff.
Uh, you you can code with the chat completions API with frontier models.
You know them well, and you can build now an AI chatbot assistant with an interactive UI.
You can even share it and give it security, uh, at least basically, uh, and you also know how to
deal with things like multi-shot prompting to give it examples and you know how to to mess around with
the system prompt, adding in information as relevant to try and give it expertise.
Wow.
It's a lot.
But next time, next time we get to tools and tools is such a big deal.
And of course, particularly for for Agentic AI, uh, it's going to be your first first look at using
tools.
Super exciting.
See you tomorrow.