Instructions to use datalab-to/surya-ocr-2-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use datalab-to/surya-ocr-2-gguf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="datalab-to/surya-ocr-2-gguf") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("datalab-to/surya-ocr-2-gguf") model = AutoModelForMultimodalLM.from_pretrained("datalab-to/surya-ocr-2-gguf", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use datalab-to/surya-ocr-2-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf datalab-to/surya-ocr-2-gguf # Run inference directly in the terminal: llama cli -hf datalab-to/surya-ocr-2-gguf
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf datalab-to/surya-ocr-2-gguf # Run inference directly in the terminal: llama cli -hf datalab-to/surya-ocr-2-gguf
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf datalab-to/surya-ocr-2-gguf # Run inference directly in the terminal: ./llama-cli -hf datalab-to/surya-ocr-2-gguf
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf datalab-to/surya-ocr-2-gguf # Run inference directly in the terminal: ./build/bin/llama-cli -hf datalab-to/surya-ocr-2-gguf
Use Docker
docker model run hf.co/datalab-to/surya-ocr-2-gguf
- LM Studio
- Jan
- vLLM
How to use datalab-to/surya-ocr-2-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "datalab-to/surya-ocr-2-gguf" # 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/surya-ocr-2-gguf", "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/surya-ocr-2-gguf
- SGLang
How to use datalab-to/surya-ocr-2-gguf 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/surya-ocr-2-gguf" \ --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/surya-ocr-2-gguf", "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/surya-ocr-2-gguf" \ --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/surya-ocr-2-gguf", "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" } } ] } ] }' - Ollama
How to use datalab-to/surya-ocr-2-gguf with Ollama:
ollama run hf.co/datalab-to/surya-ocr-2-gguf
- Unsloth Desktop
- Docker Model Runner
How to use datalab-to/surya-ocr-2-gguf with Docker Model Runner:
docker model run hf.co/datalab-to/surya-ocr-2-gguf
- Lemonade
How to use datalab-to/surya-ocr-2-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull datalab-to/surya-ocr-2-gguf
Run and chat with the model
lemonade run user.surya-ocr-2-gguf-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -9,7 +9,6 @@ tags:
|
|
| 9 |
- layout
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
| 13 |
<h1 align="center">Datalab</h1>
|
| 14 |
<p align="center">
|
| 15 |
<strong>State of the Art models for Document Intelligence</strong>
|
|
@@ -49,19 +48,17 @@ Commercial self-hosting of the model weights requires a license — see [Commerc
|
|
| 49 |
|
| 50 |
| Detection | OCR |
|
| 51 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 52 |
-
| <img src="assets/excerpt.png" width="
|
| 53 |
|
| 54 |
| Layout | Table Recognition |
|
| 55 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 56 |
-
| <img src="assets/excerpt_layout.png" width="
|
| 57 |
|
| 58 |
|
| 59 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
| 60 |
|
| 61 |
## Examples
|
| 62 |
|
| 63 |
-
Each row links to five annotated views of the same page: text-line detection, OCR, layout, reading order, and (when present) table recognition.
|
| 64 |
-
|
| 65 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 66 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 67 |
| Newspaper | [Image](assets/newspaper.png) | [Image](assets/newspaper_text.png) | [Image](assets/newspaper_layout.png) | [Image](assets/newspaper_reading.png) | |
|
|
@@ -70,10 +67,6 @@ Each row links to five annotated views of the same page: text-line detection, OC
|
|
| 70 |
| Handwritten Notes | [Image](assets/handwritten.png) | [Image](assets/handwritten_text.png) | [Image](assets/handwritten_layout.png) | [Image](assets/handwritten_reading.png) | [Image](assets/handwritten_tablerec.png) |
|
| 71 |
| Corporate Doc | [Image](assets/corporate.png) | [Image](assets/corporate_text.png) | [Image](assets/corporate_layout.png) | [Image](assets/corporate_reading.png) | [Image](assets/corporate_tablerec.png) |
|
| 72 |
|
| 73 |
-
# Commercial usage
|
| 74 |
-
|
| 75 |
-
The Surya code is licensed under Apache 2.0. The model weights use a modified AI Pubs Open Rail-M license (free for research, personal use, and startups under $5M funding/revenue). For broader commercial licensing of the model weights, visit our pricing page [here](https://www.datalab.to/pricing?utm_source=gh-surya).
|
| 76 |
-
|
| 77 |
# Installation
|
| 78 |
|
| 79 |
Install with:
|
|
@@ -82,24 +75,6 @@ Install with:
|
|
| 82 |
pip install surya-ocr
|
| 83 |
```
|
| 84 |
|
| 85 |
-
## Upgrading from Surya v1
|
| 86 |
-
|
| 87 |
-
If you have v1 code, you can migrate to this:
|
| 88 |
-
|
| 89 |
-
```python
|
| 90 |
-
# v2
|
| 91 |
-
from surya.inference import SuryaInferenceManager
|
| 92 |
-
from surya.recognition import RecognitionPredictor
|
| 93 |
-
|
| 94 |
-
manager = SuryaInferenceManager() # auto-spawns vllm or llama-server
|
| 95 |
-
rec = RecognitionPredictor(manager)
|
| 96 |
-
predictions = rec([image])
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
-
What's different:
|
| 100 |
-
- `SuryaInferenceManager` replaces `FoundationPredictor`. Same manager instance is shared across `LayoutPredictor`, `RecognitionPredictor`, `TableRecPredictor`.
|
| 101 |
-
- Output schemas changed: see the per-section JSON tables below. Highlights — `text_lines` → `blocks` (with `html`); layout dropped `top_k`, added `count`; table_rec dropped `is_header` / `colspan` / `rowspan` from cells.
|
| 102 |
-
|
| 103 |
# Usage
|
| 104 |
|
| 105 |
Surya 2 runs layout, OCR, and table recognition through a single VLM served
|
|
@@ -360,7 +335,7 @@ standard quality benchmark for document parsers.
|
|
| 360 |
|
| 361 |
## olmOCR-bench
|
| 362 |
|
| 363 |
-
Pareto-optimal
|
| 364 |
|
| 365 |
| Model | Params | Score |
|
| 366 |
|-----------------------------|----------:|---------:|
|
|
|
|
| 9 |
- layout
|
| 10 |
---
|
| 11 |
|
|
|
|
| 12 |
<h1 align="center">Datalab</h1>
|
| 13 |
<p align="center">
|
| 14 |
<strong>State of the Art models for Document Intelligence</strong>
|
|
|
|
| 48 |
|
| 49 |
| Detection | OCR |
|
| 50 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 51 |
+
| <img src="assets/excerpt.png" width="140"/> | <img src="assets/excerpt_text.png" width="140"/> |
|
| 52 |
|
| 53 |
| Layout | Table Recognition |
|
| 54 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 55 |
+
| <img src="assets/excerpt_layout.png" width="140"/> | <img src="assets/scanned_tablerec.png" width="140"/> |
|
| 56 |
|
| 57 |
|
| 58 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
| 59 |
|
| 60 |
## Examples
|
| 61 |
|
|
|
|
|
|
|
| 62 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 63 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 64 |
| Newspaper | [Image](assets/newspaper.png) | [Image](assets/newspaper_text.png) | [Image](assets/newspaper_layout.png) | [Image](assets/newspaper_reading.png) | |
|
|
|
|
| 67 |
| Handwritten Notes | [Image](assets/handwritten.png) | [Image](assets/handwritten_text.png) | [Image](assets/handwritten_layout.png) | [Image](assets/handwritten_reading.png) | [Image](assets/handwritten_tablerec.png) |
|
| 68 |
| Corporate Doc | [Image](assets/corporate.png) | [Image](assets/corporate_text.png) | [Image](assets/corporate_layout.png) | [Image](assets/corporate_reading.png) | [Image](assets/corporate_tablerec.png) |
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
# Installation
|
| 71 |
|
| 72 |
Install with:
|
|
|
|
| 75 |
pip install surya-ocr
|
| 76 |
```
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Usage
|
| 79 |
|
| 80 |
Surya 2 runs layout, OCR, and table recognition through a single VLM served
|
|
|
|
| 335 |
|
| 336 |
## olmOCR-bench
|
| 337 |
|
| 338 |
+
Pareto-optimal, and best in class under 3B params.
|
| 339 |
|
| 340 |
| Model | Params | Score |
|
| 341 |
|-----------------------------|----------:|---------:|
|