Image-Text-to-Text
Transformers
Safetensors
English
Chinese
venusocr
text-generation
ocr
document-parsing
vision-language-model
formula-recognition
table-recognition
speculative-decoding
ptp2
vllm
conversational
custom_code
Instructions to use flow3rdown/VenusOCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use flow3rdown/VenusOCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="flow3rdown/VenusOCR", trust_remote_code=True) 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 AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("flow3rdown/VenusOCR", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use flow3rdown/VenusOCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "flow3rdown/VenusOCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "flow3rdown/VenusOCR", "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/flow3rdown/VenusOCR
- SGLang
How to use flow3rdown/VenusOCR 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 "flow3rdown/VenusOCR" \ --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": "flow3rdown/VenusOCR", "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 "flow3rdown/VenusOCR" \ --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": "flow3rdown/VenusOCR", "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 flow3rdown/VenusOCR with Docker Model Runner:
docker model run hf.co/flow3rdown/VenusOCR
|
Download README.md from flow3rdown/VenusOCR: direct link, hf CLI and curl.
- Browser
- Download file 5.03 kB
-
https://huggingface.co/flow3rdown/VenusOCR/resolve/main/README.md
- Command line
-
hf download hf://flow3rdown/VenusOCR/README.md
-
curl -L -o README.md https://huggingface.co/flow3rdown/VenusOCR/resolve/main/README.md
5.03 kB
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| language: | |
| - en | |
| - zh | |
| tags: | |
| - ocr | |
| - document-parsing | |
| - vision-language-model | |
| - formula-recognition | |
| - table-recognition | |
| - speculative-decoding | |
| - ptp2 | |
| - vllm | |
| <div align="center"> | |
| # VenusOCR 2.0 | |
| ### Towards Efficient and Effective Document Parsing | |
| [](https://github.com/flow3rdown/VenusOCR) | |
| [](https://arxiv.org/pdf/2611.32617) | |
| </div> | |
| **VenusOCR 2.0** is a 1B vision-language OCR model built for high-accuracy document recognition. It supports both standard autoregressive inference and optional **PTPv2** parallel speculative decoding for faster lossless generation. | |
| This repository hosts the **region-level recognition weights**. For full-page PDF/image parsing (layout detection, reading-order recovery, and Markdown export), please use the companion [**VenusOCR SDK**](https://github.com/flow3rdown/VenusOCR). | |
| <div align="center"> | |
| <img src="assets/overview.png" alt="VenusOCR 2.0 Overview" width="100%"> | |
| </div> | |
| ## Highlights | |
| - **Unified Region Recognition:** Recognizes multi-column text, LaTeX mathematical formulas, and complex tables. | |
| - **Compact & Fast:** Lightweight 1B-class recognizer designed for efficient single-GPU deployment. | |
| - **Optional PTPv2 Acceleration:** Bundled parallel draft module (`ptp2/`) enables lossless speedup in vLLM serving. | |
| ## Architecture | |
| <div align="center"> | |
| <img src="assets/architecture.png" alt="VenusOCR 2.0 Architecture" width="100%"> | |
| </div> | |
| ## Usage | |
| ### 1. Transformers Inference | |
| Install dependencies (pinned `transformers==5.5.4` is recommended): | |
| ```bash | |
| pip install transformers==5.5.4 | |
| ``` | |
| Run quick inference on a cropped document region image: | |
| ```bash | |
| python scripts/infer_transformers.py --image /path/to/region.png --task text | |
| ``` | |
| Or load directly in Python: | |
| ```python | |
| import torch | |
| from PIL import Image | |
| from transformers import AutoModelForCausalLM, AutoProcessor | |
| model_path = "./VenusOCR2-1B" | |
| processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_path, | |
| dtype=torch.bfloat16, | |
| attn_implementation="sdpa", | |
| trust_remote_code=True, | |
| ).to("cuda:0").eval() | |
| image = Image.open("/path/to/region.png").convert("RGB") | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| {"type": "image"}, | |
| {"type": "text", "text": "Text Recognition:"}, | |
| ], | |
| } | |
| ] | |
| prompt = processor.apply_chat_template( | |
| messages, tokenize=False, add_generation_prompt=True | |
| ) | |
| inputs = processor(images=image, text=prompt, return_tensors="pt").to(model.device) | |
| with torch.inference_mode(): | |
| output_ids = model.generate(**inputs, max_new_tokens=2048, do_sample=False) | |
| generated_ids = output_ids[:, inputs["input_ids"].shape[1]:] | |
| print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0]) | |
| ``` | |
| #### Task Prompts | |
| | Task | Prompt | Output Format | | |
| | --- | --- | --- | | |
| | Text | `Text Recognition:` | Plain text / Markdown | | |
| | Formula | `Formula Recognition:` | LaTeX | | |
| | Table | `Table Recognition:` | OTSL structure | | |
| ### 2. vLLM | |
| #### Standard Mode (AR) | |
| If you have the [VenusOCR SDK](https://github.com/flow3rdown/VenusOCR) installed, launch the OpenAI-compatible server directly: | |
| ```bash | |
| venusocr serve ./VenusOCR2-1B --host 127.0.0.1 --port 8000 | |
| ``` | |
| Or launch standalone without the SDK (using `vllm==0.20.0` and `transformers==5.5.4`): | |
| ```bash | |
| pip install "vllm==0.20.0" "transformers==5.5.4" | |
| bash scripts/patch_vllm_v0_20_ptp2.sh | |
| USE_PTP2=0 HOST=127.0.0.1 PORT=8000 bash scripts/vllm_serve_ptp2.sh | |
| ``` | |
| #### Accelerated Mode (Optional PTPv2) | |
| With the vLLM patch applied (`bash scripts/patch_vllm_v0_20_ptp2.sh --reverse` to undo): | |
| ```bash | |
| HOST=127.0.0.1 PORT=8000 bash scripts/vllm_serve_ptp2.sh | |
| ``` | |
| Common environment overrides: `CUDA_VISIBLE_DEVICES`, `HOST`, `PORT`, `USE_PTP2` (`1` by default, `0` for AR), `GPU_MEMORY_UTILIZATION`, `MAX_MODEL_LEN`, `MAX_NUM_SEQS`. | |
| ### 4. End-to-End Document Parsing | |
| For full-page PDF and image parsing (layout detection, reading order, and Markdown export), use the [VenusOCR SDK](https://github.com/flow3rdown/VenusOCR): | |
| ```bash | |
| git clone https://github.com/flow3rdown/VenusOCR.git | |
| cd VenusOCR | |
| pip install -e '.[transformers,serve]' | |
| venusocr parse document.pdf -o ./output --server-url http://127.0.0.1:8000/v1 | |
| ``` | |
| ## Citation | |
| If you find VenusOCR 2.0 useful in your research or applications, please consider citing: | |
| ```bibtex | |
| @misc{venusocr2026, | |
| title={VenusOCR2.0: Towards Efficient and Effective Document Parsing}, | |
| author={Lei Li and Zheng Wei and Yi Yuan and Qingbin Liu and Jiang Bian and Zang Li}, | |
| year={2026}, | |
| eprint={2611.32617}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.CV}, | |
| url={https://arxiv.org/abs/2611.32617} | |
| } | |
| ``` | |
| ## Acknowledgements | |
| We thank the SigLIP2, Qwen3, PaddleOCR / PP-DocLayoutV3, vLLM, and OmniDocBench communities. | |