Practice in Lab: Project: Compare full tuning and LoRA budgets →
Download complete project source →
Project: Compare full tuning and LoRA budgets
A fair comparison records what is held constant and what differs. Both methods start from the same pretrained revision and classification head, see the same row order, use the same sequence length and receive the same number of optimizer steps. The method-specific learning rates are declared in the report. Parameter bytes, AdamW tensor bytes and file sizes answer different questions; none is a measurement of peak resident memory.
Download dependencies, keep the source
In Pythilo, choose this project in New project. Its code is saved locally immediately. Open Project downloads and explicitly tap Download project packages to save PyTorch, the shared UCI dataset/tokenizer and the 17.7 MB pretrained safetensors asset. Nothing downloads when you create, open or run a project. Once that complete download finishes, training and evaluation run entirely offline on the CPU. Progress, pause and resume are in Downloads. Native Python backends remain in the signed app. Each project shares the same downloaded assets.
On a desktop, use the complete source archive linked from this lesson, install torch==2.15.0 and numpy, then run fetch_assets.py once. Run python main.py for the complete dataset; --quick is an explicitly smaller contract-check run. Pythilo’s Run button uses the complete project by default.
Inspect the actual source data
The original dataset contains 3,000 review sentences from Amazon, Yelp and IMDb. The loader checks source hashes, normalizes text identities, removes conflicting labels, deduplicates groups and creates deterministic partitions. It splits only on newline because two IMDb sentences contain embedded NEL characters. Tokenization uses Google’s fixed WordPiece vocabulary; no vocabulary is fitted on the test set.
import pythilo_finetune as ft
splits = ft.dataset()
print({key: len(splits[key]) for key in ("train", "valid", "test")})
print(splits["original_rows"])Build the experiment
Compare identical splits and step budgets; measure trainable tensors, AdamW state and export bytes.
Read the complete reference implementation below. The shared pythilo_finetune.py implements BERT, WordPiece, safe asset loading, metrics and artifact primitives; the project owns its data choices, optimizer loop and evidence. Full and LoRA recipes expose zero_grad, cross_entropy, backward, gradient clipping, optimizer.step and validation selection directly.
Evaluate and review
Compare validation and held-out loss, accuracy and macro-F1. The report records row and normalized-text identities, all asset hashes, the pretrained revision, real optimizer-state bytes and artifact sizes. Model quality is measured, not assumed; the short quick fixture can perform poorly. Four epochs on this small English dataset do not establish production readiness. Review subgroup errors, multiple seeds, data rights, calibration, serving latency and representative out-of-domain tests before deployment.
Sources and reuse
Model: Google BERT miniature, revision 30b0a37ccaaa32f332884b96992754e246e48c5f, Apache-2.0. Dataset: Kotzias (2015), Sentiment Labelled Sentences, DOI 10.24432/C57604, CC BY 4.0. Original files are retained verbatim; normalization, grouping and splitting happen in memory. Attribution and the source manifest accompany the downloaded data.
Your task
Compare identical splits and step budgets; measure trainable tensors, AdamW state and export bytes. Implement run_project(output, quick=False). Follow the reference report/artifact schema; the checks run quick=True with actual pretrained weights and real data. The full dataset is the default.
The explanation opens here once every check passes.