Instructions to use ibm-granite/granite-docling-258M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-docling-258M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ibm-granite/granite-docling-258M") 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("ibm-granite/granite-docling-258M") model = AutoModelForMultimodalLM.from_pretrained("ibm-granite/granite-docling-258M", 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 ibm-granite/granite-docling-258M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-granite/granite-docling-258M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ibm-granite/granite-docling-258M", "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/ibm-granite/granite-docling-258M
- SGLang
How to use ibm-granite/granite-docling-258M 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 "ibm-granite/granite-docling-258M" \ --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": "ibm-granite/granite-docling-258M", "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 "ibm-granite/granite-docling-258M" \ --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": "ibm-granite/granite-docling-258M", "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 ibm-granite/granite-docling-258M with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-docling-258M
having trouble with efficiency/speed
took 6 minutes to do an extraction of a simple pdf.... also thought it would handle images better with better captioning and whatnot. wondering what i am doing wrong if someone can help. i can only upload images here... but happy to share the pdf with anyone who cares. i have an rtx 5090 i'm running it with... and it took 6 minutes for this pdf https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5056871 (ml) PS C:\Users\xxxxxxxxx> docling --to md --pipeline vlm --vlm-model granite_docling -v $pdf_path --output "C:\Users\xxxxxxx\Documents\Python Scripts\docling_test\out"
2025-10-02 21:11:31,049 - INFO - Loading plugin 'docling_defaults'
2025-10-02 21:11:31,051 - INFO - Registered ocr engines: ['easyocr', 'ocrmac', 'rapidocr', 'tesserocr', 'tesseract']
2025-10-02 21:11:31,060 - INFO - paths: [WindowsPath('C:/tmp/tmphx7vtdt2/ssrn-5056871.pdf')]
2025-10-02 21:11:31,069 - INFO - detected formats: [<InputFormat.PDF: 'pdf'>]
2025-10-02 21:11:31,100 - INFO - Going to convert document batch...
2025-10-02 21:11:31,100 - INFO - Initializing pipeline for VlmPipeline with options hash 14b35a24912cc09d5c7735b8ff9d88c1
2025-10-02 21:11:31,111 - INFO - Loading plugin 'docling_defaults'
2025-10-02 21:11:31,111 - INFO - Registered picture descriptions: ['vlm', 'api']
2025-10-02 21:11:31,128 - INFO - Accelerator device: 'cuda:0'
2025-10-02 21:11:32,998 - INFO - Processing document ssrn-5056871.pdf
2025-10-02 21:18:10,215 - INFO - Finished converting document ssrn-5056871.pdf in 399.16 sec.
2025-10-02 21:18:10,215 - INFO - writing Markdown output to C:\Users\ishan\Documents\Python Scripts\docling_test\out\ssrn-5056871.md
2025-10-02 21:18:10,231 - INFO - Processed 1 docs, of which 0 failed
2025-10-02 21:18:10,235 - INFO - All documents were converted in 399.17 seconds.
We have also this problem performance, would be big help if has a fix or solution