HomeAI-TechDharma Subject Extractor:...

Dharma Subject Extractor: Any Doc In, Structured Fields in JSON Out


A 2-billion-parameter mannequin that extracts precisely the fields you ask for, from any doc sort, outperforming each frontier LLM we examined, at a fraction of the associated fee.

cover_combined_1
In April, we launched DharmaOCR-LITE, a mannequin specialised for OCR throughout a variety of paperwork, from contracts and court docket filings to invoices, IDs and types. The paper behind it made a slender, well-measured case for area specialization: a smaller mannequin skilled nearer to its job beating general-purpose frontier APIs on that job.

OCR offers you the textual content on a web page, devoted to the unique formatting. That is precisely what you need when the job is the entire doc, like a contract you may learn finish to finish or a manuscript you are digitizing.

Nonetheless, there is a totally different use case: you do not need the web page, you need particular fields out of it, in a form a system downstream can devour. Each line merchandise on an bill, as a listing. The affected person identify, examination sort and date from a medical requisition, able to schedule. The fields off an ID, mapped to the columns of an worker document.

Run that doc by way of OCR and also you get again every little thing printed on it, line by line, with no indication of which string is the examination sort, which is the date or which quantity is the entire. Somebody nonetheless has to put in writing the code that maps every worth to the suitable area earlier than it reaches the database.

A general-purpose LLM can do that work at the moment, with cautious prompting. At frontier API pricing and latency, on a job many companies have to run at excessive quantity, that rapidly turns into the costly solution to remedy a well-defined downside.

So we constructed a mannequin for it as a substitute. The Subject Extractor takes a doc picture and both a request for every little thing it could actually discover, or a precise schema to fill, and returns structured JSON: typed, area by area, nested the place the doc nests. An bill comes again with each line merchandise as an ordered record, every with its personal amount and worth, alongside the totals. An ID comes again because the fields you may retailer, below the names your system already makes use of for them. The identical checkpoint handles all of it, with no per-type fine-tuning.

You may strive it your self right here.


What the Mannequin Does

Say a batch of provider invoices lands each morning, and also you want 4 issues off each to push into your system: the provider, the bill quantity, the due date, the entire. Similar story for medical requisitions going right into a scheduler, or contracts feeding a compliance system, the place what issues is the events, the time period, the penalties and the effective quantities. You do not want the web page, you want sure fields. With the Subject Extractor there are two methods to ask for them:

field-extractor-1280

  • Open: no schema equipped. The mannequin reads the web page and works out which components of it are structured fields (a label adopted by a price, a desk with a header row over its columns) from context and format, not from a set record of area names, and returns every little thing it finds as key-value pairs.
  • Schema-directed: you specify the precise form needed, area by area, with a sort for each (string, quantity, or boolean), below the important thing names your system already makes use of. Ask for “service_provider” and “client_company”, and people are the precise keys that come again. Ask for a desk and it fills it row by row, column by column, matching every cell to the important thing it belongs below. Ask for a area that is not on the doc, and it returns null as a substitute of inventing a price.

The selection comes right down to what you already know. Ship an open request when you do not know what the doc holds. Ship a schema when the output has to match a form that already exists elsewhere.

Both means, what comes again is JSON: the fields as keys, the values typed as requested, and null the place the doc did not have what you requested for. Whenever you ship a schema, the output follows it precisely, with the identical keys and no additional fields, so it could actually go straight into the subsequent system.


How It Was Skilled

The bottom mannequin is DharmaOCR-LITE v1.1, a brand new 2-billion-parameter model optimized from the one within the paper and already specialised for OCR by way of supervised fine-tuning and DPO. On high of that checkpoint we skilled a LoRA adapter on 43,384 coaching examples masking each request modes.

The information is organized into three streams:

  • English multi-domain information: numerous paperwork collected from the general public internet, spanning many doc sorts.
  • Brazilian area information: actual Brazilian paperwork sourced internally, in Portuguese.
  • Multilingual information: a smaller share masking different European and Asian languages, for broader generalization past English and Portuguese.

All three streams are annotated on the area stage. The combo is intentionally multi-domain: receipts, business invoices, types, financial institution statements, ID paperwork and artificial paperwork, slightly than one submitting sort.

03_training_data_mix_v2


The place the Benchmark Attracts the Line

The total benchmark covers 546 paperwork throughout three request eventualities, for 1,638 complete instances: extracting each area with no schema, a partial schema naming solely actual fields, and a schema that additionally contains intentionally nonexistent fields. The rating is field-level F1 (matched by path, together with place inside a desk), multiplied by the Levenshtein similarity on the values that matched and by the share of outputs that come again as legitimate JSON.

We ran the identical benchmark in opposition to 4 general-purpose frontier configurations.

image

In opposition to general-purpose LLMs, the standard hole runs from 1.8 factors (Claude Opus 5, the closest) to 9.3 factors (GPT-5.6 Luna, the widest).

image

Price runs from roughly 6 instances decrease (GPT-5.6 Luna) to roughly 147 instances decrease (GPT-5.6 Sol). The 2 sides are priced otherwise. The frontier figures come from measured common enter and output tokens per web page, reasoning tokens included, in opposition to every supplier’s revealed record pricing. Each frontier mannequin ran with reasoning set to low; Claude Opus 5 used adaptive effort, which may skip reasoning on easier pages whereas staying on the low stage. Ours is not billed per token: the mannequin runs self-hosted, so the determine is GPU time on a single L40S at $2.24 per hour.

