DharmaOCR-Benchmark / README.md
GabrielPimenta99's picture
Update README.md
4446cdc verified
|
Raw
History Blame Contribute Delete
6.32 kB
---
license: other
license_name: dharmaocr-benchmark-license
license_link: LICENSE
pretty_name: DharmaOCR-Benchmark
language:
- pt
task_categories:
- image-text-to-text
tags:
- ocr
- benchmark
- document-understanding
- brazilian-portuguese
- text-recognition
- handwriting-recognition
- legal-documents
size_categories:
- n<1K
dataset_info:
features:
- name: id
dtype: int64
- name: image
dtype: image
- name: image_base64
dtype: string
- name: assistant
dtype: string
- name: assistant_without_json
dtype: string
splits:
- name: test
num_bytes: 2534593858
num_examples: 496
download_size: 2532700883
dataset_size: 2534593858
configs:
- config_name: default
data_files:
- split: test
path: data/test-*
---
# DharmaOCR-Benchmark
<p align="left">
![Dharma-AI](logo/Dharma-ai_logo_horizontal-black.png#hf-light-mode-only)
![Dharma-AI](logo/Dharma-ai_logo_horizontal-white.png#hf-dark-mode-only)
</p>
## Overview
**DharmaOCR-Benchmark** is a 496-instance evaluation suite for OCR models focused on **Brazilian Portuguese** documents. It covers printed text, handwritten text, and legal/administrative documents — domains underrepresented in existing benchmarks like OCRBench and olmOCR-Bench.
This benchmark evaluates not only transcription quality, but also **text degeneration rate** and **unit inference cost** as first-class metrics.
Released alongside the [DharmaOCR](https://huggingface.co/dharma-ai/DharmaOCR-Lite) family of models. For the full methodology and analysis, see our paper: **[DharmaOCR: Specialized Small Language Models for Structured OCR that Outperform Open-Source and Commercial Baselines](https://arxiv.org/abs/2604.14314)**.
## Why this benchmark?
Existing OCR benchmarks do not reliably predict performance on Brazilian Portuguese documents. Language-specific orthography, domain vocabulary, and document formatting shift error profiles and amplify text degeneration in ways that general-purpose benchmarks fail to capture.
DharmaOCR-Benchmark fills this gap with a focused, reproducible evaluation protocol.
## Dataset Composition
| Subset | Samples | Description |
|---|---|---|
| **ESTER-Pt** | 363 | Printed text recognition in Brazilian Portuguese |
| **Legal** | 83 | Legal and administrative documents (publicly sourced, fully human-audited) |
| **BRESSAY** | 50 | Handwritten text recognition in Brazilian Portuguese |
| **Total** | **496** | |
> ⚠️ This benchmark was **not used** for training, model selection, DPO pair construction, or quantization calibration of any DharmaOCR model.
## Evaluation Protocol
### Score
```
DharmaOCR-Benchmark Score = (LevenshteinRatio + BLEU) / 2
```
| Component | What it captures |
|---|---|
| `LevenshteinRatio` | Character-level fidelity (misspellings, missing accents, punctuation) |
| `BLEU` | N-gram sequence preservation (reorderings, dropped spans) |
### Additional Metrics
- **Text degeneration rate (%):** Requests that hit the output-token limit *and* exhibit repeated text spans (n-gram criterion). A critical operational metric — degenerate requests inflate cost and reduce throughput system-wide.
- **Unit cost per page:** Enables fair comparison between self-hosted models and commercial APIs.
### Inference Setup
| Parameter | Value |
|---|---|
| **GPU** | NVIDIA L40S (48GB GDDR6) |
| **Instance** | AWS g6e.2xlarge |
| **Engine** | vLLM |
| **Max output tokens** | 8,192 |
| **Temperature** | 0 |
## 🏆 Benchmark Results
<table>
<thead>
<tr>
<th>Model</th>
<th>Score ↑</th>
<th>Degeneration Rate (%) ↓</th>
<th>Time/Page (s) ↓</th>
</tr>
</thead>
<tbody>
<tr>
<td>🥇 <b>DharmaOCR Full</b> (7B, ours)</td>
<td><b>0.925</b></td>
<td><b>0.40</b></td>
<td>2.132</td>
</tr>
<tr>
<td>🥈 <b>DharmaOCR Lite</b> (3B, ours)</td>
<td><b>0.911</b></td>
<td><b>0.20 ✨</b></td>
<td><b>1.464</b></td>
</tr>
<tr><td colspan="4"><br><b>Commercial APIs</b></td></tr>
<tr>
<td>Claude Opus 4.6</td>
<td>0.833</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Gemini 3.1 Pro</td>
<td>0.820</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GPT-5.4</td>
<td>0.750</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Google Vision</td>
<td>0.686</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Google Document AI</td>
<td>0.640</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GPT-4o</td>
<td>0.635</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Amazon Textract</td>
<td>0.618</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Mistral OCR 3</td>
<td>0.574</td>
<td></td>
<td></td>
</tr>
<tr><td colspan="4"><br><b>Open-Source Models</b></td></tr>
<tr>
<td>Qwen2.5-VL-7B-Instruct</td>
<td>0.839</td>
<td>2.42</td>
<td>3.101</td>
</tr>
<tr>
<td>Qwen3-VL-8B</td>
<td>0.829</td>
<td>5.65</td>
<td>7.250</td>
</tr>
<tr>
<td>olmOCR-2-7B</td>
<td>0.823</td>
<td>1.41</td>
<td>4.306</td>
</tr>
<tr>
<td>Nanonets-OCR2-3B</td>
<td>0.791</td>
<td>2.62</td>
<td>1.911</td>
</tr>
<tr>
<td>Dots OCR</td>
<td>0.738</td>
<td>6.85</td>
<td>2.526</td>
</tr>
<tr>
<td>GLM-OCR</td>
<td>0.710</td>
<td>11.69</td>
<td>1.480</td>
</tr>
<tr>
<td>Qwen3-VL-2B-Instruct</td>
<td>0.623</td>
<td>11.69</td>
<td>3.566</td>
</tr>
<tr>
<td>Qwen2.5-VL-3B-Instruct</td>
<td>0.549</td>
<td>0.60</td>
<td>1.500</td>
</tr>
<tr>
<td>gemma-3-4b-it</td>
<td>0.214</td>
<td>33.96</td>
<td>2.182</td>
</tr>
<tr>
<td>DeepSeek-OCR</td>
<td>0.196</td>
<td>21.98</td>
<td>1.213</td>
</tr>
</tbody>
</table>
<sub>Score = (LevenshteinRatio + BLEU) / 2. Time/page on NVIDIA L40S. ✨ = lowest degeneration rate across all models.</sub>
## Usage
```python
from datasets import load_dataset
dataset = load_dataset("dharma-ai/DharmaOCR-Benchmark")
```
## Citation
```bibtex
@misc{cardoso2026dharmaocrspecializedsmalllanguage,
title={DharmaOCR: Specialized Small Language Models for Structured OCR that outperform Open-Source and Commercial Baselines},
author={Gabriel Pimenta de Freitas Cardoso and Caio Lucas da Silva Chacon and Jonas Felipe da Fonseca Oliveira and Paulo Henrique de Medeiros Araujo},
year={2026},
eprint={2604.14314},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2604.14314},
}
```
## Contact
For technical questions, benchmark usage, research inquiries, or paper-related discussions:
**gabriel.pimenta@dharma-ai.com.br**