Papa Programmer
Lesson 06 of 36

Define the task and what success means

9 min read

Optional

Start with one sentence

A Model fine-tuningAdditional training of an existing model using new data. It updates model or adapter parameters to change performance or behaviour for a task; the result must be evaluated. project that starts with "make the model better at support" will not finish, because nothing says when it is done. A usable task is narrow and checkable, such as "read one customer message and return exactly one label: billing, access or technical".

That sentence names the input, the output and the allowed values. Add two more facts: who uses the result, and what happens when the model is unsure. If an uncertain answer goes to a person, the task has a safe exit, and you can measure how often the model uses it.

Inputs, outputs and edge cases

Write down what the model receives, such as the message text and the product name, and what it must not receive, such as the customer's email address. Write down the exact outputs, including how to spell them. Then list the cases that will be hard.

  • A message with two problems, such as a billing error that also locks the account.
  • A message with no clear category, such as "hello?".
  • A message in another language, or full of typing errors.
  • A message that tries to give the model instructions.

Put examples of each into your evaluation set now. Hard cases are rare in real traffic, so a random sample will hardly contain them, and a model can look good while failing exactly where it matters.

WeakStrong
TaskImprove support repliesReturn one of three labels for each message
OutputWhatever reads wellOne word from a fixed list
SuccessIt feels betterAt least 90 percent recall on technical tickets
UnsureNot mentionedSend to a person
A weak and a strong task statement

Choose the score before you train

The usual first score is AccuracyThe fraction of predictions that are correct. It can hide poor performance on less common classes, so inspect class-level results too., the share of answers that are right. It is easy to read, and it misleads when some labels are rare. The program below shows it. Of 100 tickets, 80 are billing, 15 are access and 5 are technical. It scores two models.

python
truth = ["billing"] * 80 + ["access"] * 15 + ["technical"] * 5
always_billing = ["billing"] * 100
good = ["billing"] * 76 + ["access"] * 4 + ["access"] * 12 + ["billing"] * 3 + ["technical"] * 4 + ["access"] * 1

def report(name, guess):
	accuracy = sum(t == g for t, g in zip(truth, guess)) / len(truth)
	print(f"{name}: accuracy {accuracy:.0%}")
	for label in ["billing", "access", "technical"]:
		hits = sum(t == g == label for t, g in zip(truth, guess))
		said = sum(g == label for g in guess)
		real = sum(t == label for t in truth)
		precision = hits / said if said else 0
		print(f"  {label:10} precision {precision:.2f}  recall {hits / real:.2f}")

report("always billing", always_billing)
report("tuned model", good)

It prints:

text
always billing: accuracy 80%
  billing    precision 0.80  recall 1.00
  access     precision 0.00  recall 0.00
  technical  precision 0.00  recall 0.00
tuned model: accuracy 92%
  billing    precision 0.96  recall 0.95
  access     precision 0.71  recall 0.80
  technical  precision 1.00  recall 0.80

The model that always answers billing scores 80 percent accuracy without understanding anything. It finds none of the access or technical tickets, and the recall figures of 0.00 show it. The tuned model has higher accuracy, but the more useful information is in the per-label lines. Precision is how often a label is right when the model says it. Recall is how many of the real cases of that label the model finds. If a missed technical ticket is costly, recall on technical is your target, not overall accuracy. Here the tuned model finds only 80 percent of technical tickets, so it would miss a 90 percent target despite its 92 percent accuracy.

The Lesson Metrics for classification and generation covers more scores. For now, the rule is to pick one main score and a short list of labels to watch, and write them down before training.

Set the baseline

A baseline is the score you get without fine-tuning. Run the same held-out questions through two things:

  1. A careful prompt on an off-the-shelf model, with a few examples inside it.
  2. Your current process, such as a person, a rule list or an older model.

Record the prompt, the model version, the score and a few of the wrong answers. This gives you the number to beat. It also tells you whether fine-tuning is needed at all, because a good prompt sometimes reaches the target. The Lesson RAG or fine-tuning? covers that decision.

Set a target with the people who use it

Agree the target with the people who will rely on the result. "At least 90 percent recall on technical tickets, and no more than 5 percent of billing tickets sent to the wrong team" is a target that can pass or fail. "Better than before" is not.

Also agree what a failed project looks like. If the tuned model beats the baseline by two points but costs ten times as much to run, the answer might be to keep the prompt.

Write it down

Keep the task statement, label list, score, target and baseline in one short file in your repository. Every later Lesson in this path refers back to it.

One sentenceState the input, the allowed outputs and what happens when the model is unsure.
Choose the score firstPer-label precision and recall show failures that accuracy hides.
Beat a baselineScore a prompt and the untuned model on the same questions before training.

Your reading position is saved

0%

0 of 36 complete

Contents

Learning tools