datalab-to/chandra

image text to texttransformerstransformerssafetensorsqwen3_vlimage-text-to-textocrvlmopenrail
vLLMRunnable with vLLM
239.3K

Chandra

Chandra is an OCR model that outputs markdown, HTML, and JSON. It is highly accurate at extracting text from images and PDFs, while preserving layout information.

You can try Chandra in the free playground here, or at a hosted API here.

Features

  • Convert documents to markdown, html, or json with detailed layout information
  • Good handwriting support
  • Reconstructs forms accurately, including checkboxes
  • Good support for tables, math, and complex layouts
  • Extracts images and diagrams, with captions and structured data
  • Support for 40+ languages

Quickstart

The easiest way to start is with the CLI tools:

pip install chandra-ocr

# With VLLM
chandra_vllm
chandra input.pdf ./output

# With HuggingFace
chandra input.pdf ./output --method hf

# Interactive streamlit app
chandra_app

Benchmarks

We used the olmocr benchmark, which seems to be the most reliable current OCR benchmark in our testing.

ModelArXivOld Scans MathTablesOld ScansHeaders and FootersMulti columnLong tiny textBaseOverallSource
Datalab Chandra v0.1.082.280.388.050.490.881.292.399.983.1 ± 0.9Own benchmarks
Datalab Marker v1.10.083.869.774.832.386.679.485.799.676.5 ± 1.0Own benchmarks
Mistral OCR API77.267.560.629.393.671.377.199.472.0 ± 1.1olmocr repo
Deepseek OCR75.272.379.733.396.166.780.199.775.4 ± 1.0Own benchmarks
GPT-4o (Anchored)53.574.570.040.793.869.360.696.869.9 ± 1.1olmocr repo
Gemini Flash 2 (Anchored)54.556.172.134.264.761.571.595.663.8 ± 1.2olmocr repo
Qwen 3 VL70.275.145.637.589.162.143.094.364.6 ± 1.1Own benchmarks
olmOCR v0.3.078.679.972.943.995.177.381.298.978.5 ± 1.1olmocr repo
dots.ocr82.164.288.340.994.182.481.299.579.1 ± 1.0dots.ocr repo

Examples

TypeNameLink
TablesWater Damage FormView
Tables10K FilingView
FormsHandwritten FormView
FormsLease AgreementView
HandwritingDoctor NoteView
HandwritingMath HomeworkView
BooksGeography TextbookView
BooksExercise ProblemsView
MathAttention DiagramView
MathWorksheetView
MathEGA PageView
NewspapersNew York TimesView
NewspapersLA TimesView
OtherTranscriptView
OtherFlowchartView

Usage

Installation

pip install chandra-ocr

From code


from chandra.model import InferenceManager
from chandra.model.schema import BatchInputItem

# Run chandra_vllm to start a vLLM server first if you pass vllm, else pass hf
# you can also start your own vllm server with the datalab-to/chandra model
manager = InferenceManager(method="vllm")
batch = [
    BatchInputItem(
        image=PIL_IMAGE,
        prompt_type="ocr_layout"
    )
]
result = manager.generate(batch)[0]
print(result.markdown)

With transformers

from transformers import AutoModel, AutoProcessor
from chandra.model.hf import generate_hf
from chandra.model.schema import BatchInputItem
from chandra.output import parse_markdown

model = AutoModel.from_pretrained("datalab-to/chandra").cuda()
model.processor = AutoProcessor.from_pretrained("datalab-to/chandra")

batch = [
    BatchInputItem(
        image=PIL_IMAGE,
        prompt_type="ocr_layout"
    )
]

result = generate_hf(batch, model)[0]
markdown = parse_markdown(result.raw)

Credits

Thank you to the following open source projects:

DEPLOY IN 60 SECONDS

Run chandra on Runcrate

Deploy on H100, A100, or RTX GPUs. Pay only for what you use. No setup required.