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
Download parse_rl_utils/ocria_attention_grounding/regions.py from OpenTensorLab/OCRia-1-W4A16-AutoRound: direct link, hf CLI and curl.
- Browser
- Download file 6.99 kB
-
https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-AutoRound/resolve/main/parse_rl_utils/ocria_attention_grounding/regions.py
- Command line
-
hf download hf://OpenTensorLab/OCRia-1-W4A16-AutoRound/parse_rl_utils/ocria_attention_grounding/regions.py
-
curl -L -o regions.py https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-AutoRound/resolve/main/parse_rl_utils/ocria_attention_grounding/regions.py
6.99 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. | |
| """Conservative region-edge features from predicted word boxes.""" | |
| from dataclasses import dataclass | |
| import numpy as np | |
| from .predict import Predictor, predict | |
| REGION_FEATURE_VERSION = "region-edges-v1" | |
| REGION_FEATURE_COUNT = 47 | |
| REGION_CONTEXT_VERSION = "region-edges-context-v1" | |
| REGION_CONTEXT_COUNT = 86 | |
| _REGION_TYPES = ("text", "list", "heading", "header", "footer") | |
| class HeadingRegionBlend: | |
| """Blend shared and heading-specific edge corrections in word-height units.""" | |
| base: Predictor | |
| specialist: Predictor | |
| def predict(self, features: np.ndarray) -> np.ndarray: | |
| result = predict(self.base, features).copy() | |
| headings = features[:, _REGION_TYPES.index("heading")] == 1 | |
| if headings.any(): | |
| result[headings] = 0.5 * result[headings] + 0.5 * predict( | |
| self.specialist, features[headings] | |
| ) | |
| return result | |
| class HeaderRegionOverride: | |
| """Use refreshed edge models for headers and retained models for other types.""" | |
| base: Predictor | |
| refreshed: Predictor | |
| def predict(self, features: np.ndarray) -> np.ndarray: | |
| headers = features[:, _REGION_TYPES.index("header")] == 1 | |
| result = np.empty(len(features)) | |
| if headers.any(): | |
| result[headers] = predict(self.refreshed, features[headers]) | |
| if (~headers).any(): | |
| result[~headers] = predict(self.base, features[~headers]) | |
| return result | |
| class HeadingGlyphRegionBlend: | |
| """Refine a heading edge with letter-shape features; preserve other types.""" | |
| base: Predictor | |
| shared: Predictor | |
| specialist: Predictor | |
| def predict(self, features: np.ndarray) -> np.ndarray: | |
| geometry = features[:, :REGION_CONTEXT_COUNT] | |
| result = np.empty(len(features)) | |
| headings = geometry[:, _REGION_TYPES.index("heading")] == 1 | |
| if (~headings).any(): | |
| result[~headings] = predict(self.base, geometry[~headings]) | |
| if headings.any(): | |
| result[headings] = 0.5 * ( | |
| predict(self.shared, geometry[headings]) | |
| + predict(self.specialist, features[headings]) | |
| ) | |
| return result | |
| def heading_glyph_features(texts: list[str]) -> np.ndarray: | |
| """Return ascender/capital and Latin descender fractions among letters. | |
| These are text-shape hints, not font measurements. Geometry remains the | |
| primary signal, including for scripts without Latin ascender conventions. | |
| """ | |
| result = np.zeros((len(texts), 2)) | |
| for i, text in enumerate(texts): | |
| letters = [char for char in text if char.isalpha()] | |
| count = max(1, len(letters)) | |
| result[i, 0] = ( | |
| sum(char in "bdfhklt" or char.isupper() for char in letters) / count | |
| ) | |
| result[i, 1] = sum(char in "gjpqy" for char in letters) / count | |
| return result | |
| def contextual_region_features(records: list[dict]) -> np.ndarray: | |
| """Append neighboring region geometry to uncorrected region features. | |
| Records are in transcript order, with grid-cell anchors and median word | |
| heights. All neighbors use their original anchors, so applying corrections | |
| later cannot make features depend on the order of model evaluation. | |
| """ | |
| anchors = [np.asarray(record["anchor"]) for record in records] | |
| kinds = [np.argmax(record["features"][:5]) for record in records] | |
| rows = [] | |
| for i, record in enumerate(records): | |
| box = anchors[i] | |
| height = record["height"] | |
| extra = [] | |
| for offset in (-2, -1, 1, 2): | |
| j = i + offset | |
| if not 0 <= j < len(records): | |
| extra.extend([0.0] * 7) | |
| continue | |
| neighbor = records[j] | |
| extra.extend( | |
| [ | |
| 1.0, | |
| *(((anchors[j] - box) / height).clip(-30, 30)).tolist(), | |
| neighbor["height"] / height, | |
| float(kinds[j] == kinds[i]), | |
| ] | |
| ) | |
| nearby = [ | |
| records[j] for j in range(max(0, i - 8), min(len(records), i + 9)) if j != i | |
| ] | |
| # Edge consensus is local in reading order and within three word heights, | |
| # reducing interference from a separate column or an indented list. | |
| for edge in (0, 2): | |
| aligned = [ | |
| (neighbor["anchor"][edge] - box[edge]) / height | |
| for neighbor in nearby | |
| if abs(neighbor["anchor"][edge] - box[edge]) / height < 3 | |
| ] | |
| extra.extend( | |
| [len(aligned), *np.quantile(aligned, [0.1, 0.5, 0.9]).tolist()] | |
| if aligned | |
| else [0.0] * 4 | |
| ) | |
| heights = [neighbor["height"] / height for neighbor in nearby] | |
| extra.extend( | |
| np.quantile(heights, [0.1, 0.5, 0.9]).tolist() if heights else [0.0] * 3 | |
| ) | |
| rows.append([*record["features"], *extra]) | |
| return np.asarray(rows).reshape(-1, REGION_CONTEXT_COUNT) | |
| def region_features( | |
| kind: str, | |
| text: str, | |
| box: np.ndarray, | |
| gate: np.ndarray, | |
| words: np.ndarray, | |
| lengths: np.ndarray, | |
| grid: tuple[int, int], | |
| ) -> tuple[list[float], float]: | |
| """Describe a region's edges in units of its median predicted word height. | |
| All input boxes use grid-cell edges. `gate` is the pre-regression attention | |
| box, and `words` contains only the words retained by that spatial guard. | |
| Returned height converts model residuals back into grid-cell coordinates. | |
| """ | |
| gh, gw = grid | |
| heights = words[:, 3] - words[:, 1] | |
| height = max(0.1, float(np.median(heights))) | |
| widths = words[:, 2] - words[:, 0] | |
| relative = (np.quantile(words, [0, 0.1, 0.5, 0.9, 1], axis=0) - box) / height | |
| area = max(0.1, (box[2] - box[0]) * (box[3] - box[1])) | |
| features = [float(kind == value) for value in _REGION_TYPES] | |
| features.extend( | |
| [ | |
| np.log1p(len(words)), | |
| np.log1p(len(text)), | |
| height, | |
| (box[2] - box[0]) / height, | |
| (box[3] - box[1]) / height, | |
| float((widths * heights).sum() / area), | |
| float(np.median(widths / np.maximum(1, lengths)) / height), | |
| gh, | |
| gw, | |
| ] | |
| ) | |
| features.extend((box / [gw, gh, gw, gh]).tolist()) | |
| features.extend(((gate - box) / height).tolist()) | |
| features.extend(relative.ravel().tolist()) | |
| features.extend((np.quantile(heights, [0.1, 0.5, 0.9]) / height).tolist()) | |
| features.extend( | |
| [ | |
| float(np.mean([c.isupper() for c in text])) if text else 0.0, | |
| float(np.mean([c.isdigit() for c in text])) if text else 0.0, | |
| ] | |
| ) | |
| return np.asarray(features, dtype=float).tolist(), height | |