Granite Docling is a multimodal Image-Text-to-Text model engineered for efficient document conversion. This GGUF version enables fast CPU and GPU inference using llama.cpp, making it ideal for edge deployment and resource-constrained environments.
This repository contains multiple quantization levels of the text model, plus the vision encoder/projector. You need one text model file + the mmproj file for inference.
Text Model Files (choose one):
Filename
Quant
Size
Use Case
granite-docling-258M-Q4_K_M.gguf
Q4_K_M
133 MB
Smallest, good quality-size balance, recommended for most users
granite-docling-258M-Q5_K_M.gguf
Q5_K_M
139 MB
Better quality, still compact
granite-docling-258M-Q6_K.gguf
Q6_K
164 MB
Higher quality
granite-docling-258M-Q8_0.gguf
Q8_0
170 MB
Very high quality
granite-docling-258M-f16.gguf
F16
317 MB
Highest quality, original precision
Vision/Projector File (required):
Filename
Size
Notes
mmproj-granite-docling-258M-f16.gguf
182 MB
Vision encoder (SigLIP) - required for all quantizations
Note: The mmproj file is kept at F16 precision to maintain vision quality.
Getting Started with llama.cpp
Prerequisites
Build llama.cpp with multimodal support:
bash
1git clone https://github.com/ggerganov/llama.cpp
2cd llama.cpp
3cmake -B build -DGGML_CUDA=ON # For CUDA support4cmake --build build --config Release -j
Download the GGUF files from this repository
Basic Usage
bash
1# Using Q4_K_M (recommended for most users)2./llama.cpp/build/bin/llama-mtmd-cli \3 -m granite-docling-258M-Q4_K_M.gguf \4 --mmproj mmproj-granite-docling-258M-f16.gguf \5 --image document.png \6 --chat-template "{%- for message in messages -%}{{- '<|start_of_role|>' + message['role'] + '<|end_of_role|>' -}}{%- if message['content'] is string -%}{{- message['content'] -}}{%- else -%}{%- for part in message['content'] -%}{%- if part['type'] == 'text' -%}{{- part['text'] -}}{%- elif part['type'] == 'image' -%}{{- '<image>' -}}{%- endif -%}{%- endfor -%}{%- endif -%}{{- '<|end_of_text|>\n' -}}{%- endfor -%}{%- if add_generation_prompt -%}{{- '<|start_of_role|>assistant' -}}{%- if controls -%}{{- ' ' + controls | tojson() -}}{%- endif -%}{{- '<|end_of_role|>' -}}{%- endif -%}"\7 -p "Convert this page to docling."\8 -n 512\9 --temp 0.1\10 -ngl 991112# Or use any other quantization (Q5_K_M, Q6_K, Q8_0, F16)13# Just replace the -m parameter with your chosen model file
Simplified Usage (Save Chat Template)
Save the chat template to a file for easier reuse:
bash
1# Save chat template2cat> granite_docling_template.jinja <<'EOF'
3{%- for message in messages -%}
4{{- '<|start_of_role|>' + message['role'] + '<|end_of_role|>' -}}
5{%- if message['content'] is string -%}
6{{- message['content'] -}}
7{%- else -%}
8{%- for part in message['content'] -%}
9{%- if part['type'] == 'text' -%}
10{{- part['text'] -}}
11{%- elif part['type'] == 'image' -%}
12{{- '<image>' -}}
13{%- endif -%}
14{%- endfor -%}
15{%- endif -%}
16{{- '<|end_of_text|>
17' -}}
18{%- endfor -%}
19{%- if add_generation_prompt -%}
20{{- '<|start_of_role|>assistant' -}}
21{%- if controls -%}{{- ' ' + controls | tojson() -}}{%- endif -%}
22{{- '<|end_of_role|>' -}}
23{%- endif -%}
24EOF2526# Then use it:27./llama.cpp/build/bin/llama-mtmd-cli \28 -m granite-docling-258M-Q4_K_M.gguf \29 --mmproj mmproj-granite-docling-258M-f16.gguf \30 --image document.png \31 --chat-template "$(cat granite_docling_template.jinja)"\32 -p "Convert this page to docling."\33 -n 512\34 -ngl 99
Choosing a Quantization
Recommended for most users: Q4_K_M - Best balance of size and quality
Quantization
Total Size
Quality
Speed
RAM Usage
Q4_K_M
315 MB
Good
Fastest
~400 MB
Q5_K_M
321 MB
Better
Fast
~420 MB
Q6_K
346 MB
High
Medium
~450 MB
Q8_0
352 MB
Very High
Medium
~480 MB
F16
499 MB
Highest
Slower
~650 MB
Total size = text model + mmproj (182 MB)
Example Output
The model outputs DocTags format with precise layout information:
<doctag>
<page_header><loc_145><loc_28><loc_355><loc_35>ENERGY BUDGET OF WASP-121 b</page_header>
<text><loc_88><loc_42><loc_242><loc_89>while the kernel weights are structured as...</text>
...
</doctag>
Supported Instructions
Description
Instruction
Full conversion
Convert this page to docling.
Chart
Convert chart to table.
Formula
Convert formula to LaTeX.
Code
Convert code to text.
Table
Convert table to OTSL.
OCR region
OCR the text in a specific location: <loc_155><loc_233><loc_206><loc_237>
Performance
Tested on NVIDIA RTX 4070 Ti SUPER with CUDA:
Image encoding: ~6-8ms per slice (17 slices total for 512x512 images)
Prompt processing: ~1305 tokens/sec
Generation speed: ~706 tokens/sec
Total memory: ~600 MB GPU (with all layers offloaded)