Image-Text-to-Text
Transformers
Safetensors
llava_next
Generated from Trainer
sft
trl
conversational
text-generation-inference
Instructions to use ibm-granite/granite-vision-3.3-2b-chart2csv-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-vision-3.3-2b-chart2csv-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ibm-granite/granite-vision-3.3-2b-chart2csv-preview") 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-vision-3.3-2b-chart2csv-preview") model = AutoModelForMultimodalLM.from_pretrained("ibm-granite/granite-vision-3.3-2b-chart2csv-preview", 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-vision-3.3-2b-chart2csv-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ibm-granite/granite-vision-3.3-2b-chart2csv-preview" # 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-vision-3.3-2b-chart2csv-preview", "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-vision-3.3-2b-chart2csv-preview
- SGLang
How to use ibm-granite/granite-vision-3.3-2b-chart2csv-preview 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-vision-3.3-2b-chart2csv-preview" \ --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-vision-3.3-2b-chart2csv-preview", "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-vision-3.3-2b-chart2csv-preview" \ --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-vision-3.3-2b-chart2csv-preview", "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-vision-3.3-2b-chart2csv-preview with Docker Model Runner:
docker model run hf.co/ibm-granite/granite-vision-3.3-2b-chart2csv-preview
| { | |
| "architectures": [ | |
| "LlavaNextForConditionalGeneration" | |
| ], | |
| "bos_token_id": 0, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 0, | |
| "image_grid_pinpoints": [ | |
| [ | |
| 384, | |
| 768 | |
| ], | |
| [ | |
| 384, | |
| 1152 | |
| ], | |
| [ | |
| 384, | |
| 1536 | |
| ], | |
| [ | |
| 384, | |
| 1920 | |
| ], | |
| [ | |
| 384, | |
| 2304 | |
| ], | |
| [ | |
| 384, | |
| 2688 | |
| ], | |
| [ | |
| 384, | |
| 3072 | |
| ], | |
| [ | |
| 384, | |
| 3456 | |
| ], | |
| [ | |
| 384, | |
| 3840 | |
| ], | |
| [ | |
| 768, | |
| 384 | |
| ], | |
| [ | |
| 768, | |
| 768 | |
| ], | |
| [ | |
| 768, | |
| 1152 | |
| ], | |
| [ | |
| 768, | |
| 1536 | |
| ], | |
| [ | |
| 768, | |
| 1920 | |
| ], | |
| [ | |
| 1152, | |
| 384 | |
| ], | |
| [ | |
| 1152, | |
| 768 | |
| ], | |
| [ | |
| 1152, | |
| 1152 | |
| ], | |
| [ | |
| 1536, | |
| 384 | |
| ], | |
| [ | |
| 1536, | |
| 768 | |
| ], | |
| [ | |
| 1920, | |
| 384 | |
| ], | |
| [ | |
| 1920, | |
| 768 | |
| ], | |
| [ | |
| 2304, | |
| 384 | |
| ], | |
| [ | |
| 2688, | |
| 384 | |
| ], | |
| [ | |
| 3072, | |
| 384 | |
| ], | |
| [ | |
| 3456, | |
| 384 | |
| ], | |
| [ | |
| 3840, | |
| 384 | |
| ] | |
| ], | |
| "image_seq_length": 576, | |
| "image_token_index": 49155, | |
| "model_type": "llava_next", | |
| "multimodal_projector_bias": true, | |
| "pad_token_id": 0, | |
| "pretrained_language_model": "", | |
| "pretrained_vision_tower": "", | |
| "projector_hidden_act": "gelu", | |
| "text_config": { | |
| "_attn_implementation_autoset": true, | |
| "_name_or_path": "ibm-granite/granite-3.1-2b-instruct", | |
| "architectures": [ | |
| "GraniteForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.1, | |
| "attention_multiplier": 0.015625, | |
| "bos_token_id": 0, | |
| "dtype": "bfloat16", | |
| "embedding_multiplier": 12.0, | |
| "eos_token_id": 0, | |
| "hidden_act": "silu", | |
| "hidden_size": 2048, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 8192, | |
| "logits_scaling": 8.0, | |
| "max_position_embeddings": 131072, | |
| "mlp_bias": false, | |
| "model_type": "granite", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 40, | |
| "num_key_value_heads": 8, | |
| "pad_token_id": 0, | |
| "residual_multiplier": 0.22, | |
| "rms_norm_eps": 1e-05, | |
| "rope_scaling": null, | |
| "rope_theta": 300000, | |
| "tie_word_embeddings": true, | |
| "use_cache": true, | |
| "vocab_size": 49156 | |
| }, | |
| "tie_word_embeddings": true, | |
| "transformers_version": "4.56.2", | |
| "use_image_newline_parameter": true, | |
| "vision_config": { | |
| "_attn_implementation_autoset": true, | |
| "attention_dropout": 0.0, | |
| "dtype": "bfloat16", | |
| "hidden_act": "gelu_pytorch_tanh", | |
| "hidden_size": 1152, | |
| "image_size": 384, | |
| "intermediate_size": 4304, | |
| "layer_norm_eps": 1e-06, | |
| "model_type": "siglip_vision_model", | |
| "num_attention_heads": 16, | |
| "num_channels": 3, | |
| "num_hidden_layers": 27, | |
| "patch_size": 14 | |
| }, | |
| "vision_feature_layer": [ | |
| -24, | |
| -20, | |
| -12, | |
| -1 | |
| ], | |
| "vision_feature_select_strategy": "full" | |
| } | |