AI Hints
Home›Fine-Tuning LLMs Tutorial›Evaluating a Fine-Tuned Model
Fine-Tuning LLMs · Lesson 82 of 120

Why Evaluation Is Hard

Measuring free text.

⏱ 2 min read▶ Video at 2:04:44🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

The loss went down. But is the model actually good at our task? Loss alone can't tell us. We need to measure the answers themselves. And that's harder than it sounds.

  • The loss went down
  • But is it good at the task?
  • Measure the answers

Why it is hard

With a classifier, the answer is one label, so it's either right or wrong. A language model writes free text. The same answer can be written in many ways. And for open tasks, like writing a friendly reply, there may be many good answers.

keyvalue
Classifierone label, right or wrong
LLMfree text
Same meaningmany spellings
Open tasksmany good answers

Same meaning, different text

Here's a small example. Three strings, all saying the same thing. B has the keys in a different order. C has no spaces. Run it. As plain text, they're all different. But parsed as JSON, they're equal. So for our task, we compare parsed JSON, not text.

app.pypython
import json

a = '{"intent": "stock", "book": "Dune"}'
b = '{"book": "Dune", "intent": "stock"}'
c = '{"intent":"stock","book":"Dune"}'

print("a == b as text:", a == b)
print("a == c as text:", a == c)
print("a == b as JSON:", json.loads(a) == json.loads(b))
print("a == c as JSON:", json.loads(a) == json.loads(c))
Output
a == b as text: False
a == c as text: False
a == b as JSON: True
a == c as JSON: True

Kinds of measurement

There are three main kinds of measurement. Exact checks compare against a known answer. They're cheap, and perfect for structured output. Perplexity measures how surprised the model is by the right answer. And for open text, people, or another model, judge the quality.

MethodBest for
exact checksstructured output, labels
perplexityhow well it fits the data
human judgesopen text, the gold standard
LLM as a judgeopen text, at scale

Summary

Let's recap. Loss alone isn't enough. Free text is hard to compare. Parse structured output before comparing. And pick a measurement that fits the task. Next, exact match and valid JSON.

Key takeaways
  • Loss isn't enough
  • Parse, then compare
  • Fit the method to the task
Next up: Exact Match and Valid JSON — two numbers that matter