LedgerLens: Qwen2-VL-2B distilled for offline receipt extraction (GGUF)
Photo of a receipt or invoice in, one JSON object out: vendor, date, currency, total, tax, line items. Runs fully offline with llama.cpp, including on Android phones.
This is the deployment artifact of LedgerLens, a model-compression portfolio project. Qwen2-VL-2B-Instruct was LoRA fine-tuned on CORD and SROIE receipts with targets blended from a Qwen2.5-VL-7B teacher and the datasets' gold labels, then exported to GGUF.
Research and noncommercial use only. See License below.
Files
| File | Size | What |
|---|---|---|
sft2b-teacher-agree-q4_k_m.gguf | 0.99 GB | Language model, Q4_K_M |
mmproj-sft2b-teacher-agree-f16.gguf | 1.33 GB | Vision tower / projector, f16 |
Both files are required. The vision tower is not quantized; llama.cpp's vision-encoder quantization support is immature, and this is where almost all of the on-device latency goes (see On-device).
Run it
With a recent llama.cpp build:
llama-mtmd-cli \
-m sft2b-teacher-agree-q4_k_m.gguf \
--mmproj mmproj-sft2b-teacher-agree-f16.gguf \
--image receipt.jpg --temp 0 \
-p 'Extract the following fields from this receipt or invoice image and answer with a single JSON object, nothing else:
{"vendor": string|null, "date": "YYYY-MM-DD"|null, "currency": ISO-4217 string|null, "total": number|null, "tax": number|null, "line_items": [{"description": string, "qty": number, "unit_price": number, "total": number}]}
Use null for fields not present. Do not invent values.'
Or serve it:
llama-server -m sft2b-teacher-agree-q4_k_m.gguf --mmproj mmproj-sft2b-teacher-agree-f16.gguf
The prompt above is the exact string the model was trained and evaluated with
(PROMPT in the repo's schema.py). Use it verbatim; the model expects it inside the
standard Qwen ChatML template, which llama.cpp applies automatically.
Expected output for a valid receipt is a single JSON object, for example:
{"vendor": "OJC MARKETING SDN BHD", "date": "2019-01-15", "currency": "SGD", "total": 193.0, "tax": null,
"line_items": [{"description": "KINGS SAFETY SHOES KWD 805", "qty": 1, "unit_price": 193.0, "total": 193.0}]}
Results
Every number comes from the project's eval harness and is recorded in
results/results.csv.
Scoring only counts the fields each dataset annotates (SROIE has no line items or tax;
CORD has no vendor, date or currency). "EM" is exact match after normalization.
| Variant | Split (n) | JSON valid | Total EM | Field EM (mean) | Line-item F1 |
|---|---|---|---|---|---|
| Stock Qwen2-VL-2B, Q4_K_M (zero-shot) | SROIE (347) | 96.0% | 90.2% | 77.3% | — |
| Teacher Qwen2.5-VL-7B, 4-bit (zero-shot) | CORD (100) | 97.0% | 85.0% | 86.0% | 87.7% |
| Teacher Qwen2.5-VL-7B, 4-bit (zero-shot) | SROIE (347) | 96.5% | 94.2% | 90.1% | — |
| Distilled 2B, fp16 | CORD (100) | 100% | 92.0% | 93.5% | 94.7% |
| Distilled 2B, fp16 | SROIE (347) | 100% | 96.8% | 94.3% | — |
| This file: Distilled 2B, GGUF Q4_K_M | CORD (100) | 100% | 91.0% | 92.0% | 93.8% |
| This file: Distilled 2B, GGUF Q4_K_M | SROIE (347) | 100% | 96.5% | 95.2% | — |
Read the teacher comparison correctly: the teacher is zero-shot and 4-bit, the student is fine-tuned on in-distribution data with gold-quality supervision on every annotated field. This is task specialization beating general zero-shot inference, not a 2B model out-reasoning a 7B one.
Memorization check. SROIE train and test share 72.6% of vendor strings. On the 95 test receipts whose vendor never appears in training, this GGUF scores 91.6% total EM and 75.8% vendor EM, versus 96.5% and higher on the full split. A real but modest drop, and still well above the stock model on the same subset.
On-device (Android)
Measured with the project's React Native app (llama.rn), same two files, one real SROIE test receipt, exact-match output in every run listed:
| Phone | SoC / GPU | Path | Time per receipt |
|---|---|---|---|
| Nothing Phone (3) | Snapdragon 8s Gen 4 / Adreno 825 | OpenCL GPU | ~19 s (cold: 31 s) |
| Nothing Phone (3) | same | CPU only | ~2 min |
| HONOR REA-NX9 | Snapdragon 7 Gen 1 / Adreno 644 | CPU only | 5 min 20 s |
| HONOR (Dimensity-class) | 778G+, no OpenCL | CPU only | 11.3 min |
Over 99% of CPU-only time is the fp16 vision-tower prefill, not text generation. The GPU path is chip-gated: it crashed on load on Adreno 6xx-class GPUs, so the app only enables it on verified 8-series hardware. Also observed and documented in the repo: severe thermal throttling degraded output to null fields rather than just slowing down; the same phone produced exact matches again once cool.
These are manual measurements on three devices, not a benchmark suite. The project has no production deployment and no users.
Training
- Student:
Qwen/Qwen2-VL-2B-Instruct, LoRA SFT, checkpoint chosen by held-out eval loss. - Teacher: Qwen2.5-VL-7B-Instruct (4-bit), zero-shot labels on the CORD and SROIE train splits.
- Targets: field-level blend. Where the dataset annotates a field, the teacher's value is used only if it agrees with gold; unannotated fields take the teacher's read.
- Compute: Kaggle free-tier T4s, chunked across sessions.
- Export:
convert_hf_to_gguf.pyfrom llama.cpp, thenllama-quantizeto Q4_K_M.
Full code, data converters, harness and scripts: https://github.com/iivek/LedgerLens
Training data and attribution
- CORD-v2 (NAVER CLOVA), CC BY 4.0. https://huggingface.co/datasets/naver-clova-ix/cord-v2
- SROIE (ICDAR 2019 Robust Reading Challenge, Task 3). Dataset-level license unconfirmed at the time of writing; treated as research-use-only.
See DATA_LICENSES.md.
License
These weights are released under the
PolyForm Noncommercial License 1.0.0.
Full terms and the required notice:
MODEL_LICENSE.md.
Independently of that choice, SROIE's unconfirmed dataset license means any checkpoint trained on it, including this one, is research-use-only until the organizers confirm otherwise.
Required Notice: Copyright iivek (LedgerLens) — model weights trained on CORD (CC BY 4.0, NAVER CLOVA) and SROIE (ICDAR 2019 RRC Task 3, license unconfirmed, research-use-only)