-: The second principle to try is to specify the format.
Define what rules you want the AI to follow,
and set a required structure for the response.
All right, so we're gonna look at this
through a text models first,
and then we're gonna go onto images.
Looking for a list of 10 product names
for a pair of shoes that can fit any foot size.
And this works fine.
If you wanted to engineer the response
to make it more reliable at scale
if you're running this hundreds of thousands of times.
Like if you're making a product name generator
that people can use.
But then you want to put a little bit more work into it.
We've applied all the five principles to this prompt here.
And specifically we're gonna look at
how we specified format.
And so this is a product template if you wanna grab it.
But specifically in the format where we've said
what we want is this section here,
we said comma separated list.
And all of the examples also provide a comma separated list.
And we've also then told it we need three product names.
We don't want a big list of 10 things.
Now the reason why this is important is that the response
to a prompt isn't the end of the task typically.
It's usually just the input of the next step in the chain,
which could also be another prompt,
or it could be a human created task as well.
And what impact on the results does it have?
Depending on how you want the format,
you could have it as a numbered list.
This is if we change the prompt to have a numbered list,
it comes out like this.
But then if you're a developer
and you're working on a product, you typically want
the data to be structured in a way that you can pass it
and use it in the next step, like displayed in the UI.
So JSON is a very common mode,
and in fact is actually a mode you can use in the OpenAI API
and force it to return JSON.
And then there's also YAML,
which is more human readable,
a little bit easier to pass in some cases.
Whatever the data format you need, you can specify that.
And one of the main things you want to do
with prompt engineering is test different ways
to make sure it always comes back
with the required response format.
So let's look at this in image models,
'cause it's a little bit different.
We're gonna look at stable diffusion.
So this is prompting stable diffusion XL.
And we can see, you know, we have a shoe
that fits any foot size and that's fine.
But you can see one of the responses it came back
with was like a diagram.
We actually want product photography.
So how do we specify that?
With a bit of prompt engineering,
we have this prompt that is much more reliable
and giving the same format back every time.
And the part that where we specified format specifically,
is if we go past the template here
in section here of the prompt,
we have photography, extremely detailed,
studio lighting, 3.5 millimeter DSLR.
So this is a way for us to keep it very consistent.
If we append this on the end of every prompt,
then we're gonna get a pretty consistent
visual style every time.
We've defined what rules we would like to follow,
we've, you know, told it what sort of structure
of the response comes back.
And in image prompting you can get a little bit complicated
because sometimes the format also blurs into the style.
If you use product photography,
then that's gonna necessitate certain types of style.
And similarly, if you tell it you wanna style of a painting,
then it's gonna clash with product photography
and sometimes you get unreliable results.
So really a case of testing both the first principle
and the second principle together,
and see which combination works well.
Okay, let's look at the impact on results.
Product photography is not the only thing we could do here.
There's different types of product photography.
So in this case, if we made it more of a model shoot,
we wanted someone actually wearing it
and we could achieve that.
If we wanted street wear,
now that's a different vibe entirely,
and that you can see how it changes the style of the shoe
as well alongside the format.
So it takes some testing to get what
you want in terms of your vision.
And then the final one here is like Vogue Magazine.
You can see that we have the classic problem with AI
where she's got three legs. (laughs)
Again, with AI, you need to test,
you need to see how different changes to the prompt
come back in terms of reliability of the results.
And then also the quality of the image.
I think it's a very high quality image,
but it's obviously AI given that she has three legs.
Maybe that's part of the alien vibe, I'm not sure.
But whatever it is, getting the right format back
will help you achieve the final task.
Because if you're using these images for a magazine shoot,
or if you're using them on your website,
or if you're using on social media, you need to be able
to specify what type of format you're expecting.
Is it a model shoot?
Do you actually want someone wearing these shoes?
Or do you just want some product photography
of the shoes themselves?