Personal project · public or synthetic data
LLM fine-tuning for data extraction
LoRA on a 1.5B open model to turn receipts into JSON, on a laptop GPU, with 1.2 % of the weights trained.
Key results
- field F1, zero-shot → LoRA
- 0.543 to 0.870
- receipts with every field right
- 0 to 45 %
- generation time per receipt
- 1.97 to 0.45 s
- of the weights trained
- 1.2 %
Receipts in, JSON out
Turn receipt text into structured JSON (items with name, quantity and price; subtotal, tax, service; total, cash, change) on the public CORD v2 benchmark: 800 training, 100 validation and 100 test receipts. The base model and the fine-tuned one get the same prompt, which describes the target schema.
LoRA on a laptop GPU
LoRA rank 16 on every attention and MLP projection of Qwen2.5-1.5B-Instruct, bf16, gradient checkpointing. The loss is computed on the answer tokens only, so the model learns to answer rather than to reproduce its input. After each epoch the model generates on the validation receipts and the best epoch is kept; the test set is scored once.
Served by FastAPI with the adapter merged into the base weights, generation in a worker thread behind a lock so the event loop stays responsive.
Before and after fine-tuning
Field F1 0.543 → 0.870 on the test set; receipts with every field right 0 % → 45 %; valid JSON 99 % for both. The fine-tuned model is also 4× faster (0.45 s vs 1.97 s per receipt), because it writes compact JSON instead of pretty-printing every key with null values.


Read before comparing
Not comparable with Donut’s published CORD F1: Donut reads the image, while here the model reads text rebuilt from the annotated words. Sub-items (options listed under a dish) remain weak, with a recall of 0.19 for their names.
A first run crashed on the GPU during epoch 2; its epoch-1 checkpoint was scored on test at that point (F1 0.833). That score did not influence any choice.