Suryanand/ Bootcamp
suryanand.com ↗Let's talk
← Fine-tuningAI guideIntermediate#fine-tuning#evals#testing#deployment
Frame · ai-engineering / fine-tuning / 09-evaluating-fine-tuned-models.mdGuide 080 / 103

Evaluating a fine-tuned model

Training loss going down tells you the model learned your dataset. It does not tell you the model got better at your job, stayed good at everything else, or is safe to put in front of users. Evaluation is where most of the real engineering in fine-tuning lives, and I would rather have a mediocre training setup with great evals than the reverse.

Why it matters

Fine-tuning changes behaviour in ways that are hard to predict. A model tuned for terse support replies may also become terse when it should explain. A model RL-trained on maths may get longer and slower on everything. A specialist may lose some of its safety behaviour, because narrow fine-tuning can erode refusals the base model had. Without a deliberate eval plan, you find these things from customer complaints.

Evals are also what make your work portable. When a base model is deprecated or a better one ships, the eval suite is how you decide in an afternoon whether to retrain.

How it works

I split evaluation into four layers, each answering a different question.

Rendering diagram…

Task evals use your held-out test set (frozen before training, decontaminated, see preparing training data). Prefer programmatic scoring: exact match, schema validity, unit tests, executed SQL results. For open-ended outputs, use an LLM judge with a written rubric and pairwise comparison against the baseline model.

Regression evals are a fixed set of general prompts and a few public benchmarks run through a harness such as EleutherAI's lm-evaluation-harness or the UK AI Security Institute's Inspect. You are looking for drops, not absolute scores.

Safety evals cover refusals on harmful requests, over-refusal on benign ones, prompt injection resistance if the model reads untrusted content, and any domain policies.

Ops evals measure output length, latency at your target batch size, and cost per request. RL-trained models in particular can quietly double their output length.

Reference architecture

Offline gates are necessary but not sufficient. The rollout path should also compare models on real traffic before anyone depends on the new one.

Rendering diagram…

After shadow mode, route a small canary percentage to the candidate and watch user-facing metrics (resolution rate, edits, thumbs down, escalations). Keep the old model warm for instant rollback.

Code

A compact eval runner that scores a base and a fine-tuned LoRA adapter on the same test set with vLLM, combining a programmatic validator and length tracking. LLM, SamplingParams and LoRARequest are vLLM's documented offline inference APIs.

import json, statistics
from vllm import LLM, SamplingParams
from vllm.lora.request import LoRARequest
from jsonschema import validate, ValidationError

schema = json.load(open("triage_schema.json"))
tests = [json.loads(l) for l in open("test.jsonl")]
prompts = [[{"role": "user", "content": t["input"]}] for t in tests]

llm = LLM(model="Qwen/Qwen3-4B", enable_lora=True, max_lora_rank=32)
params = SamplingParams(temperature=0.0, max_tokens=512)

def run(lora=None):
    outs = llm.chat(prompts, params, lora_request=lora)
    valid, correct, lengths = 0, 0, []
    for t, o in zip(tests, outs):
        text = o.outputs[0].text
        lengths.append(len(o.outputs[0].token_ids))
        try:
            obj = json.loads(text)
            validate(obj, schema)
            valid += 1
            correct += obj.get("queue") == t["expected_queue"]
        except (json.JSONDecodeError, ValidationError):
            pass
    n = len(tests)
    return {"valid": valid / n, "accuracy": correct / n,
            "median_tokens": statistics.median(lengths)}

print("base ", run())
print("tuned", run(LoRARequest("triage", 1, "./adapter")))

Run the same script in CI for every candidate checkpoint and store results next to the model in your registry.

Trade-offs and pitfalls

  • Contaminated test sets. If test inputs leaked into training, scores are meaningless. Decontaminate, and keep a second "fresh" set built from recent traffic.
  • Judge bias. LLM judges favour longer answers, the first position and sometimes their own model family. Randomise order, use pairwise comparisons and spot-check against human labels.
  • Single-number thinking. An average hides regressions on a minority slice. Break results down by category, language and input length.
  • Sampling noise. Small test sets swing several points between runs. Use enough examples, report confidence intervals, and fix temperature for comparisons.
  • Benchmarks are not your product. Public benchmarks are useful for spotting regressions, not for proving the model is good at your task.
  • Forgetting to eval the base. Always score the untuned base and your best prompted baseline on the same harness, or you cannot claim the fine-tune helped.

Checklist

  • Freeze and decontaminate a task test set before training.
  • Score base, prompted baseline and candidate on the same harness.
  • Include regression, safety and ops evals, not just task accuracy.
  • Use programmatic checks wherever possible and calibrated judges elsewhere.
  • Break results down by slice and report uncertainty.
  • Roll out via shadow then canary, with instant rollback.
  • Store eval results with the model version in your registry.

Further reading

Why this exists README

I learn best by explaining things, so I record the explanations. Everything here is free, with no sign-up. If a lesson helps you ship something, I'd love to hear about it.