Image-Text-to-Text
Transformers
PyTorch
Safetensors
English
gemma3
torchao
conversational
text-generation-inference
Instructions to use pytorch/gemma-3-12b-it-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pytorch/gemma-3-12b-it-INT4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="pytorch/gemma-3-12b-it-INT4") 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("pytorch/gemma-3-12b-it-INT4") model = AutoModelForMultimodalLM.from_pretrained("pytorch/gemma-3-12b-it-INT4", 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 pytorch/gemma-3-12b-it-INT4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pytorch/gemma-3-12b-it-INT4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pytorch/gemma-3-12b-it-INT4", "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/pytorch/gemma-3-12b-it-INT4
- SGLang
How to use pytorch/gemma-3-12b-it-INT4 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 "pytorch/gemma-3-12b-it-INT4" \ --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": "pytorch/gemma-3-12b-it-INT4", "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 "pytorch/gemma-3-12b-it-INT4" \ --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": "pytorch/gemma-3-12b-it-INT4", "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 pytorch/gemma-3-12b-it-INT4 with Docker Model Runner:
docker model run hf.co/pytorch/gemma-3-12b-it-INT4
Upload Gemma3ForConditionalGeneration
Browse files- config.json +6 -16
- generation_config.json +1 -1
- pytorch_model-00001-of-00002.bin +1 -1
- pytorch_model-00002-of-00002.bin +1 -1
config.json
CHANGED
|
@@ -37,9 +37,7 @@
|
|
| 37 |
"attention_bias": false,
|
| 38 |
"attention_dropout": 0.0,
|
| 39 |
"attn_logit_softcapping": null,
|
| 40 |
-
"bos_token_id": 2,
|
| 41 |
"dtype": "bfloat16",
|
| 42 |
-
"eos_token_id": 1,
|
| 43 |
"final_logit_softcapping": null,
|
| 44 |
"head_dim": 256,
|
| 45 |
"hidden_activation": "gelu_pytorch_tanh",
|
|
@@ -101,28 +99,20 @@
|
|
| 101 |
"num_attention_heads": 16,
|
| 102 |
"num_hidden_layers": 48,
|
| 103 |
"num_key_value_heads": 8,
|
| 104 |
-
"pad_token_id": 0,
|
| 105 |
"query_pre_attn_scalar": 256,
|
| 106 |
"rms_norm_eps": 1e-06,
|
| 107 |
-
"
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
"rope_type": "linear"
|
| 112 |
-
},
|
| 113 |
-
"sliding_attention": {
|
| 114 |
-
"rope_theta": 10000.0,
|
| 115 |
-
"rope_type": "default"
|
| 116 |
-
}
|
| 117 |
},
|
|
|
|
| 118 |
"sliding_window": 1024,
|
| 119 |
-
"tie_word_embeddings": true,
|
| 120 |
"use_bidirectional_attention": false,
|
| 121 |
"use_cache": true,
|
| 122 |
"vocab_size": 262208
|
| 123 |
},
|
| 124 |
-
"
|
| 125 |
-
"transformers_version": "5.3.0.dev0",
|
| 126 |
"vision_config": {
|
| 127 |
"attention_dropout": 0.0,
|
| 128 |
"dtype": "bfloat16",
|
|
|
|
| 37 |
"attention_bias": false,
|
| 38 |
"attention_dropout": 0.0,
|
| 39 |
"attn_logit_softcapping": null,
|
|
|
|
| 40 |
"dtype": "bfloat16",
|
|
|
|
| 41 |
"final_logit_softcapping": null,
|
| 42 |
"head_dim": 256,
|
| 43 |
"hidden_activation": "gelu_pytorch_tanh",
|
|
|
|
| 99 |
"num_attention_heads": 16,
|
| 100 |
"num_hidden_layers": 48,
|
| 101 |
"num_key_value_heads": 8,
|
|
|
|
| 102 |
"query_pre_attn_scalar": 256,
|
| 103 |
"rms_norm_eps": 1e-06,
|
| 104 |
+
"rope_local_base_freq": 10000.0,
|
| 105 |
+
"rope_scaling": {
|
| 106 |
+
"factor": 8.0,
|
| 107 |
+
"rope_type": "linear"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
},
|
| 109 |
+
"rope_theta": 1000000.0,
|
| 110 |
"sliding_window": 1024,
|
|
|
|
| 111 |
"use_bidirectional_attention": false,
|
| 112 |
"use_cache": true,
|
| 113 |
"vocab_size": 262208
|
| 114 |
},
|
| 115 |
+
"transformers_version": "4.57.5",
|
|
|
|
| 116 |
"vision_config": {
|
| 117 |
"attention_dropout": 0.0,
|
| 118 |
"dtype": "bfloat16",
|
generation_config.json
CHANGED
|
@@ -9,5 +9,5 @@
|
|
| 9 |
"pad_token_id": 0,
|
| 10 |
"top_k": 64,
|
| 11 |
"top_p": 0.95,
|
| 12 |
-
"transformers_version": "
|
| 13 |
}
|
|
|
|
| 9 |
"pad_token_id": 0,
|
| 10 |
"top_k": 64,
|
| 11 |
"top_p": 0.95,
|
| 12 |
+
"transformers_version": "4.57.5"
|
| 13 |
}
|
pytorch_model-00001-of-00002.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 4987220254
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:63a7663d62a5836930dafbaafbff8677a8ede00d7fea25f02edae47be7582af7
|
| 3 |
size 4987220254
|
pytorch_model-00002-of-00002.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 3548065976
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5b4267d1d5a99e0fb1ee13b147870388144f86244bf5b72ddd350298bee63e73
|
| 3 |
size 3548065976
|