knowledge · advanced · 90 min

Fine-tune a small open model

Train a small adapter (LoRA) on your dataset and prove with the test rows whether it beat the baselines.

HANDS-ON LAB · YOU RUN IT ON YOUR MACHINE · 4 STEPS
  1. Step 1 of 4

    Convert train and validation rows to chat format: the email in, the label out

    Run this to check

    head -n 1 data/train.chat.jsonl

    You pass when

    One JSON line with a messages list: a user message and a one-word assistant message.

    Files you write

    • data/train.chat.jsonl
    • data/valid.chat.jsonl
  2. Step 2 of 4

    Score the untuned small model on the test rows

    Run this to check

    uv run eval_tuned.py --base

    You pass when

    An accuracy number, usually below your classic baseline.

    Files you write

    • eval_tuned.py
  3. Step 3 of 4

    Train an adapter and log training and validation loss every 50 steps

    An adapter trains a few million numbers and leaves the model untouched, which is why it fits on a laptop.

    Run this to check

    tail -n 5 train.log

    You pass when

    Both losses went down from the first line of the log. The adapter is a small file, not a new model.

    Files you write

    • train.log
    • adapters/
  4. Step 4 of 4

    Find the step where validation loss stops falling and keep that checkpoint

    When training loss keeps falling and validation loss turns up, the model is memorising. Stop there.

    Run this to check

    uv run eval_tuned.py --adapter adapters/

    You pass when

    A tuned accuracy on the same 30 rows. In RESULTS.md, say which step you kept and why.

    Files you write

    • RESULTS.md
No transcript here on purpose. This page does not show terminal output, because model answers differ from run to run. Each step says what a pass looks like; your own terminal is the proof.