Run this model with HF Jobs

Run OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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.
OpenTensorLab's picture
Update namespace references from Vishva007 to OpenTensorLab
081e188 verified
|
Raw History Blame Contribute Delete
12.9 kB
---
license: apache-2.0
library_name: transformers
pipeline_tag: image-text-to-text
base_model: ibm-granite/granite-docling-v2-2b
base_model_relation: quantized
quantized_by: OpenTensorLab
language:
- en
- zh
- ja
- ko
- ar
- de
- es
- fr
- it
- nl
- pl
- pt
tags:
- granite
- docling
- doclang
- ocr
- document-parsing
- document-conversion
- layout-analysis
- table-recognition
- formula-recognition
- vllm
- autoround
- w4a16
- gptq
- compressed-tensors
- quantized
---
<p align="center">
<img src="assets/granite_docling_v2.png" width="300" alt="Three Docling ducks with hammers and chisels carving a granite statue of a duck that holds a DocLang scroll">
</p>
<h1 align="center">Granite Docling V2 2B — W4A16 (AutoRound)</h1>
<p align="center">
<b>4-bit weight-quantized (<a href="https://github.com/intel/auto-round">Intel AutoRound</a>) variants of <a href="https://huggingface.co/ibm-granite/granite-docling-v2-2b"><code>ibm-granite/granite-docling-v2-2b</code></a> with full BF16 Vision Tower, Connector, <code>lm_head</code>, and MTP Speculative Decoding heads preserved.</b>
</p>
<p align="center">
<a href="https://huggingface.co/ibm-granite/granite-docling-v2-2b">🤗 Base Model</a> ·
<a href="https://arxiv.org/abs/2611.37727">📄 Technical Report</a> ·
<a href="https://docling.ai/benchmarks">📊 Benchmark Explorer</a> ·
<a href="https://github.com/docling-project/docling">🦆 Docling</a> ·
<a href="https://github.com/intel/auto-round">⚙️ Intel AutoRound</a>
</p>
---
## Quantized Model Variants
Both checkpoints are produced from the same `SignRound` optimization pass (`W4A16`, `group_size=32`, symmetric) and include the original unquantized `bfloat16` Multi-Token Prediction (MTP) draft layers (`39` tensors in `model_extra_tensors.safetensors`) so `--speculative-config '{"method": "mtp", "num_speculative_tokens": 3}'` works out of the box in **vLLM**:
| Repository | Export Format | Best For |
| :--- | :--- | :--- |
| **[`OpenTensorLab/granite-docling-v2-2b-AutoRound`](https://huggingface.co/OpenTensorLab/granite-docling-v2-2b-AutoRound)** | `auto-round` / `auto-gptq` | vLLM (`INC` / `GPTQ` / `Marlin` kernels) & 🤗 Transformers |
| **[`OpenTensorLab/granite-docling-v2-2b-LLM-Compressor`](https://huggingface.co/OpenTensorLab/granite-docling-v2-2b-LLM-Compressor)** | `compressed-tensors` (`wint-a16`) | vLLM (`compressed-tensors` runtime) |
---
## Quantization Recipe & Precision Layout
To preserve OCR, layout bounding-box (`512 × 512`), table-structure, and speculative-decoding accuracy on this 2.68B VLM, only the 24 language decoder transformer blocks are quantized to 4-bit:
| Module / Component | Precision | Details |
| :--- | :--- | :--- |
| **`model.text_model.layers.[0-23]`** (96 linear layers) | **W4A16** (`INT4` weights / `BF16` activations) | `group_size=32`, `sym=True`, `iters=1200`, `nsamples=512`, `seqlen=4096` |
| **`model.vision_model`** (27-layer encoder + `GraniteDoclingConnector`) | **BF16** (Unquantized) | Preserves spatial & visual feature fidelity (`quant_nontext_module=False`) |
| **`model.text_model.embed_tokens` & `lm_head`** | **BF16** (Unquantized) | Tied embeddings (`133,800` vocab) kept at full precision |
| **`mtp.layers.[0-2]`** (3 MTP draft layers, 208M params) | **BF16** (Unquantized) | Original `bfloat16` weights preserved for lossless MTP speculative decoding |
* **Hardware Used:** NVIDIA RTX PRO 6000 Blackwell (`CUDA 13.2`, `PyTorch 2.14`)
* **Runtime Footprint (vLLM):** ~`2.67 GiB` model + MTP weights (`~3.04 GiB` total including CUDA graphs)
---
## Quick Start
### ⚡ vLLM Server (Recommended — with MTP Speculative Decoding)
```bash
pip install -U vllm --pre "transformers>=5.23.0" \
--extra-index-url https://wheels.vllm.ai/nightly
```
Serve either repository with 3-token MTP speculative decoding enabled:
```bash
vllm serve OpenTensorLab/granite-docling-v2-2b-AutoRound \
--model-impl transformers \
--gpu-memory-utilization 0.4 \
--max-model-len 16384 \
--max-num-batched-tokens 8192 \
--limit-mm-per-prompt '{"image": 1}' \
--speculative-config '{"method": "mtp", "num_speculative_tokens": 3}' \
--api-server-count 8
```
*(To use the `compressed-tensors` variant instead, swap the model ID to `OpenTensorLab/granite-docling-v2-2b-LLM-Compressor`.)*
#### Python Client (`openai` + `docling-core`)
> **Important:** Always pass `extra_body={"skip_special_tokens": False}`. DocLang structural tags and `512 × 512` bounding-box location tokens are special tokens; stripping them leaves bare text.
```python
import base64
import mimetypes
from pathlib import Path
from docling_core.transforms.deserializer.doclang import DocLangDocDeserializer
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
model_id = client.models.list().data[0].id
image_path = Path("page.png")
mime_type = mimetypes.guess_type(image_path)[0] or "image/png"
b64_img = base64.b64encode(image_path.read_bytes()).decode("utf-8")
response = client.chat.completions.create(
model=model_id,
messages=[
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": f"data:{mime_type};base64,{b64_img}"}},
{"type": "text", "text": "<doclang>"},
],
}
],
temperature=0.0,
max_tokens=16384,
extra_body={"skip_special_tokens": False},
)
doclang_xml = response.choices[0].message.content
document = DocLangDocDeserializer().deserialize_str(doclang_xml)
print(document.export_to_markdown())
```
### 🤗 Transformers
```bash
pip install "transformers>=5.23.0" auto-round torch torchvision pillow docling-core
```
```python
import torch
from PIL import Image
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "OpenTensorLab/granite-docling-v2-2b-AutoRound"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
model_id, dtype=torch.bfloat16, device_map="cuda"
)
image = Image.open("page.png").convert("RGB")
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": "<doclang>"},
],
}
]
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device, dtype=torch.bfloat16)
output = model.generate(**inputs, max_new_tokens=16384, do_sample=False)
doclang = processor.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=False)
doclang = doclang.removesuffix(processor.tokenizer.eos_token)
print(doclang)
```
---
## About Granite Docling V2 2B & Supported Prompts
**Granite Docling V2 2B** converts document page images into **DocLang**, an XML markup vocabulary recording element types, `512 × 512` bounding boxes, reading order, OTSL tables, LaTeX formulas, code, and picture captions/descriptions, exportable to Markdown, HTML, or JSON via [`docling-core`](https://github.com/docling-project/docling-core).
| Prompt | Output |
| --- | --- |
| `<doclang>` | Full page: every element with its type, bounding box, and content |
| `<doclang> [<table>]` | Tables only |
| `<doclang> [<table>, <formula>]` | Tables and formulas only |
| `<doclang> [<ocr>, <layout>]` | Text with location tokens (`<ocr>` alone omits location tokens) |
| `<doclang> [<detailed>]` | Full page plus generated descriptions for pictures |
*(Supported task tokens: `<ocr>`, `<table>`, `<formula>`, `<picture>`, `<code>`, `<layout>`, `<detailed>`.)*
For full benchmark tables (96.5% pooled content `1 − NED` across 16,205 pages) and format specifications, see the upstream model card at [`ibm-granite/granite-docling-v2-2b`](https://huggingface.co/ibm-granite/granite-docling-v2-2b) and the [DocLang 0.9 specification](https://doclang.ai/).
---
### 🚀 Deploy on RunPod
One-click launch environments pre-configured with PyTorch, CUDA, and dependencies for fine-tuning or quantization.
> 🎁 **Need GPU compute?** Sign up via [RunPod](https://runpod.io?ref=iabrlp7z) and get **$5–$500 in free credits** when you add your first $10.
#### PyTorch 2.15
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.15 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.15-runpod` | `0rsw686010` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=0rsw686010&ref=iabrlp7z) |
| **PyTorch 2.15 (CUDA 13.4)** | 13.4 | `vishva123/cuda-13.4-pytorch-2.15-runpod` | `0s0rhdfaqy` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=0s0rhdfaqy&ref=iabrlp7z) |
#### PyTorch 2.14
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.14 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.14-runpod` | `d7lxsa4w9m` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=d7lxsa4w9m&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.14-runpod` | `yk0y6j6rpg` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=yk0y6j6rpg&ref=iabrlp7z) |
| **PyTorch 2.14 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.14-runpod` | `gsp4gwx0nw` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=gsp4gwx0nw&ref=iabrlp7z) |
#### PyTorch 2.13
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.13 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.13-runpod` | `gmlupxnxfk` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=gmlupxnxfk&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.13-runpod` | `y3j8xvk4f4` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=y3j8xvk4f4&ref=iabrlp7z) |
| **PyTorch 2.13 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.13-runpod` | `vigpissn5w` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=vigpissn5w&ref=iabrlp7z) |
#### PyTorch 2.12
| Template | CUDA Version | Docker Image | Template ID | Deploy |
| :--- | :--- | :--- | :--- | :--- |
| **PyTorch 2.12 (CUDA 12.6)** | 12.6 | `vishva123/cuda-12.6-pytorch-2.12-runpod` | `ctmz86zmf0` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=ctmz86zmf0&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.0)** | 13.0 | `vishva123/cuda-13.0-pytorch-2.12-runpod` | `qjko5yiwzi` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=qjko5yiwzi&ref=iabrlp7z) |
| **PyTorch 2.12 (CUDA 13.2)** | 13.2 | `vishva123/cuda-13.2-pytorch-2.12-runpod` | `ifg6xmye0f` | [![Deploy to RunPod](https://img.shields.io/badge/RunPod-Deploy%20Pod-purple?logo=runpod&logoColor=white)](https://runpod.io/console/deploy?template=ifg6xmye0f&ref=iabrlp7z) |
---
## Citation
```bibtex
@misc{nassar2026granitedoclingv2technical,
title={Granite Docling V2: Technical Report},
author={Ahmed Nassar and Matteo Omenetti and Christoph Auer and Cesar Berrospi Ramis and Michele Dolfi and Said Gürbüz and Viktor Kuropiatnyk and Nikolaos Livathinos and Maksym Lysak and Ingmar Meijer and Tim Strohmeyer and Panos Vagenas and Valery Weber and Ahmetcan Yavuz and Daniel DeAlcala and Peter El Hachem and Vittorio Pippi and Emmanuele Vivoli and Peter Staar},
year={2026},
eprint={2611.37727},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={[https://arxiv.org/abs/2611.37727](https://arxiv.org/abs/2611.37727)},
}
```
## License
Released under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0), matching the upstream `ibm-granite/granite-docling-v2-2b` model.