Instructions to use Vishva007/granite-docling-v2-2b-AutoRound with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vishva007/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="Vishva007/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("Vishva007/granite-docling-v2-2b-AutoRound") model = AutoModelForMultimodalLM.from_pretrained("Vishva007/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 Vishva007/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 "Vishva007/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": "Vishva007/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/Vishva007/granite-docling-v2-2b-AutoRound
- SGLang
How to use Vishva007/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 "Vishva007/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": "Vishva007/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 "Vishva007/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": "Vishva007/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 Vishva007/granite-docling-v2-2b-AutoRound with Docker Model Runner:
docker model run hf.co/Vishva007/granite-docling-v2-2b-AutoRound
Granite Docling V2 2B — W4A16 (AutoRound)
4-bit weight-quantized (Intel AutoRound) variants of ibm-granite/granite-docling-v2-2b with full BF16 Vision Tower, Connector, lm_head, and MTP Speculative Decoding heads preserved.
🤗 Base Model · 📄 Technical Report · 📊 Benchmark Explorer · 🦆 Docling · ⚙️ Intel AutoRound
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 |
auto-round / auto-gptq |
vLLM (INC / GPTQ / Marlin kernels) & 🤗 Transformers |
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):
3.04 GiB` total including CUDA graphs)2.67 GiBmodel + MTP weights (`
Quick Start
⚡ vLLM Server (Recommended — with MTP Speculative Decoding)
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:
vllm 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 and512 × 512bounding-box location tokens are special tokens; stripping them leaves bare text.
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
pip install "transformers>=5.23.0" auto-round torch torchvision pillow docling-core
import torch
from PIL import Image
from 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.
| 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 and the DocLang 0.9 specification.
🚀 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 and get $5–$500 in free credits when you add your first $10.
PyTorch 2.15
PyTorch 2.14
PyTorch 2.13
PyTorch 2.12
Citation
@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, matching the upstream ibm-granite/granite-docling-v2-2b model.
- Downloads last month
- -
Model tree for Vishva007/granite-docling-v2-2b-AutoRound
Base model
ibm-granite/granite-4.0-1b-base