Dharma Field Extractor: Any Document In, Structured Fields in JSON Out

Overview

Dharma-AI has introduced the Dharma Field Extractor, a 2-billion-parameter model specialized for extracting structured data from documents. Unlike general-purpose LLMs that require complex prompting to parse documents, this model is built to output typed, schema-compliant JSON directly from document images, offering higher accuracy and significantly lower inference costs than frontier API alternatives.

Capabilities and Modes

The Field Extractor operates in two distinct modes, allowing users to balance flexibility with strict output requirements:

  • Open Extraction: The model analyzes a document without a provided schema, identifying structured fields—such as key-value pairs or table headers—based on layout and context, and returns the findings as JSON.
  • Schema-Directed Extraction: Users provide a specific schema defining the desired field names, types (string, number, or boolean), and nesting structures. The model maps document content to these keys, returning null for missing fields and ensuring the output matches the required format for downstream database integration.

Technical Foundation and Training

The model is built upon DharmaOCR-LITE v1.1, a 2-billion-parameter architecture optimized through supervised fine-tuning and Direct Preference Optimization (DPO). To achieve its performance, the model was trained using a LoRA adapter on a dataset of 43,384 examples. The training data mix includes three primary streams:

  • English multi-domain data: A broad collection of public web documents.
  • Brazilian domain data: Real-world documents in Portuguese.
  • Multilingual data: A representative sample covering various European and Asian languages.

This training approach emphasizes field-level annotation across diverse document types, including invoices, bank statements, identification documents, and forms.

Performance and Benchmarking

In a benchmark evaluation covering 546 documents and 1,638 total test cases, the Dharma Field Extractor outperformed several general-purpose frontier LLMs. The evaluation measured field-level F1 scores, Levenshtein similarity for values, and valid JSON output rates. The model achieved a score of 0.834, surpassing frontier configurations that ranged from 0.741 to 0.816.

Beyond performance, the model offers substantial cost efficiency. Because it is designed for self-hosting on infrastructure like a single L40S GPU, the operational cost is estimated to be between 6 and 147 times lower than the per-token pricing of the frontier API models tested. This demonstrates that for bounded, domain-specific tasks, a specialized small language model can provide superior results compared to larger, general-purpose models.

Sources