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
Eval Results
4-bit precision
auto-round
Run this model with HF Jobs
Run OpenTensorLab/OCRia-1-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/OCRia-1-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/OCRia-1-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/OCRia-1-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/OCRia-1-W4A16-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/OCRia-1-W4A16-AutoRound 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-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/OCRia-1-W4A16-AutoRound") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/OCRia-1-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/OCRia-1-W4A16-AutoRound 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-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/OCRia-1-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/OCRia-1-W4A16-AutoRound
- SGLang
How to use OpenTensorLab/OCRia-1-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/OCRia-1-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/OCRia-1-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/OCRia-1-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/OCRia-1-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/OCRia-1-W4A16-AutoRound with Docker Model Runner:
docker model run hf.co/OpenTensorLab/OCRia-1-W4A16-AutoRound
File size: 6,018 Bytes
90d9faa | 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 | # 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.
"""Typography, shared-line profiles, and sparse support beyond the local patch."""
from .rust import get_rust
import numpy as np
from .blocks import Block
from .native import get_native
_BLOCK_TYPES = (
"text",
"list",
"heading",
"header",
"footer",
"page_number",
"table",
"image",
"code",
"formula",
)
def extended_features(
answer: str,
units: list[tuple[int, int]],
blocks: list[Block],
per_block: list[list[int]],
features: np.ndarray,
valid: list[int],
peaks: np.ndarray,
sparse: dict,
grid: tuple[int, int],
) -> np.ndarray:
"""Append 51 features to the 53-feature context representation.
Nearby word profiles share the current word's grid-row frame. Full-support
quantiles and threshold extents retain evidence beyond the local 5x5 patch.
All offsets use grid cells; no annotation or page-image input is accepted.
"""
gh, gw = grid
owners = {u: k for k, indices in enumerate(per_block) for u in indices}
lookup = {u: j for j, u in enumerate(valid)}
positions = np.full((len(units), 2), np.nan)
positions[valid] = peaks
# Each word profile is shared by up to 24 neighbors; normalize it once.
profiles = features[:, 9:34].reshape(-1, 5, 5).sum(2)
profiles /= np.maximum(profiles.sum(1), 1e-12)[:, None]
native = get_native()
pooled_profiles = (
native.pool_profiles(positions, owners, valid, profiles)
if native is not None
else None
)
rust = get_rust()
stats, packed = (
rust.context_bounds(sparse, valid, peaks, gw)
if rust is not None
else (None, None)
)
mass_stats = None
if packed:
masses = np.concatenate([row[2] for row in packed])
starts = np.r_[
0, np.cumsum([len(row[2]) for row in packed[:-1]], dtype=np.intp)
]
mass_stats = np.column_stack(
[
np.maximum.reduceat(masses, starts),
-np.add.reduceat(masses * np.log(np.maximum(masses, 1e-12)), starts),
]
)
block_types = [
[float(block.type == kind) for kind in _BLOCK_TYPES] for block in blocks
]
typography: dict[str, list[float]] = {}
extras = []
for row, u in enumerate(valid):
owner = owners[u]
word = answer[units[u][0] : units[u][1]]
glyphs = typography.get(word)
if glyphs is None:
length = max(1, len(word))
glyphs = [
sum(c.isupper() for c in word) / length,
sum(c.isdigit() for c in word) / length,
sum(
"\u2e80" <= c <= "\u9fff" or "\uac00" <= c <= "\ud7af" for c in word
)
/ length,
sum(c in "iljtf1" for c in word) / length,
sum(c.lower() in "mw" for c in word) / length,
]
typography[word] = glyphs
px, py = peaks[row]
values = block_types[owner] + glyphs
values.extend(
[
px / gw,
py / gh,
len(per_block[owner]),
(u - per_block[owner][0]) / max(1, len(per_block[owner]) - 1),
]
)
if pooled_profiles is not None:
values.extend(pooled_profiles[row].tolist())
else:
pooled = np.zeros(7)
count = 0
for neighbor in range(max(0, u - 12), min(len(units), u + 13)):
if (
neighbor == u
or owners.get(neighbor) != owner
or neighbor not in lookup
or abs(positions[neighbor, 1] - py) > 1
):
continue
profile = profiles[lookup[neighbor]]
offset = int(round(positions[neighbor, 1] - py))
pooled[1 + offset : 6 + offset] += profile
count += 1
if count:
pooled /= count
values.extend([*pooled.tolist(), count])
if stats is not None:
_, attention, mass = packed[row]
values.extend(stats[row].tolist())
else:
indices = np.asarray(sparse["idx"][u])
attention = np.asarray(sparse["val"][u])
mass = attention / attention.sum()
xx, yy = indices % gw + 0.5, indices // gw + 0.5
for coords, peak in ((xx, px), (yy, py)):
order = np.argsort(coords)
cdf = np.cumsum(mass[order])
quantiles = np.searchsorted(cdf, (0.05, 0.25, 0.5, 0.75, 0.95))
np.minimum(quantiles, len(order) - 1, out=quantiles)
values.extend((coords[order[quantiles]] - peak).tolist())
for threshold in (0.1, 0.3, 0.6):
keep = attention >= threshold * attention.max()
values.extend(
[
float(xx[keep].min() - 0.5 - px),
float(yy[keep].min() - 0.5 - py),
float(xx[keep].max() + 0.5 - px),
float(yy[keep].max() + 0.5 - py),
]
)
if mass_stats is not None:
values.extend(mass_stats[row].tolist())
else:
values.extend(
[
float(mass.max()),
float(-(mass * np.log(np.maximum(mass, 1e-12))).sum()),
]
)
extras.append(values)
extra_array = np.asarray(extras).reshape(len(valid), 51)
# Quantile and threshold offsets share the same grid-cell clipping bounds.
np.clip(extra_array[:, 27:49], -20, 20, out=extra_array[:, 27:49])
return np.column_stack([features, extra_array])
|