OCRia-1 — W4A16 Quantized Collection

This repository is part of the W4A16 (4-bit weight, 16-bit activation) quantized release of llamaindex/OCRia-1 (fine-tuned from Qwen/Qwen3.5-4B), quantized using Intel AutoRound (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
Vishva007/OCRia-1-W4A16-GPTQ AutoGPTQ (auto-gptq) vLLM (GPTQ / Marlin kernels), TGI, AutoGPTQ
Vishva007/OCRia-1-W4A16-AutoRound AutoRound (auto-round) vLLM (GPTQ / Marlin kernels), Transformers, AutoRound
Vishva007/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):

vllm serve Vishva007/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 Vishva007/OCRia-1-W4A16-GPTQ with Vishva007/OCRia-1-W4A16-AutoRound or Vishva007/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.

import base64
import re
from huggingface_hub import hf_hub_download
from openai import OpenAI

REPO_ID = "Vishva007/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:
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.


🚀 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 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 Deploy to RunPod
PyTorch 2.15 (CUDA 13.4) 13.4 vishva123/cuda-13.4-pytorch-2.15-runpod 0s0rhdfaqy Deploy to RunPod

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 Deploy to RunPod
PyTorch 2.14 (CUDA 13.0) 13.0 vishva123/cuda-13.0-pytorch-2.14-runpod yk0y6j6rpg Deploy to RunPod
PyTorch 2.14 (CUDA 13.2) 13.2 vishva123/cuda-13.2-pytorch-2.14-runpod gsp4gwx0nw Deploy to RunPod

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 Deploy to RunPod
PyTorch 2.13 (CUDA 13.0) 13.0 vishva123/cuda-13.0-pytorch-2.13-runpod y3j8xvk4f4 Deploy to RunPod
PyTorch 2.13 (CUDA 13.2) 13.2 vishva123/cuda-13.2-pytorch-2.13-runpod vigpissn5w Deploy to RunPod

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 Deploy to RunPod
PyTorch 2.12 (CUDA 13.0) 13.0 vishva123/cuda-13.0-pytorch-2.12-runpod qjko5yiwzi Deploy to RunPod
PyTorch 2.12 (CUDA 13.2) 13.2 vishva123/cuda-13.2-pytorch-2.12-runpod ifg6xmye0f Deploy to RunPod

License & Attribution

This quantized release inherits the OCRia-1 Model and Code License (based on AI Pubs Open RAIL-M) from 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 for commercial licensing.
  • Base Architecture: Fine-tuned from Qwen/Qwen3.5-4B (Apache-2.0).

Citation

@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},
}
Downloads last month
-
Safetensors
Model size
3B params
Tensor type
I32
·
BF16
·
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Vishva007/OCRia-1-W4A16-AutoRound

Finetuned
Qwen/Qwen3.5-4B
Quantized
(9)
this model

Collection including Vishva007/OCRia-1-W4A16-AutoRound

Paper for Vishva007/OCRia-1-W4A16-AutoRound