Dharma Field Extractor: Structured JSON Output from Any Document

Dharma-AI describes the Dharma Field Extractor as a model that converts document images into structured JSON, returning typed fields and nested tables as requested. The system is built on a DharmaOCR-LITE v1.1 checkpoint and a LoRA adapter trained on 43,384 annotated examples spanning receipts, invoices, IDs, forms and synthetic documents.

How it works

The Field Extractor supports two request modes. In Open mode, the model detects structured key–value pairs and tables from layout and context and returns everything it finds. In Schema-directed mode, a caller supplies exact key names and types (string, number, boolean) and the model fills them; it returns null for fields not present and emits no extra keys beyond the provided schema.

Output is JSON: keys match the requested names, values are typed as requested, tables are populated row by row, and nested fields follow the document structure. The team emphasizes that a single checkpoint handles multiple document types without per-type fine-tuning.

Training and evaluation

Dharma-AI reports the underlying model has roughly 2 billion parameters and was fine-tuned from DharmaOCR-LITE with a LoRA adapter across three data streams: English multi-domain documents, Brazilian documents in Portuguese, and a smaller multilingual set. All training examples were annotated at the field level.

The benchmark used 546 documents and three request scenarios for a total of 1,638 cases. Scores are computed at the field level as F1 (matched by path, including table position), multiplied by Levenshtein similarity on matched values and by the share of valid JSON outputs.

On this benchmark, Dharma-AI reports a score of 0.834 for the 2‑billion‑parameter Field Extractor. The reported comparisons show Claude Opus 5 at 0.816 and GPT-5.6 Luna at 0.741. Cost comparisons are presented as relative multiples versus frontier APIs, ranging from about 6× to 147× lower; the model ran self-hosted on a single L40S GPU, with GPU time cited at $2.24 per hour as an example.

Held-out public datasets SROIE and FUNSD were included for generalization checks. Dharma-AI describes successful extractions on these sets, including multi-line addresses, blank fields returned as null, precise numeric matches to the cent, and checkbox detection on degraded scans.

Dharma-AI makes the model and interactive demos available and provides documentation and downloads at dharma-ai.com.


Original source: Hugging Face Blog

Leave a Comment