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
token_alignment (#13)
Browse files- tokenizer alignment (48d1631122017c80068ff7cf45d1138820a6142b)
- special_tokens_map.json +0 -7
- tokenizer.json +0 -9
- tokenizer_config.json +1 -10
special_tokens_map.json
CHANGED
|
@@ -13,13 +13,6 @@
|
|
| 13 |
"normalized": false,
|
| 14 |
"rstrip": false,
|
| 15 |
"single_word": false
|
| 16 |
-
},
|
| 17 |
-
{
|
| 18 |
-
"content": "<end_of_utterance>",
|
| 19 |
-
"lstrip": false,
|
| 20 |
-
"normalized": false,
|
| 21 |
-
"rstrip": false,
|
| 22 |
-
"single_word": false
|
| 23 |
}
|
| 24 |
],
|
| 25 |
"bos_token": {
|
|
|
|
| 13 |
"normalized": false,
|
| 14 |
"rstrip": false,
|
| 15 |
"single_word": false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
],
|
| 18 |
"bos_token": {
|
tokenizer.json
CHANGED
|
@@ -866,15 +866,6 @@
|
|
| 866 |
"rstrip": false,
|
| 867 |
"normalized": false,
|
| 868 |
"special": true
|
| 869 |
-
},
|
| 870 |
-
{
|
| 871 |
-
"id": 100352,
|
| 872 |
-
"content": "<end_of_utterance>",
|
| 873 |
-
"single_word": false,
|
| 874 |
-
"lstrip": false,
|
| 875 |
-
"rstrip": false,
|
| 876 |
-
"normalized": false,
|
| 877 |
-
"special": true
|
| 878 |
}
|
| 879 |
],
|
| 880 |
"normalizer": null,
|
|
|
|
| 866 |
"rstrip": false,
|
| 867 |
"normalized": false,
|
| 868 |
"special": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
}
|
| 870 |
],
|
| 871 |
"normalizer": null,
|
tokenizer_config.json
CHANGED
|
@@ -769,20 +769,11 @@
|
|
| 769 |
"rstrip": false,
|
| 770 |
"single_word": false,
|
| 771 |
"special": true
|
| 772 |
-
},
|
| 773 |
-
"100352": {
|
| 774 |
-
"content": "<end_of_utterance>",
|
| 775 |
-
"lstrip": false,
|
| 776 |
-
"normalized": false,
|
| 777 |
-
"rstrip": false,
|
| 778 |
-
"single_word": false,
|
| 779 |
-
"special": true
|
| 780 |
}
|
| 781 |
},
|
| 782 |
"additional_special_tokens": [
|
| 783 |
"<fake_token_around_image>",
|
| 784 |
-
"<image>"
|
| 785 |
-
"<end_of_utterance>"
|
| 786 |
],
|
| 787 |
"bos_token": "<|start_of_role|>",
|
| 788 |
"clean_up_tokenization_spaces": false,
|
|
|
|
| 769 |
"rstrip": false,
|
| 770 |
"single_word": false,
|
| 771 |
"special": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
}
|
| 773 |
},
|
| 774 |
"additional_special_tokens": [
|
| 775 |
"<fake_token_around_image>",
|
| 776 |
+
"<image>"
|
|
|
|
| 777 |
],
|
| 778 |
"bos_token": "<|start_of_role|>",
|
| 779 |
"clean_up_tokenization_spaces": false,
|