I fine-tuned a 270M model to read receipts as well as a 3 GB one (free Colab GPU, fictional data, C# test)
In October I built Shoebox, a private receipt and GST sorter, for the Hacktoberfest Open-Source AI Challenge. It used Gemma 3 4B through Ollama to read receipt photos on my own computer. It worked, but it was slow (about 80 seconds per receipt on a CPU-only machine), and it got the GST wrong on 2 of 6 sample receipts.
So I asked a simple question: can a tiny model, trained for just this one job, do it as well as a much bigger general model?
Short answer: on my test, yes. A fine-tuned Gemma 3 270M (about 0.3 GB) got every field right on all 6 test receipts, in about 1 second per receipt on my laptop CPU. The big model needed 31 seconds for the same result. The rest of this post is how I did it, with no paid GPU and no real receipts, and what the result does not prove.
The job
Turn a receipt's text into seven fields, as JSON:
{"vendor": "...", "date": "YYYY-MM-DD", "subtotal": 0.00, "gst": 0.00, "other_tax": 0.00, "tip": 0.00, "total": 0.00} Canadian receipts make this harder than it looks. Alberta has 5% GST only, BC adds 7% PST, Ontario has 13% HST, basic groceries are zero-rated, and dates come in every format.
Step 1: measure first
Before training anything, I wrote a small C# test, ReceiptBench. It uses the same 6 fictional sample receipts from Shoebox, the same prompt and strict scoring: amounts to the cent, the date exact, the vendor by name. That's 42 fields in total.
| Model | Size | Fields right (of 42) | Time per receipt |
|---|---|---|---|
| Gemma 4 E4B | ~3 GB | 42 | 31 s |
| Gemma 3 270M, untrained | ~0.3 GB | 11 | 1 s |
The untrained 270M's 11 points are fake. It copied the example from the prompt word for word ("...", "YYYY-MM-DD", zeros), and only scored on fields whose right answer happened to be 0.
Honest note: Gemma 4 had already solved the problem. If you just need receipts read, choosing a better model was the real fix. Fine-tuning here is about something else: getting the same result from a model a tenth the size, 30 times faster.
Step 2: make training data, without real receipts
I never put real receipts in a public repo or a cloud notebook. Instead, a Python script generates 2,000 fictional receipts with known answers:
- 7 provinces with their real tax rules (HST counts as GST; PST, RST and QST go in
other_tax) - 8 kinds of business (fuel, coffee, restaurants, groceries, office supplies…)
- zero-rated groceries, sometimes printing
GST 0.00and sometimes no tax line at all - tips, six date formats, and different labels (
SUBTOTAL,Sub Total,G.S.T.,AMOUNT DUE…) - a check that every receipt adds up to the cent Two rules kept the test fair:
- No leakage. None of the 6 test receipts or their businesses appear in the training data.
- A held-out set. 200 more generated receipts are never trained on, used only for scoring. ## Step 3: train on a free Colab GPU (10.5 minutes)
I used Unsloth with LoRA: the original model stays frozen, and only a small add-on is trained. In my run, that was 30 million of 298 million numbers (10%).
- Free Google Colab T4 GPU
- 2 passes over the data, learning rate 1e-4, LoRA rank 128
- only the answers are scored during training, not the questions (
train_on_responses_only) On the 200 held-out receipts:
| Fields right | |
|---|---|
| Before training (50 receipts) | 96 / 350 (27%) |
| After training (200 receipts) | 1400 / 1400 (100%) |
The training loss (how wrong its answers are) fell from 0.084 to 0.000 by step 150 of 680. It learned the job in the first quarter of training, so one pass would probably have been enough.
Then Unsloth exported the model as a single 292 MB GGUF file, which Ollama can run.
A tip if you try this: Colab warns that a notebook from GitHub "was not authored by Google". That's normal, but code you run there runs under your Google account. I used a separate Google account with nothing in it.
Step 4: back on my laptop
ollama create receipt-reader -f Modelfile dotnet run -- extract receipt-reader 01_fuel.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 6 s 02_coffee.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 1 s 03_office.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 1 s 04_courier.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 1 s 05_bc_print.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 1 s 06_groceries.jpg ✓vendor ✓date ✓subtotal ✓gst ✓other_tax ✓tip ✓total 1 s (The first one takes 6 seconds while the model loads.)
| Model | Size | Fields right (of 42) | Time per receipt |
|---|---|---|---|
| Gemma 3 270M, untrained | ~0.3 GB | 11 | 1 s |
| Gemma 3 270M, fine-tuned | ~0.3 GB | 42 | ~1 s |
| Gemma 4 E4B | ~3 GB | 42 | 31 s |
It got the zero-rated groceries right, and it put BC's PST in other_tax. Those were the kinds of details my October app got wrong.
What this does not prove
- Six test receipts is a small test. One run, all from the same fictional sample set.
- The 100% held-out score is the easy part. Those receipts come from the same generator as the training data, so a perfect score shows the model learned my generator's rules. I also wrote the generator after seeing the test receipts' styles (date formats, the
GST 5%line). No text was copied, but the training data was shaped to look like the test. A long restaurant bill, another language or a style it has never seen could fail. - It reads text, not photos. The 270M model does only the second half: text to fields. Something still has to read the photo first (here, Gemma 4).
- It does one thing. Ask it anything else and it still answers with receipt JSON. ## What I learned
- Measure before you train. The baseline showed that a better model already solved the problem, and that the tiny model's 11/42 was really zero.
- The data is most of the work. The training itself was one notebook and 10 minutes. Getting tax rules, zero-rated groceries and date formats right in the generator took far longer.
- Score on data the model never saw, and say how similar it is to the training data.
- Small specialised models are a real option. For one narrow, repeated job, 0.3 GB and 1 second beats 3 GB and 31 seconds. ## Why open models made this possible
- I could train it. Fine-tuning needs the weights. Gemma's are open, and Unsloth and Colab's free tier made it cost nothing.
- Receipts stay private. The trained model runs offline on my laptop, and the training data was fictional, so no real receipt ever left my computer.
-
It runs anywhere. 0.3 GB and a CPU is enough.
Try it
-
Code, data generator, notebook and full results:
AgentLab
My hands-on notebook for learning AI agents and fine-tuning with small open-weight models, in C#/.NET, on a laptop.
In October 2026 I built four local-first apps with open models (portfolio). They each call a model for one job. This repo is about the next level: models that use tools to finish multi-step tasks, reusable instructions for agents, choosing models, and fine-tuning. Everything runs locally through Ollama, with no cloud and no credit card. All projects target .NET 10 (LTS, supported until November 2028).
…Step What I'm learning Folder Status 1 Agents with tools 1.1 An agent loop by hand, with guardrails 01-mini-agent✅ Works with qwen3:4bandqwen2.5:3b
1.2 The same agent with an open-source .NET AI framework (Microsoft.Extensions.AI) 02-framework-agent✅ Works with qwen3:4b; guardrail still needed1.3 A real task: an assistant for my Sloth Sort app (search, read, suggest; you approve) 03-sloth-assistant✅
The Colab run with every output:
07-fine-tuning/colab/run-2026-11-28.ipynbThe model: receipt-reader v1 release (292 MB GGUF)
This is Step 4 of AgentLab, my notebook for learning agents, skills, model choice and fine-tuning with small open models in C#/.NET on a laptop.
The model is a modified version of Gemma 3 270M and is subject to the Gemma Terms of Use. All receipts in this project are fictional.