A specialized optical character recognition model engineered specifically for Brazilian Portuguese achieved higher accuracy and lower text degeneration rates than newer multilingual models, according to findings published by Hugging Face. The model, named DharmaOCR, recorded a score of 0.925 on a Portuguese-language benchmark evaluation. By comparison, two generalist models released after DharmaOCR—Mistral OCR4 and Unlimited-OCR—scored 0.798 and 0.7587 on the same test.
DharmaOCR was developed by Gabriel Pimenta de Freitas Cardoso, Francisco de Almeida Rocha Alves, and Victor Gabriel Ferreira Barbosa. The research team initially introduced the system in an arXiv preprint titled "DharmaOCR: Specialized Small Language Models for Structured OCR that outperform Open-Source and Commercial Baselines" and open-sourced one of its models three months prior to the July 16, 2026 evaluation report.
Training Architecture
The developers built DharmaOCR using a two-stage training process. The first phase consisted of supervised fine-tuning using a broad corpus of Portuguese-language files from varied sources, formats, and complexity levels. This stage aligned the neural network weights to the vocabulary, syntax, and document structures of Brazilian Portuguese. By restricting the domain to a single language rather than spreading capacity across a multilingual space, the model dedicated all available parameters to specific orthographic and morphological patterns.
Direct Preference Optimization formed the second phase to stabilize output during inference. Rather than training strictly on correct transcriptions step by step, DPO evaluated full extractions using comparative preference data between competing outputs. Generative OCR systems operating on step-by-step next-token prediction can experience text degeneration when encountering visual ambiguity, such as small fonts, degraded scans, or dense handwriting. Under these conditions, early divergence causes subsequent token predictions to drift into repetitive or incoherent loops. DPO suppressed these failure conditions, reducing inference time and processing costs.
Benchmark Results and Errors
Benchmark evaluations pitted DharmaOCR against Mistral OCR4 and Unlimited-OCR on complex, domain-specific documents. On Brazilian national high school examination (ENEM) essay manuscripts, which combine handwritten text with regional proper nouns and cultural references, both generalist models failed on key terms.
Mistral OCR4 transcribed the name of Brazilian musician Chico Buarque as "Chico Barque." Unlimited-OCR rendered the same name as "chico bique" and transcribed the quotation "O Brasil não exclui, assimila" as "a dose de chico bique, 'o Brasil no exclu, eliminila.'" When presented with documents rendered in small fonts, Mistral OCR4 generated degenerated text completely disconnected from the source text, creating structurally unusable output for downstream classification and compliance workflows.
The development team noted that parameter distribution is subject to the neuron superposition principle, where individual parameters encode multiple features simultaneously. While multilingual models split capacity across N languages, domain-focused models maximize parameter allocation for a single linguistic space. The authors plan to apply future architectural advances and alignment methods to maintain specialized OCR performance for Portuguese documents.
