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/align.py from OpenTensorLab/OCRia-1-W4A16-LLM-Compressor: direct link, hf CLI and curl.
- Browser
- Download file 5.28 kB
-
https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/ocria_grounding/align.py
- Command line
-
hf download hf://OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/ocria_grounding/align.py
-
curl -L -o align.py https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/ocria_grounding/align.py
5.28 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. | |
| """Answer words -> PDF word boxes, by character-level alignment of the answer with the page's text layer. | |
| PDF text layers split words (kerning), merge them, and store columns and sidebars in another order than the answer. | |
| The answer and the PDF text are folded to lowercase alphanumerics and aligned in order; then each long unmatched run | |
| of the answer is aligned against the PDF text not used yet, in any order, but only where that text is unique on the | |
| page (a header repeated in several tables would otherwise be matched to the wrong copy).""" | |
| import difflib | |
| import unicodedata | |
| def _fold(ch): | |
| ch = unicodedata.normalize("NFKC", ch).lower() | |
| return "".join(c for c in ch if c.isalnum()) | |
| def pdf_chars(words): | |
| """Flatten PDF words into (char, box) with each word's box split evenly across its folded chars.""" | |
| out = [] | |
| for w in words: | |
| t = "".join(_fold(c) for c in w["text"]) | |
| if not t: | |
| continue | |
| x0, y0, x1, y1 = w["box"]; n = len(t); dx = (x1 - x0) / n | |
| for k, c in enumerate(t): | |
| out.append((c, [x0 + k * dx, y0, x0 + (k + 1) * dx, y1])) | |
| return out | |
| def unit_boxes(answer, units, words, min_share=0.6, min_block=3): | |
| pc = pdf_chars(words) | |
| if not pc: | |
| return {} | |
| ps = "".join(c for c, _ in pc) | |
| achars, owner = [], [] | |
| for u, (s, e) in enumerate(units): | |
| for ch in answer[s:e]: | |
| f = _fold(ch) | |
| for c in f: | |
| achars.append(c); owner.append(u) | |
| a = "".join(achars) | |
| sm = difflib.SequenceMatcher(None, a, ps, autojunk=False) | |
| hit = {} | |
| for m in sm.get_matching_blocks(): | |
| if m.size < min_block: | |
| continue | |
| for k in range(m.size): | |
| hit.setdefault(owner[m.a + k], []).append(pc[m.b + k][1]) | |
| n_by_unit = {} | |
| for u in owner: | |
| n_by_unit[u] = n_by_unit.get(u, 0) + 1 | |
| out = {} | |
| for u, bs in hit.items(): | |
| if len(bs) < min_share * n_by_unit[u]: | |
| continue | |
| # keep the chars on the line of the median char (a word never spans lines) | |
| ys = sorted((b[1] + b[3]) / 2 for b in bs); ym = ys[len(ys) // 2] | |
| h = sorted(b[3] - b[1] for b in bs)[len(bs) // 2] | |
| bs = [b for b in bs if abs((b[1] + b[3]) / 2 - ym) <= 0.6 * h] | |
| out[u] = [min(b[0] for b in bs), min(b[1] for b in bs), max(b[2] for b in bs), max(b[3] for b in bs)] | |
| return out | |
| def unit_boxes_multi(answer, units, words, min_share=0.6, min_block=4, seg_min=8, passes=3, unique=True): | |
| """unit_boxes plus out-of-order passes: each long run of unmatched answer chars is aligned against the PDF chars | |
| not used yet (used ones masked), so columns / sidebars the PDF stores in another order still get boxes.""" | |
| pc = pdf_chars(words) | |
| if not pc: | |
| return {} | |
| pchars = [c for c, _ in pc] | |
| achars, owner = [], [] | |
| for u, (s, e) in enumerate(units): | |
| for ch in answer[s:e]: | |
| for c in _fold(ch): | |
| achars.append(c); owner.append(u) | |
| amatch = [None] * len(achars); pused = [False] * len(pchars) | |
| full = "".join(pchars) | |
| def align(a_lo, a_hi, out_of_order=False): | |
| a = "".join(achars[a_lo:a_hi]) | |
| p = "".join(c if not pused[k] else "\x00" for k, c in enumerate(pchars)) | |
| sm = difflib.SequenceMatcher(None, a, p, autojunk=False) | |
| for m in sm.get_matching_blocks(): | |
| if m.size < (max(min_block, 8) if out_of_order and unique else min_block): | |
| continue | |
| if out_of_order and unique and full.count(a[m.a:m.a + m.size]) > 1: | |
| continue # repeated text (same header in several tables): the out-of-order pass cannot tell which | |
| for k in range(m.size): | |
| if amatch[a_lo + m.a + k] is None and not pused[m.b + k]: | |
| amatch[a_lo + m.a + k] = m.b + k; pused[m.b + k] = True | |
| align(0, len(achars)) | |
| for _ in range(passes): | |
| segs, k = [], 0 | |
| while k < len(achars): | |
| if amatch[k] is None: | |
| j = k | |
| while j < len(achars) and amatch[j] is None: | |
| j += 1 | |
| if j - k >= seg_min: | |
| segs.append((k, j)) | |
| k = j | |
| else: | |
| k += 1 | |
| if not segs: | |
| break | |
| for lo, hi in sorted(segs, key=lambda x: x[0] - x[1]): | |
| align(lo, hi, out_of_order=True) | |
| hit = {} | |
| for i, b in enumerate(amatch): | |
| if b is not None: | |
| hit.setdefault(owner[i], []).append(pc[b][1]) | |
| n_by_unit = {} | |
| for u in owner: | |
| n_by_unit[u] = n_by_unit.get(u, 0) + 1 | |
| out = {} | |
| for u, bs in hit.items(): | |
| if len(bs) < min_share * n_by_unit[u]: | |
| continue | |
| ys = sorted((b[1] + b[3]) / 2 for b in bs); ym = ys[len(ys) // 2] | |
| h = sorted(b[3] - b[1] for b in bs)[len(bs) // 2] | |
| bs = [b for b in bs if abs((b[1] + b[3]) / 2 - ym) <= 0.6 * h] | |
| out[u] = [min(b[0] for b in bs), min(b[1] for b in bs), max(b[2] for b in bs), max(b[3] for b in bs)] | |
| return out | |