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.
1pip install chandra-ocr
2
3# With vLLM (recommended, easy install)
4chandra_vllm
5chandra input.pdf ./output
6
7# With HuggingFace (requires torch)
8pip install chandra-ocr[hf]
9chandra input.pdf ./output --method hf
1from chandra.model import InferenceManager
2from chandra.model.schema import BatchInputItem
3from PIL import Image
4
5# Start vLLM server first with: chandra_vllm
6manager = InferenceManager(method="vllm")
7batch = [
8 BatchInputItem(
9 image=Image.open("document.png"),
10 prompt_type="ocr_layout"
11 )
12]
13result = manager.generate(batch)[0]
14print(result.markdown)
1from transformers import AutoModelForImageTextToText, AutoProcessor
2from chandra.model.hf import generate_hf
3from chandra.model.schema import BatchInputItem
4from chandra.output import parse_markdown
5from PIL import Image
6import torch
7
8model = AutoModelForImageTextToText.from_pretrained(
9 "datalab-to/chandra-ocr-2",
10 dtype=torch.bfloat16,
11 device_map="auto",
12)
13model.eval()
14model.processor = AutoProcessor.from_pretrained("datalab-to/chandra-ocr-2")
15model.processor.tokenizer.padding_side = "left"
16
17batch = [
18 BatchInputItem(
19 image=Image.open("document.png"),
20 prompt_type="ocr_layout"
21 )
22]
23
24result = generate_hf(batch, model)[0]
25markdown = parse_markdown(result.raw)
26print(markdown)
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.
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%.
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.
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.