datalab-to/chandra-ocr-2
<p align="center"> <img src="datalab-logo.png" alt="Datalab Logo" width="150"/> </p>
Chandra OCR 2
Chandra 2 is a state of the art OCR model from Datalab that outputs markdown, HTML, and JSON. It is highly accurate at extracting text from images and PDFs, while preserving layout information.
Try Chandra in the free playground, or use the hosted API for higher accuracy and speed.
What's New in Chandra 2
- 85.8% olmocr bench score (sota), 77.8% multilingual bench score (12% improvement over Chandra 1)
- Significant improvements to math, tables, complex layouts
- Improved layout, especially on wider documents
- Significantly better image captioning
- 90+ language support with major accuracy gains
Features
- Convert documents to markdown, HTML, or JSON with detailed layout information
- Excellent handwriting support
- Reconstructs forms accurately, including checkboxes
- Strong performance with tables, math, and complex layouts
- Extracts images and diagrams, with captions and structured data
- Support for 90+ languages
<img src="handwritten_form.png" width="600px"/>
Quickstart
pip install chandra-ocr
# With vLLM (recommended, easy install)
chandra_vllm
chandra input.pdf ./output
# With HuggingFace (requires torch)
pip install chandra-ocr[hf]
chandra input.pdf ./output --method hfUsage
With vLLM (recommended)
from chandra.model import InferenceManager
from chandra.model.schema import BatchInputItem
from PIL import Image
# Start vLLM server first with: chandra_vllm
manager = InferenceManager(method="vllm")
batch = [
BatchInputItem(
image=Image.open("document.png"),
prompt_type="ocr_layout"
)
]
result = manager.generate(batch)[0]
print(result.markdown)With HuggingFace Transformers
from transformers import AutoModelForImageTextToText, AutoProcessor
from chandra.model.hf import generate_hf
from chandra.model.schema import BatchInputItem
from chandra.output import parse_markdown
from PIL import Image
import torch
model = AutoModelForImageTextToText.from_pretrained(
"datalab-to/chandra-ocr-2",
dtype=torch.bfloat16,
device_map="auto",
)
model.eval()
model.processor = AutoProcessor.from_pretrained("datalab-to/chandra-ocr-2")
model.processor.tokenizer.padding_side = "left"
batch = [
BatchInputItem(
image=Image.open("document.png"),
prompt_type="ocr_layout"
)
]
result = generate_hf(batch, model)[0]
markdown = parse_markdown(result.raw)
print(markdown)Benchmarks
olmOCR Benchmark
<img src="bench.png" width="600px"/>
Examples
Multilingual Benchmark (43 Languages)
The table below covers the 43 most common languages, benchmarked across multiple models. For a comprehensive evaluation across 90 languages (Chandra 2 vs Gemini 2.5 Flash only), see the full 90-language benchmark.
<img src="multilingual.png" width="600px"/>
Full 90-Language Benchmark
We also have a more comprehensive evaluation covering 90 languages, comparing Chandra 2 against Gemini 2.5 Flash. The average scores are lower than the 43-language table above because this includes many lower-resource languages. Chandra 2 averages 72.7% vs Gemini 2.5 Flash at 60.8%.
See the full 90-language results.
Throughput
Benchmarked with vLLM on a single NVIDIA H100 80GB GPU using a diverse mix of documents (math, tables, scans, multi-column layouts) from the olmOCR benchmark set. This set is significantly slower than real-world usage - we estimate 2 pages/s in real-world usage.
Commercial Usage
Code is Apache 2.0. Model weights use a modified OpenRAIL-M license: free for research, personal use, and startups under $2M funding/revenue. Cannot be used competitively with our API. For broader commercial licensing, see pricing.
