Instructions to use google/diffusiongemma-26B-A4B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/diffusiongemma-26B-A4B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/diffusiongemma-26B-A4B-it") 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("google/diffusiongemma-26B-A4B-it") model = AutoModelForMultimodalLM.from_pretrained("google/diffusiongemma-26B-A4B-it") 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 google/diffusiongemma-26B-A4B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/diffusiongemma-26B-A4B-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/diffusiongemma-26B-A4B-it", "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/google/diffusiongemma-26B-A4B-it
- SGLang
How to use google/diffusiongemma-26B-A4B-it 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 "google/diffusiongemma-26B-A4B-it" \ --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": "google/diffusiongemma-26B-A4B-it", "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 "google/diffusiongemma-26B-A4B-it" \ --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": "google/diffusiongemma-26B-A4B-it", "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 google/diffusiongemma-26B-A4B-it with Docker Model Runner:
docker model run hf.co/google/diffusiongemma-26B-A4B-it
Raise per-image vision soft-token budget from 280 to 1120
#24
by lucianommartins - opened
- config.json +2 -2
- processor_config.json +3 -3
config.json
CHANGED
|
@@ -93,7 +93,7 @@
|
|
| 93 |
"attention_bias": false,
|
| 94 |
"attention_dropout": 0.0,
|
| 95 |
"chunk_size_feed_forward": 0,
|
| 96 |
-
"default_output_length":
|
| 97 |
"dtype": "bfloat16",
|
| 98 |
"global_head_dim": 72,
|
| 99 |
"head_dim": 72,
|
|
@@ -130,5 +130,5 @@
|
|
| 130 |
"standardize": true,
|
| 131 |
"use_clipped_linears": false
|
| 132 |
},
|
| 133 |
-
"vision_soft_tokens_per_image":
|
| 134 |
}
|
|
|
|
| 93 |
"attention_bias": false,
|
| 94 |
"attention_dropout": 0.0,
|
| 95 |
"chunk_size_feed_forward": 0,
|
| 96 |
+
"default_output_length": 1120,
|
| 97 |
"dtype": "bfloat16",
|
| 98 |
"global_head_dim": 72,
|
| 99 |
"head_dim": 72,
|
|
|
|
| 130 |
"standardize": true,
|
| 131 |
"use_clipped_linears": false
|
| 132 |
},
|
| 133 |
+
"vision_soft_tokens_per_image": 1120
|
| 134 |
}
|
processor_config.json
CHANGED
|
@@ -33,19 +33,19 @@
|
|
| 33 |
0.0
|
| 34 |
],
|
| 35 |
"image_processor_type": "Gemma4ImageProcessor",
|
| 36 |
-
"image_seq_length":
|
| 37 |
"image_std": [
|
| 38 |
1.0,
|
| 39 |
1.0,
|
| 40 |
1.0
|
| 41 |
],
|
| 42 |
-
"max_soft_tokens":
|
| 43 |
"patch_size": 16,
|
| 44 |
"pooling_kernel_size": 3,
|
| 45 |
"resample": 3,
|
| 46 |
"rescale_factor": 0.00392156862745098
|
| 47 |
},
|
| 48 |
-
"image_seq_length":
|
| 49 |
"processor_class": "Gemma4Processor",
|
| 50 |
"video_processor": {
|
| 51 |
"do_convert_rgb": true,
|
|
|
|
| 33 |
0.0
|
| 34 |
],
|
| 35 |
"image_processor_type": "Gemma4ImageProcessor",
|
| 36 |
+
"image_seq_length": 1120,
|
| 37 |
"image_std": [
|
| 38 |
1.0,
|
| 39 |
1.0,
|
| 40 |
1.0
|
| 41 |
],
|
| 42 |
+
"max_soft_tokens": 1120,
|
| 43 |
"patch_size": 16,
|
| 44 |
"pooling_kernel_size": 3,
|
| 45 |
"resample": 3,
|
| 46 |
"rescale_factor": 0.00392156862745098
|
| 47 |
},
|
| 48 |
+
"image_seq_length": 1120,
|
| 49 |
"processor_class": "Gemma4Processor",
|
| 50 |
"video_processor": {
|
| 51 |
"do_convert_rgb": true,
|