0:00Intro: MOFUSA Tech Academy
Welcome to MOFUSA Tech Academy. Beyond learning, towards mastery.
0:09Same meaning, different words: how do you score it?
Last episode, we measured how well a model predicts text. Now we score its answers. And for some tasks, there's a right answer we can check automatically. Code can be run against tests. An order number pulled out of an email is either exactly right or not. But for a sentence like "Your refund will arrive in five days", the model might say "You will get your money back within five days": completely correct, yet sharing only a few words with our reference. A naive word-counting score would mark it down. Today: the toolbox of exact evaluation, from running code, to string matching, to measuring similarity in words, and in meaning, and how to pick the right tool for each task.
Season Four, Module Fifteen, stop two: exact evaluation.
1:02Functional correctness: unit tests and pass@k
The gold standard of exact evaluation is functional correctness: does the output actually work? For code, run it against tests. Brightcart's order-total function must give seventy-six dollars fifty for three mugs and a discounted kettle, zero for an empty basket, and apply the discount only to kettles. If every test passes, the answer is correct, however it's written. The same idea extends beyond code: run a database query on test data and check the result; check a maths answer numerically; check whether an agent actually made the booking it claimed.
For code, a popular measure is pass at k: generate several solutions, and ask how likely it is that at least one of k of them passes. Suppose a model writes ten solutions and three pass. If you only get one try, the chance of success is thirty percent. If you can try five and keep any that passes the tests, it rises to about ninety-two percent. This connects to the best-of-n idea from episode forty-two.
2:12Exact match and format checks
When outputs are short and precise, like an order number pulled from an email, or a ticket category, exact match works well: is the output identical to the reference? It usually needs a little normalisation first, ignoring capital letters or extra words like "Order", so trivial differences don't count as errors. For category outputs, use the classification metrics from episode twelve: accuracy, and precision, recall and F1 for each category. And for structured output, measure format validity: what share of responses parse as valid JSON, matching the required schema.
Even with constrained decoding, it's worth tracking.
2:58Lexical similarity: counting shared words
For open-ended text with a reference answer, the oldest family of metrics simply counts shared words. Our reference has seven words; the candidate has six, and four of them, "your", "refund", "five" and "days", also appear in the reference. Precision: four out of the candidate's six words are shared, sixty-seven percent. Recall: four of the reference's seven words appear, fifty-seven percent. Their F1 is about zero point six two. We can count pairs of words too: of the candidate's five word pairs, two, "your refund" and "five days", appear in the reference, a bigram precision of zero point four.
Famous metrics like BLEU, from machine translation, and ROUGE, from summarisation, are more refined versions of this counting idea.
3:55Why word overlap fails
Now the problem. "You will get your money back within five days" means exactly the same as our reference, but it shares only three words with it: "will", "your" and "days". The reference spells its five as a digit, so the word "five" doesn't match. It would score poorly. And it fails in the other direction too. "Your refund will not arrive in five days" shares nearly every word with the reference, so it scores highly, yet it means the opposite. Word overlap measures surface form, not meaning. It also depends on having good reference answers, when in truth there are many valid ways to answer.
For an assistant like Brightcart's, word-overlap metrics can be misleading.
4:42Semantic similarity: comparing meaning
The fix is to compare meaning instead of words. Turn the reference and the candidate into embedding vectors, the meaning-space from episode thirty-five, and measure their cosine similarity. In our example space, "refund" and "money back" point almost the same way, zero point nine nine six, while "refund" and "delivery" point quite differently, zero point two seven. Embed whole sentences the same way, and our paraphrase now scores highly, as it should. Semantic similarity is far better for paraphrases, but it isn't perfect.
Small but crucial differences, like a negation, or "five days" versus "fifteen days", may still produce similar embeddings. The scores depend on which embedding model you use. And you need to decide what counts as "similar enough", ideally by checking against examples that people have labelled.
5:40Building reference data
Every reference-based metric is only as good as its references. Brightcart builds an evaluation set from two hundred real support tickets, with personal details removed, and asks Sana's team to write expert answers. Where possible, include several good reference answers per question, cover the tricky edge cases, update the set when policies change, and, crucially, keep it separate from anything used to build or tune the system, just as we kept the test set locked away in Season One.
6:14Choosing a metric
So which metric should you use? If the output can be run or checked, check it: functional correctness. If it's a short value or category, use exact match or classification metrics. If it's structured, check the format and then each field. If it's open-ended but has reference answers, prefer semantic similarity, with word overlap only as a rough signal. And if there's no single right answer at all, for things like helpfulness, tone and safety, you need judgement, from people, or from another AI. That's next episode.
6:50Try it yourself: pass@k with one success
The model writes ten versions of the discount function, and only one passes the tests. What's pass at one, and pass at five? Pause. Pass at one is simply one in ten. For pass at five, ask: if we pick five of the ten at random, what's the chance at least one is the working version? The chance of picking five failures is a hundred and twenty-six out of two hundred and fifty-two, exactly a half, so pass at five is a half. With three working versions, it was over ninety percent. Pass at k answers a practical question: if I let it try k times, how likely is it to succeed at least once?
7:37Pause & Predict: the perfect paraphrase
Here's a perfect paraphrase of the reference: "you will get your money back within five days". It means exactly the same thing. Will word overlap reward it? Pause. It shares only three words with the reference: "your", "will" and "days". Its F1 is zero point three seven five, lower than the earlier candidate's zero point six one five, even though the paraphrase is arguably the better reply. "Five" written as a word doesn't even match the digit. That's the weakness of lexical metrics in a single example.
8:19Normalise before you compare
Exact match is only fair after normalisation. When the model extracts invoice fields, "twelve dollars fifty" might appear as "dollar sign twelve point five zero" in one place and "twelve point five" in another. Dates come in many formats, and company names vary in capital letters and punctuation. So convert everything into one standard form first: parse numbers and dates, lowercase names, strip stray punctuation. Then compare. But be careful to normalise the format, never the meaning.
8:55Pause & Predict: field accuracy vs document accuracy
Each invoice has four fields, and the model gets each field right ninety-four percent of the time. What fraction of invoices come out completely correct? Pause. If the errors are independent, zero point nine four to the fourth power: about seventy-eight percent. Ninety-four percent sounds great, but more than one invoice in five still needs fixing. Report both numbers: field-level accuracy tells engineers where to improve, and document-level accuracy tells the business how much manual work remains.
9:38Try it yourself: choosing a similarity threshold
Semantic similarity needs a threshold: how close is close enough? Here are eight labelled pairs. The four that mean the same thing score zero point nine five, zero point nine one, zero point eight six and zero point eight two. But one pair that means something different scores zero point eight eight. Where would you set the threshold? Pause.
At zero point eight, every true match is caught, but one false match slips in. At zero point nine, there are no false matches, but half the true ones are missed. In between is a compromise. No threshold is perfect, so choose it on labelled data from your own task, based on which kind of mistake costs you more.
10:30Unit tests for replies
Even open-ended replies can have unit tests. Does the reply mention the order number the customer gave? Does it avoid stating a delivery date that isn't in the order data? Is it under eighty words? Is it free of email addresses and card numbers? Does it include the returns link when the topic is returns? Each check is simple, fast and exact. Run them over every reply in the evaluation set, and the failures point straight at what needs fixing.
11:03Looking after your golden set
Your evaluation set, often called a golden set, needs looking after. Version it: the first two hundred tickets, then fifty more about the new smart kettles, then thirty hard cases taken from real failures. Record which version every score was measured on, because scores are only comparable on the same version. And never paste golden examples into your prompts or training data. That would leak the test into the model, the leakage problem from Season One, and your scores would stop meaning anything.
11:37Pause & Predict: pick the metric
Pick the metric for each task. Extracting an order number from an email. Producing a JSON summary of a ticket. Writing a database query for Sana's dashboard. And drafting a friendly reply. Pause. The order number: exact match, after normalising. The JSON summary: first check it's valid against the schema, then compare each field. The database query: run it, and check that it returns the right results, because many different queries can be correct. And the friendly reply: automatic checks plus semantic similarity, and for qualities like tone, a judge, which is next episode's topic.
12:23When the tests are too weak
Functional correctness has a weak spot: the tests themselves. If the only test checks that three mugs and a kettle total seventy-six fifty, a "solution" that ignores its input and always returns seventy-six fifty will pass. Useless code, perfect score. Strong test suites include edge cases: an empty basket, a basket with no kettle, two kettles, rounding to the penny, and invalid input. Remember reward hacking from episode forty: whatever you measure, a model may find the shortcut, so make the measurement hard to fool.
12:59Myth vs Fact
Myth: a high word-overlap score means a good answer. Fact: as the negation example showed, an answer can share almost every word with the reference and mean the opposite. Use metrics that check what actually matters for your task.
13:17Recap
Let's recap. Functional correctness runs the output and checks it, and pass at k measures success across several attempts. Exact match, with normalisation, suits short outputs, and format checks suit structured ones. Word-overlap metrics like BLEU and ROUGE count shared words, but miss paraphrases and negations. Semantic similarity compares meaning with embeddings, though numbers and negations still need care. And every reference-based metric needs good, separate reference data. One sentence to remember: check what can be checked, and compare meaning, not just words.
13:57Next: AI as a judge
Mission complete. Brightcart scores order-number extraction with exact match, ticket routing with F1, code helpers with unit tests, and refund answers by meaning, plus a separate check on the numbers. But Sana's biggest questions can't be exact-matched. Was the reply helpful? Empathetic? Safe? On-brand? Next: using one AI to judge another, and how to keep that judge honest. See you on the map.