Image-Text-to-Text
Transformers
Safetensors
English
idefics3
text-generation
documents
code
formula
chart
ocr
layout
table
document-parse
docling
granite
extraction
math
conversational
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)# 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=40) 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
Commit History
Update README.md 377322a verified
Update README.md a1ff0fe verified
Update README.md 5289190 verified
Update README.md da240aa verified
Update README.md 0281789 verified
Update README.md 9e1ee78 verified
Update README.md (#9) a709291 verified
Update README.md 2e257e0 verified
Update README.md (#8) b0d56bd verified
Update README.md 3299088 verified
Upload granite_docling_split_page.png 3e1f4b0 verified
Update README.md 906d75c verified
Update README.md 46d5666 verified
Update README.md 595d39b verified
Update README.md 24a14e1 verified
Update README.md 65f280a verified
Update README.md f0856a8 verified
Update README.md 9a7beaf verified
Update README.md (#6) a0903a5 verified
Upload assets/new_arxiv.png with huggingface_hub 3beb7d8 verified
Update README.md (#5) 40d7a97 verified
Update README.md 5ead9c9 verified
Update README.md 7e97417 verified
Update README.md cbc889a verified
Update README.md cd1a8df verified
Update README.md 6d56bf5 verified
Update README.md be2da5a verified
Pre release update. 22024b7
Update README.md f3e9d3a verified
Update README.md 0e8c0b2 verified
Update README.md c5b5483 verified
Update README.md 8b625a8 verified
Update README.md 4492f6a verified
Upload config.json c8f0b3a verified
updated logo cc7f1e5 verified
init checkpoint and chat template 341382d
Ahmed Nassar AHN@zurich.ibm.com commited on
tokenizer and config 2d59cb9
Ahmed Nassar AHN@zurich.ibm.com commited on