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
Download ocria_grounding/__init__.py from OpenTensorLab/OCRia-1-W4A16-LLM-Compressor: direct link, hf CLI and curl.
- Browser
- Download file 4.25 kB
-
https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/ocria_grounding/__init__.py
- Command line
-
hf download hf://OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/ocria_grounding/__init__.py
-
curl -L -o __init__.py https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/ocria_grounding/__init__.py
4.25 kB
| # Copyright (c) 2026 LlamaIndex, Inc. All rights reserved. | |
| # Licensed under the OCRia-1 Model and Code License (LICENSE at the root of this repository). | |
| # This is not open-source software: see the license for permitted uses. | |
| """Layout boxes for OCRia-1 answers (experimental). | |
| OCRia-1 writes markdown without boxes. This package places that markdown on the page: | |
| 1. A layout detector (Docling's Heron, Apache-2.0, downloaded from its own repository) finds the page's regions. | |
| 2. Every word of the answer gets a position: its PDF word box when the page has a text layer, else the ink its | |
| attention points at, read from a second, teacher-forced pass of the same weights over the page and the answer. | |
| 3. Each region becomes an item holding the answer's words that fall in it. | |
| from ocria_grounding import load, load_detector, transcribe, ground_layout, render_pdf_page | |
| g, det = load(), load_detector() # OCRia-1 (CUDA) and Heron (cuda, else mps, else cpu) | |
| image, words = render_pdf_page("doc.pdf", 0) # 300-DPI page + its text-layer words (omit for image inputs) | |
| answer = transcribe(g, image) # or the raw answer from any other server (vLLM, ...) | |
| page = ground_layout(g, image, answer, detector=det, words=words) | |
| # {width, height, items: [{type, label, md, box: [x0, y0, x1, y1], start}]}, boxes in pixels of `image` | |
| Pass exactly the image and system prompt the answer was generated with. `to_layout_items_page` serializes the result | |
| as a ParseBench layout page. Without a detector, `ground_layout` (and the older `ground_page`) fall back to boxes | |
| from attention alone, which are much less accurate. | |
| """ | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from .detector import DETECTOR, Detector | |
| from .ground import ground_page, to_box_markdown, to_layout_page | |
| from .heads import heads_for | |
| from .layout import ground_layout, to_layout_items_page | |
| from .pdf import render_pdf_page | |
| MODEL = "llamaindex/OCRia-1" | |
| __all__ = ["load_fast_layout", "MODEL", "DETECTOR", "load", "load_detector", "transcribe", "ground_layout", "to_layout_items_page", | |
| "render_pdf_page", "Detector", "ground_page", "to_box_markdown", "to_layout_page", "heads_for"] | |
| def load_detector(model: str = DETECTOR, device: str | None = None) -> Detector: | |
| """Docling's Heron layout detector (Apache-2.0, a separate download from its own repository).""" | |
| return Detector(model, device) | |
| def load(model: str = MODEL, device: str = "cuda", heads=None, system_prompt: str | None = None): | |
| """A Grounder for OCRia-1: `model` is the repo id or a local copy of it; the heads and the system prompt default | |
| to the ones shipped in this repository (prompt.txt).""" | |
| from .capture import Grounder | |
| if system_prompt is None: | |
| local = Path(__file__).resolve().parent.parent / "prompt.txt" | |
| if not local.exists(): | |
| from huggingface_hub import hf_hub_download | |
| local = Path(hf_hub_download(MODEL, "prompt.txt")) | |
| system_prompt = local.read_text() | |
| return Grounder(model, heads or heads_for(MODEL), system_prompt, device) | |
| def transcribe(grounder, image, max_new_tokens: int = 24576) -> str: | |
| """OCRia-1's raw answer for one page image (greedy), from the grounder's own model, so one model load serves both | |
| the transcription and the boxes. For throughput, transcribe with vLLM instead and pass its raw answer.""" | |
| import torch | |
| enc = grounder.proc(text=[grounder.prompt], images=[image.convert("RGB")], return_tensors="pt").to(grounder.device) | |
| with torch.no_grad(): | |
| ids = grounder.model.generate(**enc, max_new_tokens=max_new_tokens, do_sample=False) | |
| return grounder.proc.decode(ids[0, enc["input_ids"].shape[1]:], skip_special_tokens=True) | |
| def load_fast_layout(model_dir: str | Path | None = None): | |
| """Load the five trusted frozen layout artifacts once, without GPU or downloads.""" | |
| from parse_rl_utils.ocria_attention_grounding.api import FastLayout | |
| directory = Path(model_dir) if model_dir else Path(__file__).resolve().parent.parent / "fast_layout_models" | |
| return FastLayout(**{key: directory / f"{key}.joblib" | |
| for key in ("words", "pictures", "regions", "tables", "peaks")}) | |