-: Hey, I'm gonna walk you through what evals.
So this is maybe something you've heard of.
Evals are short for evaluation metrics
and it's how we measure alignment
between what we get in terms of responses from the AI
and the business goals that we've been set.
So for example, the accuracy, the reliability,
or the quality of the responses.
This is an example of evals.
You might have seen this
whenever a new model is released.
This is the example from Claude 3.
They check how well it did
against generally accepted eval benchmarks.
MLU is one of them. GPQA, Diamond.
There's human eval, which is a coding eval benchmark.
And typically these are question
and answer sets as you get a percentage correct.
And if that percentage keeps going up,
then you're doing a good job.
And if that percentage is very high compared
to GPT-4 or some of the other models out there,
and then you've hit the holy grail
and people will start training your model,
trying to use your model.
So it's something that they focus on quite a bit.
And this is an example of what these evals look like.
This is an abstract algebra one.
You can see there's question, the statement there,
and then there's answer A, B, C, D.
And we just see how well the AI does
in terms of that question and answer.
So we know the answer to that question
and that the answer is B.
And if the AI predicts B, then gets it right.
Same, this was one for professional accounting.
It's asking a question and this answers A, B, C, D.
And the correct answer is A,
so we can tell whether the AI got it or not.
And the reason why evals are important
is they're surprisingly often all you need
as Greg Brockman from OpenAI says.
They're usually the most important part
of any prompt engineering project that I work.
Now, what makes them so hard
is that these tools are not reliable.
Like, they quite often fail
and you don't know that they're failing
unless you're running it at 10 or 100 or even 1,000 times.
And seeing how often it fails
and know what failure is really important
and you need to be able to capture that in your evals.
But the other big problem is cost and latency.
So if your evals are too expensive
or they're too slow to run
and it limits how many tests you can run.
If every time you test a new prompt, you have to send it
to your boss and they'll wait for them to come back
to you a week later, then you're not gonna be able
to iterate very fast.
The other big thing is hallucination.
It's pretty hard to fact check models
or fact check humans (indistinct).
And these models tend to make things up
or miss important things.
It's really hard to measure
because you very quickly run into the fact
that there's almost no objective truth in the world
unless the question is very simple.
Most tasks are not simple, particularly the ones
where evals matter the most.
There are three types of eval:
programmatic, synthetic and human eval.
Programmatic is the holy grail. It's the ideal one.
If you can quickly and cheaply calculate whether the answer
is correct, then you can move a lot faster
and you get answers within milliseconds.
A good example of this is checking AI answers
to multiple choice questions as we already saw.
It's fast and cheap
and the one weakness is that it's pretty hard to come up
with good programmatic measures that capture complex tasks.
Because we're limited here to multiple choice,
if it's a freeform answer, that's a lot harder to calculate.
In that manner, we tend to move towards synthetic evals.
Synthetic evals is just asking typically GPT-4,
or the best model is at the time,
whether a response is concise
or asking whether the response is correct
or checking some other action in the response.
That's something that GPT-4 is actually pretty good at,
particularly when you're measuring the responses
from lesser models or open source models.
It's cheaper and faster than using a human,
but the problem is that if AI is bad at the task,
then it's potentially also bad at checking the task.
It's also a lot costlier and slower than programmatic evals.
I have some synthetic evals that cost me a couple
of dollars every time I run them.
And while that's cheaper than paying a human to evaluate,
it takes a couple of minutes to run
and I find I get distracted and start checking my emails
and then I forget what I was doing.
So it's a bit of a productivity killer
if you have to wait a long time
and you could easily spend like $100 just testing.
Human evals is ideal.
That's an example of getting your boss to check the work
or getting an editor to add comments to a document
or even just you looking at like eyeballing the responses
like you would do in ChatGPT.
But this is a high likelihood of accuracy
or at least, you're likely to agree
with the results if you like the responses.
But the problem is it's weakest.
It's the weakest way to evaluate
because it's very expensive, it's slow, it takes a long time
to get people to give feedback.
They can also be pretty subjective as well.
Different people will evaluate the same response
in different ways.
So let's dive into each one a little bit deeper.
Programmatic evals.
The simplest one I really like is just word length.
Like when you're generating blog content,
one of the things I find
is that it doesn't generate long enough content.
So one of the things I test fairly often is like,
how do I get it to produce a longer piece of content?
And this is an example here from a Google Sheets test I did
where I just ran the prompt 10 times,
ran another prompt 10 times where I had,
I'll lose my job all in caps
if it doesn't make the blog post longer.
And that did actually improve the word length.
It was 13% higher.
The reason why this is good
is because it's simple to calculate.
You can do it, even in Excel
Q&A is the most obvious one.
So one that pretty much everyone does.
You generate some set of questions and answers
and you know what the answers should be,
therefore, you can check whether it actually follows suit.
So this is an example from a bank.
We have transaction descriptions
and we know what the transaction type
and transaction category should be for these descriptions
and we can check whether it actually categorizes them
into the right format.
So you can see on the example labeled four,
purchased books from the bookstore,
it labeled that as entertainment instead of other.
The other one is hallucinations.
And we came up with a relatively elegant way to test this.
One of my clients, we were building product descriptions
or product ads based on the copy that was on the website.
So what we did is we just built a function in Google Sheets
that would check the copy on the website
and divide up all the words.
So we'd just see what words were available on the website
and if any words were in the ad that weren't on the website,
then that was counted as a hallucination
so we could very quickly
and easily A/B test even in Google Sheets.
So the second one I wanna talk through a little bit
of detail is synthetic.
So I'm gonna show you some examples of this.
One is using a vector database,
and this is a lot faster actually than calling GpT-4,
but it can still be quite effective.
Embeddings that you get from a a vector search.
Basically how close things are in terms of similarity.
The lower the score, the better here.
And we're looking in this case
at how well it matches the way
that someone writes right in the certain style of an author.
And in this case, some of the techniques
were much better than others.
Another one that's really popular
for synthetic evals is pairwise comparison.
So you can pass it both of the responses.
In this case, this is the bank transaction example
that we gave before.
We know what the reference answer is, withdrawal other.
And we know that GPT-3.5 has come back
with withdrawal entertainment,
Mistral came back with withdrawal other.
We can pass all that information to an LLM
and ask it to give a verdict, as well as some reasoning.
And this is pretty good for fuzzier tasks
where there's not like a direct match necessarily,
or there might be one version that's better than another.
The other big one I use a lot
is I call it like violation finding.
You have a bunch of errors
that typically show up in the responses.
Like for example, if you're generating blog content
or creating a report
and if someone has to go edit that blog content,
a human has to go edit that blog content.
But you can take all of the edits that they typically find
as some of the problems that they see over and over again
and then turn those into rules that you check for.
So you can have one prompt for each type of violation.
Say, for example, it's using the wrong language
or it's not concise enough, whatever it is.
And then you can see
how many violations one report has versus another.
Human evals, most expensive one,
but also most effective if you have the time.
So one example from the image generation space,
I do a lot of cherry-picking.
Cherry-picking is basically just, yeah, running lots
of different types of things
and then choosing which ones turn out the best.
here's an example where I was making a sci-fi,
a story image catalog.
So basically creating images to go with the sci-fi story.
I was trying to figure out a good prompt
and I wanted some dystopian-looking stuff.
I went and downloaded some images
of people being welded into their houses
during the COVID-19 lockup
and a few other dystopian images like that.
And then I just used Midjourney Describe
to reverse engineer the prompt and looking at these prompts.
I could cherry pick my favorite examples
and say, okay, this looks really interesting.
I'm gonna use that scenario in this sci-fi story.
The other one I use a lot is just, I call it thumb ratings.
So thumbs up, thumbs down if the response is good.
This is an example from a marketing team.
If we're generating an email with an image,
a customer this image and some copy
and they can give it a quick thumbs up
or thumbs down as to whether it's approved or not.
We can use that approval rate across lots
of these images in order to tell whether it's good or bad.
And we could A/B test those prompts there.
Makes it a little bit easier for people,
like Tinder for ratings.
The final one is just manual review.
This is from a project I was working on
where we were analyzing video and using the GPT Vision API.
One of the things we found
is that quite often, we'd refuse the request
and we wouldn't have found this
unless we actually looked for it,
and dug into what was really coming back.
So we dumped all that into Google Sheets
and then we looked a little bit further into the detail
and we'd notice that quite often it would say
that it can't assist with these requests
in certain scenarios.
And we'd dig into what those scenarios were
and then we'd correct for them in the prompt.
Cool, that is how evals work
and it's a really deep field,
so it's not covering everything,
but at least you have a good understanding now
of what you need to be looking at,
what you need to be thinking about
and how to work through the problem
of evaluating your model output.