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 parse_rl_utils/ocria_attention_grounding/columns.py from OpenTensorLab/OCRia-1-W4A16-LLM-Compressor: direct link, hf CLI and curl.
- Browser
- Download file 6.7 kB
-
https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/parse_rl_utils/ocria_attention_grounding/columns.py
- Command line
-
hf download hf://OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/parse_rl_utils/ocria_attention_grounding/columns.py
-
curl -L -o columns.py https://huggingface.co/OpenTensorLab/OCRia-1-W4A16-LLM-Compressor/resolve/main/parse_rl_utils/ocria_attention_grounding/columns.py
6.7 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. | |
| """Separate prose that continues into another column without a Markdown break.""" | |
| import numpy as np | |
| from .blocks import Block | |
| from .io import units_for | |
| _COLUMN_WINDOW = 12 | |
| _COLUMN_TAIL_MIN = 6 | |
| _COLUMN_JUMP = 0.15 | |
| def split_column_blocks(answer: str, capture: dict, blocks: list[Block]) -> list[Block]: | |
| """Split at sustained rightward/upward transitions in cached word peaks. | |
| Offsets stay in the original transcript and attention-grid coordinates. | |
| Twelve preceding words must support a disjoint horizontal band. A tail | |
| can have six words if they form coherent rows beyond that band. The | |
| upward jump must exceed three typical line steps, allowing short columns | |
| while excluding ordinary left-to-right line wraps. | |
| Only prose is eligible, preserving image/table attention-unit contracts. | |
| """ | |
| units, per_block = units_for(answer, blocks) | |
| sparse = capture["sparse_maps"] | |
| gh, gw = capture["grid"] | |
| result = [] | |
| for block, indices in zip(blocks, per_block): | |
| if block.type != "text" or len(indices) < 2 * _COLUMN_WINDOW: | |
| result.append(block) | |
| continue | |
| valid, points = [], [] | |
| for unit in indices: | |
| if sparse["val"][unit]: | |
| cell = sparse["idx"][unit][int(np.argmax(sparse["val"][unit]))] | |
| valid.append(unit) | |
| points.append([cell % gw + 0.5, cell // gw + 0.5]) | |
| positions = np.asarray(points) | |
| # Estimate line spacing in attention-grid cells. Small positive steps | |
| # capture wraps; larger jumps can belong to a different region. | |
| deltas = np.diff(positions[:, 1]) if len(positions) else np.array([]) | |
| line_steps = deltas[(deltas > 0) & (deltas <= max(2, gh * 0.03))] | |
| vertical_jump = ( | |
| max(2.0, 3 * float(np.median(line_steps))) | |
| if len(line_steps) | |
| else _COLUMN_JUMP * gh | |
| ) | |
| cuts = [] | |
| last = -_COLUMN_WINDOW | |
| for index in range(_COLUMN_WINDOW, len(valid) - _COLUMN_TAIL_MIN + 1): | |
| if ( | |
| index - last < _COLUMN_WINDOW | |
| or positions[index, 1] - positions[index - 1, 1] >= -vertical_jump | |
| ): | |
| continue | |
| before = positions[index - _COLUMN_WINDOW : index] | |
| after = positions[index : index + _COLUMN_WINDOW] | |
| if len(after) < _COLUMN_WINDOW: | |
| # Short tails need multiple coherent rows and every word to | |
| # clear the preceding column's right edge (grid coordinates). | |
| dy = np.diff(after[:, 1]) | |
| if ( | |
| np.ptp(after[:, 1]) < 1 | |
| or np.any(dy < -1) | |
| or after[:, 0].min() <= np.quantile(before[:, 0], 0.9) | |
| ): | |
| continue | |
| if ( | |
| np.quantile(after[:, 0], 0.1) > np.quantile(before[:, 0], 0.9) | |
| and np.median(after[:, 1]) - np.median(before[:, 1]) < -vertical_jump | |
| ): | |
| cuts.append(units[valid[index]][0]) | |
| last = index | |
| boundaries = [block.start, *cuts, block.end] | |
| result.extend( | |
| Block(block.type, start, end) | |
| for start, end in zip(boundaries, boundaries[1:]) | |
| ) | |
| return _split_short_openings(answer, capture, result) | |
| def _split_short_openings( | |
| answer: str, capture: dict, blocks: list[Block] | |
| ) -> list[Block]: | |
| """Recover 4–11 opening words stranded at the foot of a previous column. | |
| Twelve following words must support a disjoint column above the opening. | |
| Both windows follow row order; all coordinates are attention-grid cells. | |
| Splits preserve transcript offsets and therefore cached attention indices. | |
| """ | |
| units, per_block = units_for(answer, blocks) | |
| sparse = capture["sparse_maps"] | |
| grid_width = capture["grid"][1] | |
| result = [] | |
| for block, indices in zip(blocks, per_block): | |
| cut = None | |
| if block.type == "text" and len(indices) >= 17: | |
| points = [] | |
| for unit in indices[:23]: | |
| values = sparse["val"][unit] | |
| if not values: | |
| break | |
| cell = sparse["idx"][unit][int(np.argmax(values))] | |
| points.append([cell % grid_width, cell // grid_width]) | |
| # All candidate cuts lie within the first 23 words. Reject ordinary | |
| # same-column prose before reading the rest of its attention maps. | |
| if len(points) == min(23, len(indices)): | |
| horizontal = [point[0] for point in points] | |
| if not any( | |
| min(horizontal[index : index + 12]) > max(horizontal[:index]) | |
| for index in range(4, min(12, len(indices) - 11)) | |
| ): | |
| result.append(block) | |
| continue | |
| for unit in indices[23:]: | |
| values = sparse["val"][unit] | |
| if not values: | |
| break | |
| cell = sparse["idx"][unit][int(np.argmax(values))] | |
| points.append([cell % grid_width, cell // grid_width]) | |
| if len(points) == len(indices): | |
| positions = np.asarray(points) | |
| steps = np.diff(positions[:, 1]) | |
| steps = steps[(steps > 0) & (steps <= 3)] | |
| jump = max(3, 3 * float(np.median(steps))) if len(steps) else 3 | |
| for index in range(4, min(12, len(indices) - 11)): | |
| before, after = positions[:index], positions[index : index + 12] | |
| if ( | |
| after[:, 0].min() <= before[:, 0].max() | |
| or np.median(before[:, 1]) - np.median(after[:, 1]) <= jump | |
| or any(np.any(np.diff(p[:, 1]) < -1) for p in (before, after)) | |
| or any(np.ptp(p[:, 1]) > jump for p in (before, after)) | |
| or any( | |
| np.any(np.diff(p[:, 0])[np.diff(p[:, 1]) == 0] <= 0) | |
| for p in (before, after) | |
| ) | |
| ): | |
| continue | |
| cut = units[indices[index]][0] | |
| break | |
| if cut is None: | |
| result.append(block) | |
| else: | |
| result.extend( | |
| [Block(block.type, block.start, cut), Block(block.type, cut, block.end)] | |
| ) | |
| return result | |