← All posts

Fine-tuning small models on a laptop with LoRA

You do not need a cluster to learn fine-tuning. A tiny model, prompt masking, and a CPU smoke test go a long way.

llm-finetune-lab
LoRA Fine-Tuning

llm-finetune-lab is my playground for supervised fine-tuning without a GPU farm. It uses LoRA and PEFT so you only train a small adapter, and it defaults to TinyLlama with a distilgpt2 CPU smoke test so the whole loop runs on a laptop.

Prompt masking matters

The detail that most tutorials skip: mask the prompt tokens so the loss is only computed on the response. Without it, the model spends capacity learning to echo the instruction instead of answering it.

bash
$ python train.py --model distilgpt2 --epochs 1masking prompt tokens: ontrainable params: 0.8% of base

A generate script lets you try the trained adapter immediately, which closes the loop from data to a model you can actually talk to.


Newsletter

Get the next one in your inbox.

I respect your inbox. No spam, unsubscribe anytime.