Instructions to use ibm-granite/granite-docling-v2-500m-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use ibm-granite/granite-docling-v2-500m-mlx with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("ibm-granite/granite-docling-v2-500m-mlx") config = load_config("ibm-granite/granite-docling-v2-500m-mlx") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Granite Docling V2 500M MLX
Half a billion parameters, rich in structure: any page becomes DocLang, with extra vision tokens only where the page needs them.
📄 Technical report · 📊 Benchmark Explorer · 🤗 Demo · 🦆 Docling · 🏆 2B sibling
Granite Docling V2 500M is the small, fast member of the Granite Docling V2 family. It converts a page image into
DocLang, a markup language that records each element's type, position and reading order along with its
content. One generation gives you headings, paragraphs, lists, tables with merged and header cells, LaTeX formulas,
code, pictures with their captions and the text printed inside them, and page headers and footers. You can export the result to Markdown, HTML or JSON
with docling-core. It succeeds SmolDocling and
Granite-Docling 258M, from the Docling team at IBM.
This repository holds the weights for MLX-VLM on Apple silicon. The original checkpoint is ibm-granite/granite-docling-v2-500m.
- 🏆 Accuracy above its size: 94.9% content 1 − NED pooled over 16,205 pages from nine benchmarks, ahead of Nemotron 3.5 Parse (0.6B) and Unlimited-OCR 2 (3.3B). The edit distance falls from 20.6% with Granite-Docling 258M to 5.1%, four times lower.
- 🔀 Adaptive vision budget: a learned density router reads 64 tokens per tile on ordinary pages and re-encodes dense pages, such as newspapers or small CJK print, at 256 tokens per tile.
- 🧱 Structure is part of the output: every element carries its type and bounding box. Tables keep their full cell structure, and inline math, sub- and superscripts are marked inside the text.
- 🖼️ Pictures are read, not skipped: each picture keeps its type, its caption and the text printed inside it; the
[<detailed>]prompt adds a description. - 🎯 Prompt for only what you need: ask for just the tables, the formulas, or the text with boxes, and the model decodes nothing else.
- 🌍 Multilingual: far stronger than Granite-Docling 258M beyond English, above all on Chinese, Japanese, Korean, Hindi, Russian and Arabic, and on mixed Chinese–English pages.
- ✍️ Handwriting: reads handwritten notes and forms far better than Granite-Docling 258M, though printed text remains more accurate.
- 🍎 Runs on your Mac: MLX-VLM on Apple silicon, density router included; bf16 weights of about 1.1 GB.
Page content 1 − NED (all text on the page, including table cells, formulas and code), pooled over 20,502 pages
from ten benchmarks, against throughput on one H100 (each system with the settings its model card recommends,
2,078 ParseBench pages, peak over 8–256 pages in flight; details in the
original model card). Granite Docling V2 uses MTP speculative decoding and
Nemotron 3.5 Parse its DFlash2 drafter. The 2B Flash and 500M Flash points have the accuracy of the 2B and 500M and are available in the
IBM watsonx editions of Docling. Bubble area is proportional to
parameter count; a double ring marks two-pass systems.
What is DocLang?
DocLang is an XML vocabulary for documents. Each element opens with its type, then its bounding box as four
location tokens (x0 y0 x1 y1 on a 512 × 512 grid from the top-left corner), then its content. Captions sit
inside the table, picture, code or formula they describe. Tables use
OTSL cell tokens (<ched/> header, <fcel/> filled cell, <nl/> row
break, plus merge tokens). Formulas are LaTeX, and inline formatting such as bold, superscript and handwriting is
marked inside running text.
Every tag and every coordinate is a single token, so a page's full structure costs far fewer tokens than
HTML. A DocLang page converts losslessly into a
DoclingDocument and from there into Markdown, HTML or JSON.
DocLang is the successor of the DocTags format used by
SmolDocling and
Granite-Docling 258M.
DocLang 0.9 specification →
Quick start
🍎 MLX
Runs on Apple silicon with MLX-VLM.
pip install "mlx-vlm>=0.8.1" pillow docling-core
import mlx.core as mx
from PIL import Image
from mlx_vlm import generate, load
from mlx_vlm.prompt_utils import apply_chat_template
model_id = "ibm-granite/granite-docling-v2-500m-mlx"
model, processor = load(model_id)
prompt = apply_chat_template(processor, model.config, "<doclang>", num_images=1)
# The density router scores the page from its vision features: 64 tokens per tile, or 256 for dense pages.
tiles = processor.image_processor(Image.open("page.png"), return_tensors="np")
fine = model.predict_fine_route(mx.array(tiles["pixel_values"]), mx.array(tiles["pixel_attention_mask"])).item()
result = generate(model, processor, prompt, image=["page.png"], max_tokens=16384, temperature=0.0, fine_route=fine)
doclang = result.text
print(doclang)
The output keeps the DocLang tags and location tokens. The router decision costs one pass of the vision encoder.
To force a route, pass fine_route=True or fine_route=False directly.
Command line, batches and 8-bit weights
Command line. Add --processor-kwargs '{"fine_route": true}' for a dense page.
mlx_vlm.generate --model ibm-granite/granite-docling-v2-500m-mlx \
--image page.png --prompt "<doclang>" --max-tokens 16384 --temperature 0
Several pages. batch_generate adds the chat template itself, so give it the bare prompt. It uses one route
for the whole batch, so group pages by route and set processor.image_processor.fine_route before each call. For
a PDF, render each page to an image (for example with pypdfium2 at 144 DPI).
from mlx_vlm.generate import batch_generate
pages = ["page-1.png", "page-2.png", "page-3.png"]
processor.image_processor.fine_route = False
response = batch_generate(model, processor, images=pages, prompts=["<doclang>"] * len(pages), max_tokens=16384)
for page, doclang in zip(pages, response.texts):
print(page, doclang[:200])
Less memory. An 8-bit copy needs less memory and is faster. Give ./granite-docling-v2-500m-8bit as the model
after this:
mlx_vlm.convert --hf-path ibm-granite/granite-docling-v2-500m \
--mlx-path ./granite-docling-v2-500m-8bit -q --q-bits 8
📝 Export to Markdown, HTML or JSON
from docling_core.transforms.deserializer.doclang import DocLangDocDeserializer
document = DocLangDocDeserializer().deserialize_str(doclang)
print(document.export_to_markdown())
document.save_as_markdown("page.md")
document.save_as_html("page.html")
document.save_as_json("page.json")
Prompts
The default prompt <doclang> converts the whole page. A task prompt lists the tasks you want in
square brackets after <doclang>, allowing you to control what the model generates.
The complete list of supported tasks is: <ocr>, <table>, <formula>, <picture>, <code>,
<layout> and <detailed>.
The prompts in the table below are examples only, not an exhaustive list. You can use any combination of the supported tasks, in any order, provided that the exact prompt structure is preserved.
| Prompt | Output |
|---|---|
<doclang> |
The full page: every element with its type, location and content |
<doclang> [<table>] |
Only the tables |
<doclang> [<table>, <formula>] |
Only the tables and formulas |
<doclang> [<ocr>, <layout>] |
Text with location tokens; without <layout> the output has content only |
<doclang> [<detailed>] |
The full page plus a generated description of each picture |
<doclang>, tasks in angle
brackets, separated by , . Other spacing or punctuation lowers quality. The model only takes <doclang>
and these task prompts; it does not follow free-form instructions or answer questions.
Abridged outputs for the page shown above. Small gray numbers are location tokens, shown by their values.
Task prompts also work on crops of a single element.
When the requested content is absent, the model returns an empty <doclang></doclang>.
Evaluation
Content 1 − NED (%, higher is better) is the character-level similarity of the whole page's text, weighted
by characters. Missing and invented text count as errors. Greedy decoding with the <doclang> prompt; the router sent 428 of the 1,649
OmniDocBench pages (26%) to the fine route.
| Model | Params | OmniDocBench 1.6 | DocLayNet v1 | DocLayNet v2† | Creative Layouts† | MDPBench | ParseBench | olmOCR-Bench | RealDocBench | VAREX | All (16,205 pages) |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Granite Docling V2 500M | 0.54B | 93.6 | 97.3 | 94.7 | 96.9 | 82.8 | 94.4 | 96.9 | 87.5 | 95.7 | 94.9 |
| Granite Docling V2 2B | 2.5B | 96.2 | 98.1 | 95.8 | 97.6 | 86.0 | 96.0 | 98.4 | 91.6 | 97.7 | 96.5 |
| dots.mocr | 3B | 95.9 | 98.6 | 93.8 | 94.8 | 86.2 | 95.1 | 98.3 | 78.8 | 87.8 | 94.6 |
| MinerU 2.5 Pro | 1.2B | 97.2 | 97.5 | 94.5 | 97.1 | 83.2 | 94.8 | 97.8 | 81.5 | 89.3 | 94.4 |
| Nemotron 3.5 Parse | 0.6B | 92.1 | 96.9 | 93.0 | 97.0 | 81.3 | 93.8 | 95.9 | 78.0 | 87.8 | 92.9 |
| Chandra | 5.3B | 91.5 | 97.8 | 93.5 | 91.6 | 72.4 | 87.9 | 97.7 | 77.1 | 77.9 | 90.3 |
| Unlimited-OCR 2 | 3.3B | 84.8 | 96.4 | 90.4 | 97.5 | 63.2 | 87.3 | 95.4 | 77.2 | 86.9 | 89.4 |
| LightOnOCR 3 | 4B | 76.2 | 93.9 | 90.7 | 97.4 | 61.1 | 91.0 | 94.3 | 71.3 | 86.3 | 87.6 |
| LightOnOCR 3 | 0.8B | 66.0 | 93.2 | 88.3 | 97.2 | 55.4 | 91.3 | 96.5 | 79.5 | 84.0 | 86.0 |
| Granite-Docling 258M | 0.26B | — | — | — | — | — | — | — | — | — | 79.4 |
† Internal held-out benchmarks; their pages and ground truth are not released. Pages per benchmark: 1,649 / 4,999 / 2,067 / 1,034 / 673 / 2,023 / 1,403 / 580 / 1,777. Other systems are mapped to DocLang with Docling's public converters and pooled over the pages they returned (16,174–16,193 of 16,205).
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},
}
License
Released under the Apache 2.0 license.
- Downloads last month
- -
Quantized
Model tree for ibm-granite/granite-docling-v2-500m-mlx
Base model
ibm-granite/granite-4.0-350m-base