Image-Text-to-Text
Transformers
Safetensors
qwen3_5
ocr
pdf
markdown
layout
conversational
Eval Results
Instructions to use datalab-to/chandra-ocr-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use datalab-to/chandra-ocr-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="datalab-to/chandra-ocr-2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("datalab-to/chandra-ocr-2") model = AutoModelForMultimodalLM.from_pretrained("datalab-to/chandra-ocr-2", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use datalab-to/chandra-ocr-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "datalab-to/chandra-ocr-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/chandra-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/datalab-to/chandra-ocr-2
- SGLang
How to use datalab-to/chandra-ocr-2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "datalab-to/chandra-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/chandra-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "datalab-to/chandra-ocr-2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "datalab-to/chandra-ocr-2", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use datalab-to/chandra-ocr-2 with Docker Model Runner:
docker model run hf.co/datalab-to/chandra-ocr-2
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,6 +10,11 @@ tags:
|
|
| 10 |
- vision-language
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Chandra 2
|
| 14 |
|
| 15 |
Chandra 2 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.
|
|
@@ -46,7 +51,7 @@ chandra input.pdf ./output --method hf
|
|
| 46 |
|
| 47 |
## Usage
|
| 48 |
|
| 49 |
-
### With vLLM
|
| 50 |
|
| 51 |
```python
|
| 52 |
from chandra.model import InferenceManager
|
|
@@ -118,8 +123,33 @@ print(markdown)
|
|
| 118 |
| Qwen 3 VL 8B | 70.2 | 75.1 | 45.6 | 37.5 | 89.1 | 62.1 | 43.0 | 94.3 | 64.6 ± 1.1 | Own benchmarks |
|
| 119 |
| Gemini Flash 2 (Anchored) | 54.5 | 56.1 | 72.1 | 34.2 | 64.7 | 61.5 | 71.5 | 95.6 | 63.8 ± 1.2 | olmocr repo |
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
### Multilingual Benchmark (43 Languages)
|
| 122 |
|
|
|
|
|
|
|
| 123 |
<img src="multilingual.png" width="600px"/>
|
| 124 |
|
| 125 |
| Language | Datalab API | Chandra 2 | Chandra 1 | Gemini 2.5 Flash | GPT-5 Mini |
|
|
@@ -131,7 +161,6 @@ print(markdown)
|
|
| 131 |
| da | 90.1% | 91.1% | 88.4% | 86.0% | 87.7% |
|
| 132 |
| de | 93.8% | 94.8% | 83.0% | 88.3% | 93.8% |
|
| 133 |
| el | 89.9% | 85.6% | 85.5% | 83.5% | 82.4% |
|
| 134 |
-
| en | 95.2% | 96.6% | - | 90.3% | 88.3% |
|
| 135 |
| es | 91.8% | 89.3% | 88.7% | 86.8% | 97.1% |
|
| 136 |
| fa | 82.2% | 75.1% | 69.6% | 61.8% | 56.4% |
|
| 137 |
| fi | 85.7% | 83.4% | 78.4% | 86.0% | 84.7% |
|
|
@@ -169,28 +198,6 @@ print(markdown)
|
|
| 169 |
| zh | 87.8% | 88.7% | 88.3% | 70.0% | 70.4% |
|
| 170 |
| **Average** | **80.4%** | **77.8%** | **69.4%** | **67.6%** | **60.5%** |
|
| 171 |
|
| 172 |
-
## Examples
|
| 173 |
-
|
| 174 |
-
<img src="handwritten_form.png" width="600px"/>
|
| 175 |
-
|
| 176 |
-
| Type | Name | Link |
|
| 177 |
-
|------|------|------|
|
| 178 |
-
| Tables | Statistical Distribution | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/complex_tables.png) |
|
| 179 |
-
| Tables | Financial Table | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/financial_table.png) |
|
| 180 |
-
| Forms | Registration Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/handwritten_form.png) |
|
| 181 |
-
| Forms | Lease Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/lease_filled.png) |
|
| 182 |
-
| Math | CS229 Textbook | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/cs229.png) |
|
| 183 |
-
| Math | Handwritten Math | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/handwritten_math.png) |
|
| 184 |
-
| Math | Chinese Math | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/chinese_math.png) |
|
| 185 |
-
| Handwriting | Cursive Writing | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/cursive_writing.png) |
|
| 186 |
-
| Handwriting | Handwritten Notes | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/handwritten_notes.png) |
|
| 187 |
-
| Languages | Arabic | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/arabic.png) |
|
| 188 |
-
| Languages | Japanese | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/japanese.png) |
|
| 189 |
-
| Languages | Hindi | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/hindi.png) |
|
| 190 |
-
| Languages | Russian | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/russian.png) |
|
| 191 |
-
| Other | Charts | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/charts.png) |
|
| 192 |
-
| Other | Chemistry | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/chemistry.png) |
|
| 193 |
-
|
| 194 |
## Commercial Usage
|
| 195 |
|
| 196 |
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](https://www.datalab.to/pricing?utm_source=gh-chandra).
|
|
|
|
| 10 |
- vision-language
|
| 11 |
---
|
| 12 |
|
| 13 |
+
<p align="center">
|
| 14 |
+
<img src="datalab-logo.png" alt="Datalab Logo" width="150"/>
|
| 15 |
+
</p>
|
| 16 |
+
<h1 align="center">Datalab</h1>
|
| 17 |
+
|
| 18 |
# Chandra 2
|
| 19 |
|
| 20 |
Chandra 2 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.
|
|
|
|
| 51 |
|
| 52 |
## Usage
|
| 53 |
|
| 54 |
+
### With vLLM (recommended)
|
| 55 |
|
| 56 |
```python
|
| 57 |
from chandra.model import InferenceManager
|
|
|
|
| 123 |
| Qwen 3 VL 8B | 70.2 | 75.1 | 45.6 | 37.5 | 89.1 | 62.1 | 43.0 | 94.3 | 64.6 ± 1.1 | Own benchmarks |
|
| 124 |
| Gemini Flash 2 (Anchored) | 54.5 | 56.1 | 72.1 | 34.2 | 64.7 | 61.5 | 71.5 | 95.6 | 63.8 ± 1.2 | olmocr repo |
|
| 125 |
|
| 126 |
+
## Examples
|
| 127 |
+
|
| 128 |
+
<img src="handwritten_form.png" width="600px"/>
|
| 129 |
+
|
| 130 |
+
| Type | Name | Link |
|
| 131 |
+
|------|------|------|
|
| 132 |
+
| Tables | Statistical Distribution | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/complex_tables.png) |
|
| 133 |
+
| Tables | Financial Table | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/tables/financial_table.png) |
|
| 134 |
+
| Forms | Registration Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/handwritten_form.png) |
|
| 135 |
+
| Forms | Lease Form | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/forms/lease_filled.png) |
|
| 136 |
+
| Math | CS229 Textbook | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/cs229.png) |
|
| 137 |
+
| Math | Handwritten Math | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/handwritten_math.png) |
|
| 138 |
+
| Math | Chinese Math | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/math/chinese_math.png) |
|
| 139 |
+
| Handwriting | Cursive Writing | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/cursive_writing.png) |
|
| 140 |
+
| Handwriting | Handwritten Notes | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/handwriting/handwritten_notes.png) |
|
| 141 |
+
| Languages | Arabic | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/arabic.png) |
|
| 142 |
+
| Languages | Japanese | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/japanese.png) |
|
| 143 |
+
| Languages | Hindi | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/hindi.png) |
|
| 144 |
+
| Languages | Russian | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/languages/russian.png) |
|
| 145 |
+
| Other | Charts | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/charts.png) |
|
| 146 |
+
| Other | Chemistry | [View](https://github.com/datalab-to/chandra/blob/master/assets/examples/other/chemistry.png) |
|
| 147 |
+
|
| 148 |
+
|
| 149 |
### Multilingual Benchmark (43 Languages)
|
| 150 |
|
| 151 |
+
This is from our internal multilingual evaluations.
|
| 152 |
+
|
| 153 |
<img src="multilingual.png" width="600px"/>
|
| 154 |
|
| 155 |
| Language | Datalab API | Chandra 2 | Chandra 1 | Gemini 2.5 Flash | GPT-5 Mini |
|
|
|
|
| 161 |
| da | 90.1% | 91.1% | 88.4% | 86.0% | 87.7% |
|
| 162 |
| de | 93.8% | 94.8% | 83.0% | 88.3% | 93.8% |
|
| 163 |
| el | 89.9% | 85.6% | 85.5% | 83.5% | 82.4% |
|
|
|
|
| 164 |
| es | 91.8% | 89.3% | 88.7% | 86.8% | 97.1% |
|
| 165 |
| fa | 82.2% | 75.1% | 69.6% | 61.8% | 56.4% |
|
| 166 |
| fi | 85.7% | 83.4% | 78.4% | 86.0% | 84.7% |
|
|
|
|
| 198 |
| zh | 87.8% | 88.7% | 88.3% | 70.0% | 70.4% |
|
| 199 |
| **Average** | **80.4%** | **77.8%** | **69.4%** | **67.6%** | **60.5%** |
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
## Commercial Usage
|
| 202 |
|
| 203 |
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](https://www.datalab.to/pricing?utm_source=gh-chandra).
|