Image-Text-to-Text
Transformers
Safetensors
qwen3_5
ocr
document-understanding
visual-grounding
vision-language
auto-round
int4
w4a16
tables
forms
quantized
conversational
4-bit precision
Run this model with HF Jobs
Run OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound 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/LightOnOCR-3-4B-W4A16-AutoRound. 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/LightOnOCR-3-4B-W4A16-AutoRound 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/LightOnOCR-3-4B-W4A16-AutoRound. 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/LightOnOCR-3-4B-W4A16-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound") 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/LightOnOCR-3-4B-W4A16-AutoRound") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound", 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/LightOnOCR-3-4B-W4A16-AutoRound with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound" # 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/LightOnOCR-3-4B-W4A16-AutoRound", "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/LightOnOCR-3-4B-W4A16-AutoRound
- SGLang
How to use OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound 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/LightOnOCR-3-4B-W4A16-AutoRound" \ --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/LightOnOCR-3-4B-W4A16-AutoRound", "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/LightOnOCR-3-4B-W4A16-AutoRound" \ --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/LightOnOCR-3-4B-W4A16-AutoRound", "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/LightOnOCR-3-4B-W4A16-AutoRound with Docker Model Runner:
docker model run hf.co/OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound
File size: 10,338 Bytes
8b30382 | 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 | ---
base_model: lightonai/LightOnOCR-3-4B
library_name: transformers
tags:
- ocr
- document-understanding
- visual-grounding
- vision-language
- auto-round
- int4
- w4a16
- tables
- forms
- quantized
pipeline_tag: image-text-to-text
license: apache-2.0
---
# LightOnOCR-3-4B — W4A16 Quantized (AutoRound)
This repository provides an INT4 quantized version of [lightonai/LightOnOCR-3-4B](https://huggingface.co/lightonai/LightOnOCR-3-4B) using [Intel AutoRound](https://github.com/intel/auto-round) with high-fidelity production settings.
`LightOnOCR-3-4B` is an end-to-end vision-language model based on the Qwen3.5 architecture tailored for high-accuracy document transcription, layout understanding, visual grounding, and structured figure extraction.
---
## Quantization Details
| Parameter | Configuration | Details |
| :--- | :--- | :--- |
| **Quantization Scheme** | `W4A16` | Weights INT4, Activations BF16 |
| **Group Size** | `32` | Enhanced accuracy per weight block |
| **Symmetry** | `Symmetric` (`sym=True`) | Standard high-throughput configuration |
| **Iterations** | `1200` | Production-grade fine-grained optimization |
| **Calibration Samples** | `512` samples (`seqlen=4096`) | Broad domain calibration coverage |
| **Vision Preservation** | `quant_nontext_module=False` | **Vision tower & multimodal projector kept in BF16** to prevent OCR/grounding degradation |
### Sibling Repositories & Formats
Choose the backend format suited to your inference engine:
- **AutoRound Native / Transformers:** [`OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound`](https://huggingface.co/OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound)
- **AutoGPTQ / Marlin:** [`OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-GPTQ`](https://huggingface.co/OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-GPTQ)
- **vLLM / Compressed Tensors:** [`OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-LLM-Compressor`](https://huggingface.co/OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-LLM-Compressor)
---
## Operating Modes
LightOnOCR-3 operates in two primary modes:
1. **Plain Transcription Mode (`prompt = ""`):** Transcribes text directly to Markdown layout without bounding boxes.
2. **Grounding Mode (`prompt = "grounding"`):** Outputs normalized bounding boxes `[0, 1000]` and semantic labels (`text`, `title`, `table`, `image`, `chart`, etc.) for each document component.
---
## Quickstart
### 1. Python Inference via Transformers
```bash
pip install --upgrade "transformers>=5.5.4" auto-round pillow torchvision
```
```python
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
# Swap repo_id with your target variant:
model_id = "OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Set image URL or local path
image_url = "[https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg](https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg)"
# Use "grounding" or "" (for transcription only)
prompt = "grounding"
content = [{"type": "image", "url": image_url}]
if prompt:
content.append({"type": "text", "text": prompt})
conversation = [{"role": "user", "content": content}]
inputs = processor.apply_chat_template(
conversation,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
enable_thinking=False, # LightOnOCR is optimized with thinking disabled
).to(model.device)
with torch.inference_mode():
output_ids = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
generated_ids = output_ids[0, inputs["input_ids"].shape[1]:]
print(processor.decode(generated_ids, skip_special_tokens=True))
```
---
### 2. High-Throughput Serving with vLLM
*(Recommended using `OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-LLM-Compressor` or `OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound-GPTQ`)*
#### Start Server
```bash
vllm serve OpenTensorLab/OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound \
--trust-remote-code \
--dtype bfloat16 \
--max-model-len 8192 \
--default-chat-template-kwargs '{"enable_thinking": false}'
```
#### Query Server
```python
import requests
url = "http://localhost:8000/v1/chat/completions"
image_url = "[https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg](https://huggingface.co/datasets/hf-internal-testing/fixtures_ocr/resolve/main/SROIE-receipt.jpeg)"
payload = {
"model": "OpenTensorLab/LightOnOCR-3-4B-W4A16-AutoRound",
"messages": [
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": image_url}},
{"type": "text", "text": "grounding"}
]
}
],
"max_tokens": 2048,
"temperature": 0.0
}
response = requests.post(url, json=payload)
print(response.json()["choices"][0]["message"]["content"])
```
---
## Best Practices for Document Preprocessing
* **Resolution:** Render scanned documents and PDFs at **400 DPI** using a target longest dimension of **2048px**.
* **Aspect Ratio:** Maintain the native aspect ratio when resizing; do not stretch images, as bounding box coordinate accuracy depends on geometric integrity.
* **Thinking Tokens:** Ensure `enable_thinking=False` is preserved in chat templates during generation.
---
### 🚀 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) |
---
## Citation & Acknowledgements
Quantized using [Intel AutoRound](https://github.com/intel/auto-round). Base model created and released by [LightOn AI](https://huggingface.co/lightonai).
```bibtex
@misc{lightonocr2_2026,
title = {LightOnOCR: A 1B End-to-End Multilingual Vision-Language Model for State-of-the-Art OCR},
author = {Said Taghadouini and Adrien Cavaill\`{e}s and Baptiste Aubertin},
year = {2026},
howpublished = {\url{[https://arxiv.org/abs/2601.14251](https://arxiv.org/abs/2601.14251)}}
}
@article{cheng2023optimize,
title={Optimize Weight Rounding via Signed Gradient Descent for Large Language Model Quantization},
author={Cheng, Wenhua and Hai, Wei and Shen, Haihao and others},
journal={arXiv preprint arXiv:2309.05516},
year={2023}
}
```
|