andrea@gemelli ~ %

Your documents should not leave your laptop

A 350M model that turns Italian forms into JSON on a CPU, fully offline, and Scrivano, the app that runs it

5 min read Document AIKey Information ExtractionSmall ModelsFine-tuningOfflineOpen Source

Introduction

Key information extraction (KIE) usually works like this: a scan of a form goes to a server, a large model reads it, and structured data comes back. The document, often the most sensitive thing a person owns, has left their machine.

Identity cards, residency declarations, tax codes, bank details: for these documents I would rather lose a few points of accuracy than send them to someone else's GPU. So the question I started from was a practical one: how small can a model be and still extract fields well enough to run locally, on a CPU, with nothing leaving the laptop?

To answer it for Italian forms I built two things, both open on Hugging Face 🤗

Why local

Running locally is a design decision, not a deployment detail. It sets the constraints for everything else:

A frontier model would score higher. But for personal documents, keeping the data on the device is worth more to me than the gap.

The dataset

There was no Italian KIE dataset in this shape, so I built one from the Italian split of XFUND[1], a multilingual form-understanding benchmark.

The conversion starts from 4,882 question→answer links, maps their labels to a controlled set of keys (2,757 survive, 56%), then drops multi-answer labels and conflicting duplicate keys. The result is 199 documents, 1,461 fields and 37 extraction keys, each with a natural-language description (codice-fiscale, nome-completo, data-nascita, iban, ...), split 149 train / 50 validation.

Each example pairs a document's text and a field schema with the target JSON. 149 training documents is small, and the results below reflect that.

The model

The base is LiquidAI/LFM2.5-350M[2], fine-tuned with SFT (TRL[3]) to take a document's text plus a field schema and emit a JSON object, omitting fields it cannot find.

At this scale the model does not learn Italian or Italian bureaucracy. It learns a discipline: find the value, put it under the right key, close the brace.

Results

On the 50-document validation split, with greedy decoding:

Model Avg F1 JSON parse failures
LiquidAI/LFM2.5-350M (base) 0.2877 6 / 50
LFM2.5-350M-IT-Extract 0.6639 10 / 50
same, Q4_K_M GGUF 0.6635 10 / 50
same, Q4_K_M on OCR text 0.5662 10 / 50

These are upper bounds: the schema is oracle-filtered (the model is only asked for fields the document contains), parse failures are excluded rather than scored as zero, and the metric double-counts a wrong value. Everything is reproducible with uv run main.py.

Limitations

Trying it: Scrivano

To use the model without writing code, I wrapped it in Scrivano 📝, a small desktop app (~280 MB installed) with the model bundled inside. You drop in a PDF or an image, pick or edit the fields you want, and get streamed JSON back, with each value linked to its position on the page. OCR runs locally too (PP-OCRv5[4]), and values found nowhere on the page are flagged as likely inventions. Builds are on the releases page.

Scrivano with the sample residency form loaded The sample residency declaration loaded: fields on the left, streamed JSON on the right.

Conclusions 🎁

  1. Local inference is a feature. For personal documents, keeping data on the device is worth more than a few points of accuracy.
  2. A small fine-tuned model is enough for structured extraction. 350M parameters and 149 documents take F1 from 0.29 to 0.66.
  3. Report upper bounds as upper bounds. Oracle schema, excluded parse failures and a lenient metric all inflate the number, so say so.

Happy extracting 🤗

Update: eight languages and a second task

Since this post I released a second round, all in one Hugging Face collection:

Same size, same laptop, still offline 🔒

References


  1. Xu, et al., "XFUND: A Benchmark Dataset for Multilingual Visually Rich Form Understanding", Findings of ACL 2022 ↩︎

  2. Liquid AI, LFM2 Technical Report, 2025 ↩︎

  3. Hugging Face, TRL: Transformer Reinforcement Learning ↩︎

  4. PaddlePaddle, "PP-OCRv5", PaddleOCR, 2025 ↩︎