This isn’t a gross sales value. Self-hosted value depends upon the {hardware}, the amount and the latency every deployment wants. The comparability is right here to point out {that a} sovereign SSLM, deployed by yourself infrastructure, is an actual various to frontier APIs.


A Take a look at of Generalization

SROIE and FUNSD are two public datasets in our benchmark, not utilized in coaching. Beneath is one instance from every.

On a SROIE receipt, we requested for all 18 fields printed on it, with no phantom fields this time, and each one comes again right: the multi-line, unlabeled billing tackle captured as a single area, the 2 clean fields (salesperson and ref) appropriately returned as null, and each quantity on the receipt matching to the cent.

sroie_combined

On a FUNSD photocopying variance type, a guidelines of twelve boolean fields with one nested group of 5 sub-options, the mannequin marks precisely the one field that is checked (poor high quality unique, with a handwritten “pale” observe beside it) as true, and the opposite eleven as false, matching the shape precisely. It additionally reads the handwritten Bates ID off the web page appropriately, and returns null for the 2 fields left clean.

funsd_combined


High quality and Price, on the Similar Time

A 2-billion-parameter mannequin scored 0.834, above each frontier configuration we examined, from Claude Opus 5 at 0.816 to GPT-5.6 Luna at 0.741, whereas operating on a single L40S at a decrease value per extraction than each API within the comparability. Larger high quality and decrease value, measured on the identical benchmark, in the identical run.

This is not the primary time we have measured it. Our OCR paper put the primary DharmaOCR-LITE, a 3-billion-parameter mannequin, above each business frontier API examined on Brazilian Portuguese; three months later, newer and better-resourced fashions arrived, and the hole held. Now a 2-billion-parameter mannequin does it on area extraction. Every consequence provides proof for the thesis we began Dharma-AI with: on a bounded job, a small mannequin skilled near that job beats a frontier mannequin requested to do the identical factor usually. On this benchmark, it additionally value 6 to 147 instances much less to run.

Parameter depend units the ceiling; coaching decides how a lot of it a mannequin reaches in your job. What you are promoting does not want the most important mannequin out there. It wants one skilled in your downside.

Strive it by yourself paperwork right here. To be taught extra about Dharma-AI and the specialised fashions we construct, go to dharma-ai.com.


Sources

  • BID. Brazilian Identification Doc Dataset. Soares, Neves Jr., Bezerra (2020), “BID Dataset: a problem dataset for doc processing duties,” Anais Estendidos XXXIII SIBGRAPI. github.com/ricardobnjunior/Brazilian-Identification-Doc-Dataset
  • CORD. Park et al., NAVER CLOVA (2019). huggingface.co/datasets/naver-clova-ix/cord-v2
  • DocVQA. Mathew et al., WACV 2021 (ICDAR 2019). huggingface.co/datasets/lmms-lab/DocVQA
  • WildReceipt. Solar et al., IJCAI 2021. huggingface.co/datasets/Theivaprakasham/wildreceipt
  • SROIE (ICDAR 2019). Held out from coaching, analysis solely. huggingface.co/datasets/darentang/sroie (mirror); upstream rrc.cvc.uab.es/?ch=13
  • FUNSD. Jaume et al. Held out from coaching, analysis solely. huggingface.co/datasets/nielsr/funsd (mirror); guillaumejaume.github.io/FUNSD
  • Zenodo Invoices (PT). Cruz & Castelli, NOVA IMS (2022). zenodo.org/data/6371710
  • line_items. Sagarjha456, Hugging Face. huggingface.co/datasets/Sagarjha456/line_items
  • Katanaml Invoices (Donut). Kozłowski & Weichbroth (2021), Mendeley Information doi:10.17632/tnj49gpmtz.2. huggingface.co/datasets/katanaml-org/invoices-donut-data-v1
  • HumynLabs Brazilian Payments and Invoices. huggingface.co/datasets/HumynLabs/Brazilian_Bills_and_Invoices_Dataset
  • Tech4Humans BR-Doc Extraction. huggingface.co/datasets/tech4humans/br-doc-extraction
  • Cardoso, Gabriel Pimenta de Freitas, et al. “DharmaOCR: Specialised Small Language Fashions for Structured OCR that outperform Open-Supply and Industrial Baselines.” arXiv preprint arXiv:2604.14314 (2026).


Additional Studying

Discover Dharma AI on Hugging Face to strive our interactive demos, obtain our open-source fashions, and uncover how specialised AI methods outperform general-purpose fashions in actual enterprise purposes.



Supply hyperlink

Get notified whenever we post something new!

spot_img

Continue reading

Dangote Will increase Africa Funding Pledge

Aliko Dangote has elevated his deliberate funding in African industrial growth to $60 billion by the top of the last decade, up from an earlier $50 billion goal, as his group expands its gasoline infrastructure throughout the continent. The...

Ethiopia Becomes Africa’s Fifth-Largest Economy After GDP Rebasing to $210.7 Billion

Ethiopia has turn out to be Africa’s fifth-largest economic system after a GDP rebasing elevated its measured gross home product to $210.7 billion for the 2025/26 fiscal 12 months. The revised rating locations the nation behind South Africa, Egypt,...

Zimbabwe Exports Climb 61% to $10.4 Billion as Value-Added Trade Targets $1 Billion by 2030

Zimbabwe’s merchandise exports climbed 61% to $10.4 billion between January and September 2026, whereas value-added exports elevated 68% to $671 million. The figures put the nation on track towards its aim of producing $1 billion in value-added exports by...

advert