layeser/qwen2.5-1.5b-receipt-extraction-lora
a receipt data extraction LoRA for JSON
2 min readupdated
This LoRA adapter (a small add-on for the base model) trains Qwen2.5-1.5B-Instruct to turn OCR (optical character recognition) receipt text into structured JSON. It outputs compact JSON containing item positions, quantities, prices, taxes, and totals without extra empty fields. The model is built on Qwen/Qwen2.5-1.5B-Instruct and was trained in just 22 minutes on a standard laptop GPU. It runs 4 times faster than the base version and handles receipt parsing with higher accuracy. This tool is useful for developers and analysts who need to automate the processing of receipts and financial documents.
Key features
- Field F1 accuracy increased from 0.54 to 0.87 compared to the base model.
- Generation speed on an RTX 5060 laptop increased to 0.45 seconds per receipt.
- Compact output: the model records only the fields that are actually present in the receipt.
- Trained on the CORD v2 dataset using the LoRA method (rank 16, alpha 32).
What you can do
- Apply it in bots or scripts for automatic parsing of receipts and bills using a given system prompt.
- Integrate it into applications for tracking personal or corporate expenses.
- Use the code to quickly deploy a data extraction pipeline on local hardware.
Example
import json
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
BASE, ADAPTER = "Qwen/Qwen2.5-1.5B-Instruct", "layeser/qwen2.5-1.5b-receipt-extraction-lora"
tok = AutoTokenizer.from_pretrained(ADAPTER)
model = AutoModelForCausalLM.from_pretrained(BASE, dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, ADAPTER).merge_and_unload()
Read more
DetailsBenchmarks: Field F1 0.870 (versus 0.543 for the base), correct receipt rate 45% (versus 0%).
Requirements: run and tested on a laptop GPU with 8 GB VRAM.
Limitations: the model works with post-OCR text (not directly with images) and struggles more with rare fields and sub-items.
Training details: CORD v2 dataset, 800 training examples, epoch 3 chosen by best F1 metric.










Comments