Eval Harnesses: Proving Your Fine-Tune Actually Worked
You fine-tuned in Episode 1, preference-tuned in Episode 5, and served the result in Episode 6. One question decides whether any of it worked: did the fine-tune actually get better at your task, or does it just feel better in chat? This is the companion tutorial to Train Your Own AI, Episode 7: a verified eval harness for a single 24 GB, 4090-class GPU, built on EleutherAI's lm-eval plus a frozen held-out set of your own. No headline hourly GPU price is quoted here because rental prices move daily; check the directory for today's.
Why training loss lies
Three numbers get confused constantly:
- Training loss measures fit to the training data. It falls even when the model is memorizing, so a beautiful curve can hide an overfit model.
- Eval loss (TRL's
SFTTrainerwith aneval_datasetand an eval strategy set) measures fit to held-back data. Training loss falling while eval loss turns back up means the model stopped generalizing. - Task score measures the thing you care about: the ticket classified right, the JSON valid, the preferred answer picked.
Eval loss is the smoke alarm; task score is the verdict. And the verdict only counts on examples the model never trained on, under the same prompts, same chat template, and same decoding settings for every model compared. Change any of those between runs and you benchmarked your prompt, not your fine-tune.
Freeze the held-out set first
Take 100-200 examples of your real task and slice them on purpose:
- Normal: representative, everyday inputs.
- Hard: inputs the base model gets wrong today. This is where a fine-tune earns its keep.
- Regression: inputs the base model already handles well. A fine-tune that gains on hard cases and loses here is a bad trade.
- Format: exact structure checks, e.g. valid JSON with the right keys.
- Edge: messy, long, or ambiguous inputs.
Save it as one JSON Lines file, heldout.jsonl, with a prompt and an expected answer per line. Freeze it and version it. Once you have tuned against a test set a hundred times, it quietly becomes training data.
Pick the metric that matches the task
- Classification: accuracy, plus F1 when classes are unbalanced (a model can nail the common class, whiff the rare one, and still post a pretty average).
- Structured output: exact match on the fields that matter, plus a schema check (valid JSON, right keys, right types), because close does not parse.
- Open-ended answers: a blind win rate. Generate from both models on 50-100 held-out prompts, hide which is which, score which answer wins; ties count as half. This is the DPO proof from Episode 5, generalized.
- Perplexity (exponentiated eval loss): a supporting signal only. A model can be confidently fluent and still wrong.
Write the metric, the slices, and the pass bar down before you run. A bar set after the scores arrive is a rationalization.
Public benchmarks with lm-eval
The standard runner is EleutherAI's lm-evaluation-harness (lm_eval), the harness behind the Hugging Face Open LLM Leaderboard. Current installs are lighter: the base package no longer bundles the model backends, so install it with the Hugging Face extra. Smoke-test with --limit first (the docs mark it for testing only), then run the real thing.
pip install "lm_eval[hf]"
lm_eval ls tasks
For a 7B fine-tune on 24 GB, start with the cheap loglikelihood tasks. Run the base model first and save the output:
lm_eval --model hf \
--model_args pretrained=unsloth/Qwen2.5-7B-Instruct,dtype=bfloat16 \
--tasks hellaswag,arc_easy,arc_challenge,winogrande,boolq,piqa,openbookqa \
--device cuda:0 --batch_size auto \
--output_path results/base --log_samples
Then run the exact same command with one addition in --model_args: peft= pointing at your LoRA adapter. The harness loads the base model and evaluates the adapter on top, no merge needed (the same trick vLLM used for serving in Episode 6). Add load_in_4bit=True to the model args if memory gets tight.
lm_eval --model hf \
--model_args pretrained=unsloth/Qwen2.5-7B-Instruct,dtype=bfloat16,peft=./your-adapter \
--tasks hellaswag,arc_easy,arc_challenge,winogrande,boolq,piqa,openbookqa \
--device cuda:0 --batch_size auto \
--output_path results/finetune --log_samples
--log_samples matters: it saves individual outputs so you can read failures later, not just the headline score.
Score your own held-out set
Public benchmarks prove the fine-tune did not break general ability. They cannot prove it learned your task. The held-out file gets its own short script, not a framework:
from datasets import load_dataset
held = load_dataset("json",
data_files="heldout.jsonl", split="train")
# For BASE and for FINE-TUNE (PEFT adapter):
# same chat template, greedy decoding,
# same max_new_tokens -> save every output
# Score with YOUR metric from above:
# accuracy / F1 / exact match / schema check
# Then READ 20 failures by hand. Bucket them.
Sort the failures into buckets (wrong facts, wrong format, refusals, rambling) and you know exactly what the next dataset needs. Never tune against the held-out failures and then report the same set as proof: fix the training data, retrain, and let the frozen set judge again, or build a fresh one and say so.
Read the results like a skeptic
- Delta, per slice: fine-tune minus base, per task and per slice, never one blended average that can hide a regression.
- Regression slice: if the model got worse at things it used to do well, that is catastrophic forgetting. Honest options: fewer steps, lower learning rate, mix general data back in, or walk away from the checkpoint.
- Variance: small test sets wobble. A one-point gain on 100 examples is noise, not a victory.
- Grade the shipped artifact: if production is the GGUF from Episode 3 or the vLLM server from Episode 6, run the held-out set against that quantized, served copy too. Quantization can cost points the adapter never lost.
Recap, and the series loop closed
Training loss is not proof. Proof is a frozen held-out set, scored identically for base and fine-tune, with a task-matched metric and a pass bar set before the run. Use lm-eval for public benchmarks (base first, then the same command with peft=), your own script for the task only your data can judge, and grade the deliverable you actually ship. That closes the loop this series opened in Episode 1: train, feed, export, choose, prefer, serve, and now prove.
Find the cheapest GPU for your next run
Live pricing, hardware specs, and availability across 30 GPU clouds, neoclouds, and bare-metal providers.
Open the Directory