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
4-bit precision
auto-round
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.
Instructions to use OpenTensorLab/granite-docling-v2-2b-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenTensorLab/granite-docling-v2-2b-AutoRound 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-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/granite-docling-v2-2b-AutoRound") model = AutoModelForMultimodalLM.from_pretrained("OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-AutoRound 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-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/granite-docling-v2-2b-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/granite-docling-v2-2b-AutoRound
- SGLang
How to use OpenTensorLab/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-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/granite-docling-v2-2b-AutoRound with Docker Model Runner:
docker model run hf.co/OpenTensorLab/granite-docling-v2-2b-AutoRound
Vishva R commited on
Create README.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230---license: apache-2.0library_name: transformerspipeline_tag: image-text-to-textbase_model:- ibm-granite/granite-docling-v2-2b- ibm-granite/granite-4.0-1bbase_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-W4A16-AutoRound`](https://huggingface.co/Vishva007/granite-docling-v2-2b-W4A16-AutoRound)** | `auto-round` / `auto-gptq` | vLLM (`INC` / `GPTQ` / `Marlin` kernels) & 🤗 Transformers || **[`Vishva007/granite-docling-v2-2b-W4A16-LLM-Compressor`](https://huggingface.co/Vishva007/granite-docling-v2-2b-W4A16-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-W4A16-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-W4A16-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-W4A16-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/).
---
## 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.mdAdded+230