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
Add Troubleshooting section to README (#23)
Browse files- Add Troubleshooting section to README (10ae2e8a5590ace87c70eadead48c12532ce6cad)
README.md
CHANGED
|
@@ -35,7 +35,7 @@ library_name: transformers
|
|
| 35 |
|
| 36 |
**Model Summary**:
|
| 37 |
|
| 38 |
-
Granite Docling 258M builds upon the
|
| 39 |
|
| 40 |
- **Developed by**: IBM Research
|
| 41 |
- **Model type**: Multi-modal model (image+text-to-text)
|
|
@@ -292,6 +292,8 @@ print(f"Total time: {time.time() - start_time:.2f} sec")
|
|
| 292 |
|
| 293 |
💻 Local inference on Apple Silicon with MLX: [see here](https://huggingface.co/ibm-granite/granite-docling-258M-mlx)
|
| 294 |
|
|
|
|
|
|
|
| 295 |
## Intended Use
|
| 296 |
Granite-Docling is designed to complement the Docling library, not replace it. It integrates as a component within larger Docling library, consolidating the functions of multiple single-purpose models into a single, compact VLM.
|
| 297 |
However, Granite-Docling is **not** intended for general image understanding. For tasks focused solely on image-text input, we recommend using [Granite Vision models](https://huggingface.co/collections/ibm-granite/granite-vision-models-67b3bd4ff90c915ba4cd2800), which are purpose-built and optimized for image-text processing.
|
|
@@ -533,4 +535,49 @@ Its training, which includes both human-annotated and synthetic data informed by
|
|
| 533 |
- ⭐️ Learn about the latest updates with Docling: https://docling-project.github.io/docling/#features
|
| 534 |
- 🚀 Get started with Docling concepts, integrations and tutorials: https://docling-project.github.io/docling/getting_started/
|
| 535 |
- 💡 Learn about the latest Granite learning resources: https://ibm.biz/granite-learning-resources
|
| 536 |
-
- 🖥️ Learn more about how to use Granite-Docling, explore the Docling library, and see what’s coming next for Docling in the release blog: https://ibm.com/new/announcements/granite-docling-end-to-end-document-conversion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
**Model Summary**:
|
| 37 |
|
| 38 |
+
Granite Docling 258M builds upon the Idefics3 architecture, but introduces two key modifications: it replaces the vision encoder with siglip2-base-patch16-512 and substitutes the language model with a Granite 165M LLM. Try out our [Granite-Docling-258](https://huggingface.co/spaces/ibm-granite/granite-docling-258m-demo) demo today.
|
| 39 |
|
| 40 |
- **Developed by**: IBM Research
|
| 41 |
- **Model type**: Multi-modal model (image+text-to-text)
|
|
|
|
| 292 |
|
| 293 |
💻 Local inference on Apple Silicon with MLX: [see here](https://huggingface.co/ibm-granite/granite-docling-258M-mlx)
|
| 294 |
|
| 295 |
+
ℹ️ If you see trouble running granite-docling with the codes above, check the troubleshooting section at the bottom ⬇️.
|
| 296 |
+
|
| 297 |
## Intended Use
|
| 298 |
Granite-Docling is designed to complement the Docling library, not replace it. It integrates as a component within larger Docling library, consolidating the functions of multiple single-purpose models into a single, compact VLM.
|
| 299 |
However, Granite-Docling is **not** intended for general image understanding. For tasks focused solely on image-text input, we recommend using [Granite Vision models](https://huggingface.co/collections/ibm-granite/granite-vision-models-67b3bd4ff90c915ba4cd2800), which are purpose-built and optimized for image-text processing.
|
|
|
|
| 535 |
- ⭐️ Learn about the latest updates with Docling: https://docling-project.github.io/docling/#features
|
| 536 |
- 🚀 Get started with Docling concepts, integrations and tutorials: https://docling-project.github.io/docling/getting_started/
|
| 537 |
- 💡 Learn about the latest Granite learning resources: https://ibm.biz/granite-learning-resources
|
| 538 |
+
- 🖥️ Learn more about how to use Granite-Docling, explore the Docling library, and see what’s coming next for Docling in the release blog: https://ibm.com/new/announcements/granite-docling-end-to-end-document-conversion
|
| 539 |
+
|
| 540 |
+
## Troubleshooting
|
| 541 |
+
|
| 542 |
+
**Running with VLLM**
|
| 543 |
+
|
| 544 |
+
1. You receive `AttributeError: 'LlamaModel' object has no attribute 'wte'` when launching the model through VLLM.
|
| 545 |
+
|
| 546 |
+
With current versions of VLLM (including 0.10.2), support for tied weights as used in granite-docling is limited and breaks. We provide a version with untied weights on the `untied` branch of this model repo.
|
| 547 |
+
To use the untied version, please pass the `revision` argument to VLLM:
|
| 548 |
+
|
| 549 |
+
```sh
|
| 550 |
+
# Serve the model through VLLM
|
| 551 |
+
$> vllm serve ibm-granite/granite-docling-258M --revision untied
|
| 552 |
+
```
|
| 553 |
+
|
| 554 |
+
```python
|
| 555 |
+
# If using the VLLM python SDK:
|
| 556 |
+
from vllm import LLM
|
| 557 |
+
...
|
| 558 |
+
|
| 559 |
+
llm = LLM(model=MODEL_PATH, revision="untied", limit_mm_per_prompt={"image": 1})
|
| 560 |
+
```
|
| 561 |
+
|
| 562 |
+
2. The model outputs only exclamation marks (i.e. "!!!!!!!!!!!!!!!").
|
| 563 |
+
|
| 564 |
+
This is seen on older NVIDIA GPUs, such as the T4 GPU available in Google Colab, because it lacks support for `bfloat16` format.
|
| 565 |
+
You can work around it by setting the `dtype` to `float32`.
|
| 566 |
+
|
| 567 |
+
```sh
|
| 568 |
+
# Serve the model through VLLM
|
| 569 |
+
$> vllm serve ibm-granite/granite-docling-258M --revision untied --dtype float32
|
| 570 |
+
```
|
| 571 |
+
|
| 572 |
+
```python
|
| 573 |
+
# If using the VLLM python SDK:
|
| 574 |
+
from vllm import LLM
|
| 575 |
+
...
|
| 576 |
+
|
| 577 |
+
llm = LLM(model=MODEL_PATH, revision="untied", limit_mm_per_prompt={"image": 1}, dtype="float32")
|
| 578 |
+
```
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
|