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
v0.0.2 (#3)
Browse files- v0.0.2 (ecba62ead2399d4df4d3f69a180419e09d2dbb67)
- config.json +3 -10
- generation_config.json +2 -2
- merges.txt +0 -0
- model.safetensors +1 -1
- tokenizer_config.json +3 -3
- trainer_state.json +0 -0
config.json
CHANGED
|
@@ -5,20 +5,14 @@
|
|
| 5 |
],
|
| 6 |
"attention_bias": false,
|
| 7 |
"attention_dropout": 0.0,
|
| 8 |
-
"bos_token_id":
|
| 9 |
-
"eos_token_id":
|
| 10 |
-
"freeze_lm_head": true,
|
| 11 |
-
"freeze_text_layers": true,
|
| 12 |
-
"freeze_text_module_exceptions": [],
|
| 13 |
-
"freeze_vision_layers": true,
|
| 14 |
-
"freeze_vision_module_exceptions": [],
|
| 15 |
"head_dim": 64,
|
| 16 |
"hidden_act": "silu",
|
| 17 |
"hidden_size": 576,
|
| 18 |
"image_token_id": 100270,
|
| 19 |
"initializer_range": 0.02,
|
| 20 |
"intermediate_size": 1536,
|
| 21 |
-
"lm_head_path": "/data1/checkpoints/v06-granite165m/step_2000000_ckp/",
|
| 22 |
"max_position_embeddings": 8192,
|
| 23 |
"mlp_bias": false,
|
| 24 |
"model_type": "idefics3",
|
|
@@ -47,7 +41,7 @@
|
|
| 47 |
"scale_factor": 4,
|
| 48 |
"text_config": {
|
| 49 |
"architectures": [
|
| 50 |
-
"
|
| 51 |
],
|
| 52 |
"attention_bias": false,
|
| 53 |
"attention_dropout": 0.0,
|
|
@@ -68,7 +62,6 @@
|
|
| 68 |
"rms_norm_eps": 1e-05,
|
| 69 |
"rope_scaling": null,
|
| 70 |
"rope_theta": 10000.0,
|
| 71 |
-
"tie_word_embeddings": true,
|
| 72 |
"torch_dtype": "bfloat16",
|
| 73 |
"use_cache": true,
|
| 74 |
"vocab_size": 100480
|
|
|
|
| 5 |
],
|
| 6 |
"attention_bias": false,
|
| 7 |
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 100264,
|
| 9 |
+
"eos_token_id": 100338,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"head_dim": 64,
|
| 11 |
"hidden_act": "silu",
|
| 12 |
"hidden_size": 576,
|
| 13 |
"image_token_id": 100270,
|
| 14 |
"initializer_range": 0.02,
|
| 15 |
"intermediate_size": 1536,
|
|
|
|
| 16 |
"max_position_embeddings": 8192,
|
| 17 |
"mlp_bias": false,
|
| 18 |
"model_type": "idefics3",
|
|
|
|
| 41 |
"scale_factor": 4,
|
| 42 |
"text_config": {
|
| 43 |
"architectures": [
|
| 44 |
+
"llama"
|
| 45 |
],
|
| 46 |
"attention_bias": false,
|
| 47 |
"attention_dropout": 0.0,
|
|
|
|
| 62 |
"rms_norm_eps": 1e-05,
|
| 63 |
"rope_scaling": null,
|
| 64 |
"rope_theta": 10000.0,
|
|
|
|
| 65 |
"torch_dtype": "bfloat16",
|
| 66 |
"use_cache": true,
|
| 67 |
"vocab_size": 100480
|
generation_config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
-
"bos_token_id":
|
| 4 |
-
"eos_token_id":
|
| 5 |
"pad_token_id": 128002,
|
| 6 |
"transformers_version": "4.53.0.dev0"
|
| 7 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 100264,
|
| 4 |
+
"eos_token_id": 100338,
|
| 5 |
"pad_token_id": 128002,
|
| 6 |
"transformers_version": "4.53.0.dev0"
|
| 7 |
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 630993616
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:92d6fa41f9edcb5ef51f9ac1844edb11dfdaf403473351d1ddbee0e883e42f25
|
| 3 |
size 630993616
|
tokenizer_config.json
CHANGED
|
@@ -1064,12 +1064,12 @@
|
|
| 1064 |
"<image>",
|
| 1065 |
"<end_of_utterance>"
|
| 1066 |
],
|
| 1067 |
-
"bos_token": "<|
|
| 1068 |
"clean_up_tokenization_spaces": false,
|
| 1069 |
-
"eos_token": "<|
|
| 1070 |
"errors": "replace",
|
| 1071 |
"extra_special_tokens": {},
|
| 1072 |
-
"model_max_length":
|
| 1073 |
"pad_token": "<|pad|>",
|
| 1074 |
"padding_side": "left",
|
| 1075 |
"processor_class": "Idefics3Processor",
|
|
|
|
| 1064 |
"<image>",
|
| 1065 |
"<end_of_utterance>"
|
| 1066 |
],
|
| 1067 |
+
"bos_token": "<|start_of_role|>",
|
| 1068 |
"clean_up_tokenization_spaces": false,
|
| 1069 |
+
"eos_token": "<|end_of_utterance|>",
|
| 1070 |
"errors": "replace",
|
| 1071 |
"extra_special_tokens": {},
|
| 1072 |
+
"model_max_length": 8192,
|
| 1073 |
"pad_token": "<|pad|>",
|
| 1074 |
"padding_side": "left",
|
| 1075 |
"processor_class": "Idefics3Processor",
|
trainer_state.json
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|