Image-Text-to-Text
Transformers
Safetensors
granite_docling
granite
docling
doclang
ocr
document-parsing
document-conversion
layout-analysis
table-recognition
formula-recognition
vllm
autoround
w4a16
gptq
compressed-tensors
quantized
conversational
Run this model with HF Jobs
Run OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-LLM-Compressor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/granite-docling-v2-2b-LLM-Compressor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-LLM-Compressor") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-LLM-Compressor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-LLM-Compressor
- SGLang
How to use OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-LLM-Compressor with Docker Model Runner:
docker model run hf.co/OpenTensorLab/granite-docling-v2-2b-LLM-Compressor
Update namespace references from Vishva007 to OpenTensorLab
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267---license: apache-2.0library_name: transformerspipeline_tag: image-text-to-textbase_model: ibm-granite/granite-docling-v2-2bbase_model_relation: quantizedquantized_by: Vishva007language:- en- zh- ja- ko- ar- de- es- fr- it- nl- pl- pttags:- 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 || :--- | :--- | :--- || **[`Vishva007/granite-docling-v2-2b-AutoRound`](https://huggingface.co/Vishva007/granite-docling-v2-2b-AutoRound)** | `auto-round` / `auto-gptq` | vLLM (`INC` / `GPTQ` / `Marlin` kernels) & 🤗 Transformers || **[`Vishva007/granite-docling-v2-2b-LLM-Compressor`](https://huggingface.co/Vishva007/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)
```bashpip 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:
```bashvllm serve Vishva007/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 `Vishva007/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.
```pythonimport base64import mimetypesfrom pathlib import Path
from docling_core.transforms.deserializer.doclang import DocLangDocDeserializerfrom 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.contentdocument = DocLangDocDeserializer().deserialize_str(doclang_xml)print(document.export_to_markdown())```
### 🤗 Transformers
```bashpip install "transformers>=5.23.0" auto-round torch torchvision pillow docling-core
```
```pythonimport torchfrom PIL import Imagefrom transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "Vishva007/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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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.---
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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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` | [](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.README.md+267-267