Lab: Fine-tuned DistilBERT against the TF-IDF router
Module 7 · Lab · About 60 minutes · Needs: lessons 1 to 4 of this module, and the Module 6 lab (or its cells, pasted here). A Colab T4 is recommended; the CPU path finishes in a few minutes
What you are building
It is Monday 19 October 2026, project week 7. Rosa's question from Lesson 4 still needs a fair answer: does a fine-tuned transformer beat the TF-IDF router on Tidewell's own mail, and what does it cost? The four lessons appended parts to inbox/hf_classifier.py and tests/test_hf_classifier.py. This lab settles both files once, brings back the saved TF-IDF model, fine-tunes DistilBERT with a fixed seed and saves it in models/, then scores both on HARD_TEST, the 80 hand-written messages: per class, per language, with training time, model size and speed. It ends with two more seeds and an interval, because one run on 80 messages can mislead, and a report for Rosa in reports/.
Open a new Colab notebook, call it module-07-lab.ipynb, and run each cell in order.