Image-Text-to-Text
Transformers
Joblib
Safetensors
English
qwen3_5
ocr
pdf
markdown
document-parsing
tables
charts
parsebench
autoround
w4a16
gptq
llm-compressor
compressed-tensors
quantized
vllm
conversational
Run this model with HF Jobs
Run OpenTensorLab/OCRia-1-W4A16-LLM-Compressor on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Instructions to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenTensorLab/OCRia-1-W4A16-LLM-Compressor") 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("OpenTensorLab/OCRia-1-W4A16-LLM-Compressor") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", 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
- vLLM
How to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor
- SGLang
How to use OpenTensorLab/OCRia-1-W4A16-LLM-Compressor 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 "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" \ --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": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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 "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor" \ --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": "OpenTensorLab/OCRia-1-W4A16-LLM-Compressor", "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 OpenTensorLab/OCRia-1-W4A16-LLM-Compressor with Docker Model Runner:
docker model run hf.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor
File size: 13,199 Bytes
045917f 549d0dd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | ---
library_name: transformers
pipeline_tag: image-text-to-text
base_model: llamaindex/OCRia-1
base_model_relation: quantized
license: other
license_name: ocria-1-license
license_link: LICENSE
language:
- en
tags:
- ocr
- pdf
- markdown
- document-parsing
- tables
- charts
- parsebench
- autoround
- w4a16
- gptq
- llm-compressor
- compressed-tensors
- quantized
- vllm
---
# OCRia-1 — W4A16 Quantized Collection
This repository is part of the **W4A16 (4-bit weight, 16-bit activation)** quantized release of [llamaindex/OCRia-1](https://huggingface.co/llamaindex/OCRia-1) (fine-tuned from [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B)), quantized using [Intel AutoRound](https://github.com/intel/auto-round) (`SignRoundConfig`) and exported across three standard inference formats for drop-in compatibility with vLLM and Hugging Face Transformers.
All non-weight auxiliary files from the upstream repository—including `prompt.txt`, `ocria_grounding/`, `fast_layout_models/`, `parse_rl_utils/`, `examples/`, and `LICENSE`—are bundled in each repository so layout grounding and prompt templates work out of the box.
## Available Quantized Models
All three repositories share the exact same SignRound-optimized W4A16 calibration weights (`group_size=32`, symmetric) and differ only in their serialization schema:
| Repository | Serialization Format | Target Runtimes & Kernels |
| :--- | :--- | :--- |
| **[OpenTensorLab/OCRia-1-W4A16-GPTQ](https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-GPTQ)** | AutoGPTQ (`auto-gptq`) | vLLM (GPTQ / Marlin kernels), TGI, AutoGPTQ |
| **[OpenTensorLab/OCRia-1-W4A16-AutoRound](https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-AutoRound)** | AutoRound (`auto-round`) | vLLM (GPTQ / Marlin kernels), Transformers, AutoRound |
| **[OpenTensorLab/OCRia-1-W4A16-LLM-Compressor](https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor)** | Compressed-Tensors (`llm-compressor`) | vLLM (Compressed-Tensors / Marlin kernels), Neural Magic |
## Quantization Recipe & Architecture Details
To preserve OCR fidelity, dense table structure, and visual token alignment on the Qwen3.5 hybrid architecture (`GatedDeltaNet` linear attention + full self-attention + Vision Transformer), selective layer preservation was applied during quantization:
* **Algorithm:** Intel AutoRound (`SignRoundConfig` with `iters=1000`, `gradient_accumulate_steps=4`, effective batch size `8`).
* **Precision & Grouping:** `W4A16`, symmetric (`sym=True`), `group_size=32` (compatible with vLLM Marlin/GPTQ kernels).
* **Calibration:** `512` samples at `4096` sequence length (`NeelNanda/pile-10k`).
* **Unquantized Modules (Kept in BF16):**
* **Vision Encoder & Merger (`model.visual.*`):** All 24 vision blocks and the patch merger remain unquantized (`quant_nontext_module=False`) to prevent degradation on small text, formulas, and chart labels.
* **Linear Attention Layers (`linear_attn.*`):** All Qwen3.5 `GatedDeltaNet` recurrent/linear attention projections (`in_proj_qkv`, `in_proj_z`, `in_proj_a`, `in_proj_b`, `out_proj`) are excluded (`ignore_layers`) to maintain numerical stability across long pages.
* **Embeddings & Output Head (`embed_tokens`, `lm_head`):** Preserved in `bfloat16`.
* **Quantized Modules:** Standard self-attention projections (`q_proj`, `k_proj`, `v_proj`, `o_proj`) and MLP layers (`gate_proj`, `up_proj`, `down_proj`) across the language decoder layers.
## Quickstart: Serving with vLLM
Serve any of the three repositories with vLLM (`>= 0.30`). Because Qwen3.5 hybrid layers compile Triton/CUDA kernels on startup, ensure the CUDA toolkit (`nvcc`) is available in your environment (included in `vllm/vllm-openai` images):
```bash
vllm serve OpenTensorLab/OCRia-1-W4A16-GPTQ \
--port 8000 \
--host 0.0.0.0 \
--max-model-len 42k \
--kv-cache-dtype fp8 \
--gpu-memory-utilization 0.90 \
--enable-prefix-caching \
--enable-chunked-prefill \
--trust-remote-code \
--dtype bfloat16 \
--limit-mm-per-prompt '{"image": 1}'
```
*(Replace `OpenTensorLab/OCRia-1-W4A16-GPTQ` with `OpenTensorLab/OCRia-1-W4A16-AutoRound` or `OpenTensorLab/OCRia-1-W4A16-LLM-Compressor` depending on your preferred weight format.)*
### Python Client Inference (OpenAI-Compatible API)
Send one page image per request using the bundled `prompt.txt` as the system message. **Keep thinking disabled** (`enable_thinking: False`) and decode greedily (`temperature=0.0`); the Qwen3.5 chat template enables thinking by default, which breaks OCRia-1's structured Markdown/HTML output format.
```python
import base64
import re
from huggingface_hub import hf_hub_download
from openai import OpenAI
REPO_ID = "OpenTensorLab/OCRia-1-W4A16-GPTQ"
# Load the exact system prompt bundled in this repository
prompt = open(hf_hub_download(REPO_ID, "prompt.txt"), encoding="utf-8").read()
with open("page.png", "rb") as f:
page_b64 = base64.b64encode(f.read()).decode("utf-8")
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
resp = client.chat.completions.create(
model=REPO_ID,
messages=[
{"role": "system", "content": prompt},
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{page_b64}"},
}
],
},
],
temperature=0.0,
max_tokens=24576,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
raw_text = resp.choices[0].message.content
match = re.search(r"```markdown\n(.*?)(?:\n```|$)", raw_text, re.S)
markdown_output = match.group(1) if match else raw_text
print(markdown_output)
```
### Input Preprocessing Guidelines
* **Resolution & Image Budget:** Render PDF pages at 300 DPI (e.g., `page.get_pixmap(dpi=300)` in `pymupdf`) and downscale to ~4.1 megapixels (~210 DPI on US Letter) to match OCRia-1's evaluation profile:
```python
from PIL import Image
img = Image.open("page.png").convert("RGB")
scale = min(1.0, (4_100_000 / (img.width * img.height)) ** 0.5)
img = img.resize((round(img.width * scale), round(img.height * scale)), Image.LANCZOS)
```
* **Token Budget:** Keep `max_tokens=24576` (and `--max-model-len` around `32768`–`42k`) as dense multi-column pages and large HTML financial tables regularly exceed 16k output tokens.
## Model Capabilities & Output Schema
OCRia-1 transcribes a single page image directly into structured Markdown without an external OCR engine:
| Content Type | Output Representation |
| --- | --- |
| **Tables & Charts** | HTML `<table>` with `colspan` / `rowspan` (charts are converted into tables of underlying data points) |
| **Diagrams & Flowcharts** | Fenced ````mermaid` blocks |
| **Mathematics** | Inline `$ ... $` and display `$$ ... $$` LaTeX (including handwritten equations) |
| **Chemical Formulas** | Plain text with HTML `<sub>` and `<sup>` (e.g., `K<sub>3</sub>Fe(CN)<sub>6</sub>`) |
| **Text Formatting** | `**bold**`, `*italic*`, `~~strikethrough~~`, `<u>underline</u>`, `<mark>` highlights |
| **Forms & Checkboxes** | `[ ]`, `[x]`, and `[___]` for blank fill-in fields |
| **Embedded Visuals** | `![label: description]` (`logo`, `icon`, `photo`, `illustration`, `screenshot`, `map`, `signature`, `seal`, `code`, `drawing`, `image`) |
| **Page Furniture** | `<page_header>`, `<page_footer>`, `<page_number>`, and `<watermark>` tags |
## Experimental Layout Grounding (`ocria_grounding`)
All files required for post-generation bounding box extraction (`ocria_grounding/`, `fast_layout_models/`, `parse_rl_utils/`, and `examples/`) are included directly in this repository. For full details on PDF text-layer alignment, Heron layout detection, and `fast-layout` CPU postprocessing, refer to the upstream [llamaindex/OCRia-1 documentation](https://www.google.com/search?q=https://huggingface.co/llamaindex/OCRia-1%23layout-boxes-experimental).
---
### 🚀 Deploy on RunPod
One-click launch environments pre-configured with PyTorch, CUDA, and dependencies for fine-tuning or quantization.
> 🎁 **Need GPU compute?** Sign up via [RunPod](https://runpod.io?ref=iabrlp7z) and get **$5–$500 in free credits** when you add your first $10.
#### PyTorch 2.15
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.15 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.15-runpod` | `0rsw686010` | [](https://runpod.io/console/deploy?template=0rsw686010&ref=iabrlp7z) |
| **PyTorch 2.15 (CUDA 13.4)** | 13.4 | `vishva123/cuda-13.4-pytorch-2.15-runpod` | `0s0rhdfaqy` | [](https://runpod.io/console/deploy?template=0s0rhdfaqy&ref=iabrlp7z) |
#### PyTorch 2.14
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.14 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.14-runpod` | `d7lxsa4w9m` | [](https://runpod.io/console/deploy?template=d7lxsa4w9m&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.14-runpod` | `yk0y6j6rpg` | [](https://runpod.io/console/deploy?template=yk0y6j6rpg&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.14-runpod` | `gsp4gwx0nw` | [](https://runpod.io/console/deploy?template=gsp4gwx0nw&ref=iabrlp7z) |
#### PyTorch 2.13
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.13 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.13-runpod` | `gmlupxnxfk` | [](https://runpod.io/console/deploy?template=gmlupxnxfk&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.13-runpod` | `y3j8xvk4f4` | [](https://runpod.io/console/deploy?template=y3j8xvk4f4&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.13-runpod` | `vigpissn5w` | [](https://runpod.io/console/deploy?template=vigpissn5w&ref=iabrlp7z) |
#### PyTorch 2.12
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.12 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.12-runpod` | `ctmz86zmf0` | [](https://runpod.io/console/deploy?template=ctmz86zmf0&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.12-runpod` | `qjko5yiwzi` | [](https://runpod.io/console/deploy?template=qjko5yiwzi&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.12-runpod` | `ifg6xmye0f` | [](https://runpod.io/console/deploy?template=ifg6xmye0f&ref=iabrlp7z) |
---
## License & Attribution
This quantized release inherits the **[OCRia-1 Model and Code License](https://www.google.com/search?q=LICENSE)** (based on AI Pubs Open RAIL-M) from [llamaindex/OCRia-1](https://huggingface.co/llamaindex/OCRia-1):
* **Research & Personal Use:** Free for academic/non-profit research, benchmarking, internal R&D, and personal use.
* **Commercial Use:** Free for organizations under $2M in annual revenue and under $2M in total funding, provided the model is not used in a document parsing/OCR product or service competing with LlamaParse or LlamaCloud. Contact [LlamaIndex](https://www.llamaindex.ai/contact) for commercial licensing.
* **Base Architecture:** Fine-tuned from [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (Apache-2.0).
### Citation
```bibtex
@misc{rangapur2026ocria1,
title = {{OCRia-1} Technical Report},
author = {Rangapur, Aman and Jimeno Yepes, Antonio and Bustamante, Daniel and Dendumrongsup, Nutchapol and
Acosta, Sebasti{\'a}n G. and Doulcet, Pierre-Lo{\"i}c and Suo, Simon},
year = {2026},
eprint = {2611.00092},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.00092},
}
``` |