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)# 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=40) 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 Studio
How to use datalab-to/surya-ocr-2-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for datalab-to/surya-ocr-2-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for datalab-to/surya-ocr-2-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for datalab-to/surya-ocr-2-gguf to start chatting
- Atomic Chat new
- 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
Move 28 demo images into assets/ subfolder
Browse files- README.md +10 -22
- corporate.png β assets/corporate.png +0 -0
- corporate_layout.png β assets/corporate_layout.png +0 -0
- corporate_reading.png β assets/corporate_reading.png +0 -0
- corporate_tablerec.png β assets/corporate_tablerec.png +0 -0
- corporate_text.png β assets/corporate_text.png +0 -0
- excerpt.png β assets/excerpt.png +0 -0
- excerpt_layout.png β assets/excerpt_layout.png +0 -0
- excerpt_text.png β assets/excerpt_text.png +0 -0
- form.png β assets/form.png +0 -0
- form_layout.png β assets/form_layout.png +0 -0
- form_reading.png β assets/form_reading.png +0 -0
- form_tablerec.png β assets/form_tablerec.png +0 -0
- form_text.png β assets/form_text.png +0 -0
- handwritten.png β assets/handwritten.png +0 -0
- handwritten_layout.png β assets/handwritten_layout.png +0 -0
- handwritten_reading.png β assets/handwritten_reading.png +0 -0
- handwritten_tablerec.png β assets/handwritten_tablerec.png +0 -0
- handwritten_text.png β assets/handwritten_text.png +0 -0
- newspaper.png β assets/newspaper.png +0 -0
- newspaper_layout.png β assets/newspaper_layout.png +0 -0
- newspaper_reading.png β assets/newspaper_reading.png +0 -0
- newspaper_text.png β assets/newspaper_text.png +0 -0
- olmocr_size_chart.png β assets/olmocr_size_chart.png +0 -0
- scanned_tablerec.png β assets/scanned_tablerec.png +0 -0
- textbook.png β assets/textbook.png +0 -0
- textbook_layout.png β assets/textbook_layout.png +0 -0
- textbook_reading.png β assets/textbook_reading.png +0 -0
- textbook_text.png β assets/textbook_text.png +0 -0
README.md
CHANGED
|
@@ -1,15 +1,3 @@
|
|
| 1 |
-
---
|
| 2 |
-
library_name: transformers
|
| 3 |
-
license: openrail
|
| 4 |
-
license_link: LICENSE
|
| 5 |
-
tags:
|
| 6 |
-
- ocr
|
| 7 |
-
- pdf
|
| 8 |
-
- markdown
|
| 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,16 +37,16 @@ Commercial self-hosting of the model weights requires a license β see [Commerc
|
|
| 49 |
|
| 50 |
## Model Information
|
| 51 |
|
| 52 |
-
<img src="olmocr_size_chart.png" width="700"/>
|
| 53 |
|
| 54 |
|
| 55 |
| Detection | OCR |
|
| 56 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 57 |
-
| <img src="excerpt.png" width="280"/> | <img src="excerpt_text.png" width="280"/> |
|
| 58 |
|
| 59 |
| Layout | Table Recognition |
|
| 60 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 61 |
-
| <img src="excerpt_layout.png" width="280"/> | <img src="scanned_tablerec.png" width="280"/> |
|
| 62 |
|
| 63 |
|
| 64 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
|
@@ -69,11 +57,11 @@ Each row links to five annotated views of the same page: text-line detection, OC
|
|
| 69 |
|
| 70 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 71 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 72 |
-
| Newspaper | [Image](newspaper.png) | [Image](newspaper_text.png) | [Image](newspaper_layout.png) | [Image](newspaper_reading.png) | |
|
| 73 |
-
| Textbook | [Image](textbook.png) | [Image](textbook_text.png) | [Image](textbook_layout.png) | [Image](textbook_reading.png) | |
|
| 74 |
-
| Tax Form | [Image](form.png) | [Image](form_text.png) | [Image](form_layout.png) | [Image](form_reading.png) | [Image](form_tablerec.png) |
|
| 75 |
-
| Handwritten Notes | [Image](handwritten.png) | [Image](handwritten_text.png) | [Image](handwritten_layout.png) | [Image](handwritten_reading.png) | [Image](handwritten_tablerec.png) |
|
| 76 |
-
| Corporate Doc | [Image](corporate.png) | [Image](corporate_text.png) | [Image](corporate_layout.png) | [Image](corporate_reading.png) | [Image](corporate_tablerec.png) |
|
| 77 |
|
| 78 |
# Commercial usage
|
| 79 |
|
|
@@ -365,7 +353,7 @@ standard quality benchmark for document parsers.
|
|
| 365 |
|
| 366 |
## olmOCR-bench
|
| 367 |
|
| 368 |
-
|
| 369 |
|
| 370 |
| Model | Params | Score |
|
| 371 |
|-----------------------------|----------:|---------:|
|
|
@@ -417,7 +405,7 @@ Top 15 widely-spoken languages:
|
|
| 417 |
| `es` | Spanish | 90.7% |
|
| 418 |
| `vi` | Vietnamese | 73.2% |
|
| 419 |
|
| 420 |
-
See [https://github.com/datalab-to/surya/blob/
|
| 421 |
|
| 422 |
## Throughput
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<h1 align="center">Datalab</h1>
|
| 2 |
<p align="center">
|
| 3 |
<strong>State of the Art models for Document Intelligence</strong>
|
|
|
|
| 37 |
|
| 38 |
## Model Information
|
| 39 |
|
| 40 |
+
<img src="assets/olmocr_size_chart.png" width="700"/>
|
| 41 |
|
| 42 |
|
| 43 |
| Detection | OCR |
|
| 44 |
|:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
|
| 45 |
+
| <img src="assets/excerpt.png" width="280"/> | <img src="assets/excerpt_text.png" width="280"/> |
|
| 46 |
|
| 47 |
| Layout | Table Recognition |
|
| 48 |
|:------------------------------------------------------------------:|:-------------------------------------------------------------:|
|
| 49 |
+
| <img src="assets/excerpt_layout.png" width="280"/> | <img src="assets/scanned_tablerec.png" width="280"/> |
|
| 50 |
|
| 51 |
|
| 52 |
Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
|
|
|
|
| 57 |
|
| 58 |
| Name | Detection | OCR | Layout | Order | Table Rec |
|
| 59 |
|-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
|
| 60 |
+
| Newspaper | [Image](assets/newspaper.png) | [Image](assets/newspaper_text.png) | [Image](assets/newspaper_layout.png) | [Image](assets/newspaper_reading.png) | |
|
| 61 |
+
| Textbook | [Image](assets/textbook.png) | [Image](assets/textbook_text.png) | [Image](assets/textbook_layout.png) | [Image](assets/textbook_reading.png) | |
|
| 62 |
+
| Tax Form | [Image](assets/form.png) | [Image](assets/form_text.png) | [Image](assets/form_layout.png) | [Image](assets/form_reading.png) | [Image](assets/form_tablerec.png) |
|
| 63 |
+
| 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) |
|
| 64 |
+
| 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) |
|
| 65 |
|
| 66 |
# Commercial usage
|
| 67 |
|
|
|
|
| 353 |
|
| 354 |
## olmOCR-bench
|
| 355 |
|
| 356 |
+
Pareto-optimal on the size-vs-score frontier, and best in class under 3B params.
|
| 357 |
|
| 358 |
| Model | Params | Score |
|
| 359 |
|-----------------------------|----------:|---------:|
|
|
|
|
| 405 |
| `es` | Spanish | 90.7% |
|
| 406 |
| `vi` | Vietnamese | 73.2% |
|
| 407 |
|
| 408 |
+
See [https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md](https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md) for the full 91-language table.
|
| 409 |
|
| 410 |
## Throughput
|
| 411 |
|
corporate.png β assets/corporate.png
RENAMED
|
File without changes
|
corporate_layout.png β assets/corporate_layout.png
RENAMED
|
File without changes
|
corporate_reading.png β assets/corporate_reading.png
RENAMED
|
File without changes
|
corporate_tablerec.png β assets/corporate_tablerec.png
RENAMED
|
File without changes
|
corporate_text.png β assets/corporate_text.png
RENAMED
|
File without changes
|
excerpt.png β assets/excerpt.png
RENAMED
|
File without changes
|
excerpt_layout.png β assets/excerpt_layout.png
RENAMED
|
File without changes
|
excerpt_text.png β assets/excerpt_text.png
RENAMED
|
File without changes
|
form.png β assets/form.png
RENAMED
|
File without changes
|
form_layout.png β assets/form_layout.png
RENAMED
|
File without changes
|
form_reading.png β assets/form_reading.png
RENAMED
|
File without changes
|
form_tablerec.png β assets/form_tablerec.png
RENAMED
|
File without changes
|
form_text.png β assets/form_text.png
RENAMED
|
File without changes
|
handwritten.png β assets/handwritten.png
RENAMED
|
File without changes
|
handwritten_layout.png β assets/handwritten_layout.png
RENAMED
|
File without changes
|
handwritten_reading.png β assets/handwritten_reading.png
RENAMED
|
File without changes
|
handwritten_tablerec.png β assets/handwritten_tablerec.png
RENAMED
|
File without changes
|
handwritten_text.png β assets/handwritten_text.png
RENAMED
|
File without changes
|
newspaper.png β assets/newspaper.png
RENAMED
|
File without changes
|
newspaper_layout.png β assets/newspaper_layout.png
RENAMED
|
File without changes
|
newspaper_reading.png β assets/newspaper_reading.png
RENAMED
|
File without changes
|
newspaper_text.png β assets/newspaper_text.png
RENAMED
|
File without changes
|
olmocr_size_chart.png β assets/olmocr_size_chart.png
RENAMED
|
File without changes
|
scanned_tablerec.png β assets/scanned_tablerec.png
RENAMED
|
File without changes
|
textbook.png β assets/textbook.png
RENAMED
|
File without changes
|
textbook_layout.png β assets/textbook_layout.png
RENAMED
|
File without changes
|
textbook_reading.png β assets/textbook_reading.png
RENAMED
|
File without changes
|
textbook_text.png β assets/textbook_text.png
RENAMED
|
File without changes
|