Instructions to use google/gemma-4-26B-A4B-it-qat-q4_0-unquantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-26B-A4B-it-qat-q4_0-unquantized with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/gemma-4-26B-A4B-it-qat-q4_0-unquantized") 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/gemma-4-26B-A4B-it-qat-q4_0-unquantized") model = AutoModelForMultimodalLM.from_pretrained("google/gemma-4-26B-A4B-it-qat-q4_0-unquantized", 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/gemma-4-26B-A4B-it-qat-q4_0-unquantized with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-4-26B-A4B-it-qat-q4_0-unquantized" # 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/gemma-4-26B-A4B-it-qat-q4_0-unquantized", "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/gemma-4-26B-A4B-it-qat-q4_0-unquantized
- SGLang
How to use google/gemma-4-26B-A4B-it-qat-q4_0-unquantized 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/gemma-4-26B-A4B-it-qat-q4_0-unquantized" \ --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/gemma-4-26B-A4B-it-qat-q4_0-unquantized", "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/gemma-4-26B-A4B-it-qat-q4_0-unquantized" \ --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/gemma-4-26B-A4B-it-qat-q4_0-unquantized", "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/gemma-4-26B-A4B-it-qat-q4_0-unquantized with Docker Model Runner:
docker model run hf.co/google/gemma-4-26B-A4B-it-qat-q4_0-unquantized
Commit ·
f1e06dc
1
Parent(s): e2b4fdb
Add response_template to tokenizer_config.json (#3)
Browse files- Add response_template to tokenizer_config.json (adf452f0c4515af750405812efb90eddb00323c9)
- Update README.md (5a66bfb145086976e6f76233052962a8d9ca59da)
Co-authored-by: Matthew Carrigan <Rocketknight1@users.noreply.huggingface.co>
- README.md +4 -4
- tokenizer_config.json +46 -0
README.md
CHANGED
|
@@ -181,7 +181,7 @@ outputs = model.generate(**inputs, max_new_tokens=1024)
|
|
| 181 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 182 |
|
| 183 |
# Parse output
|
| 184 |
-
processor.parse_response(response)
|
| 185 |
```
|
| 186 |
|
| 187 |
To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
|
|
@@ -241,7 +241,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
|
|
| 241 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 242 |
|
| 243 |
# Parse output
|
| 244 |
-
processor.parse_response(response)
|
| 245 |
```
|
| 246 |
|
| 247 |
</details>
|
|
@@ -299,7 +299,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
|
|
| 299 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 300 |
|
| 301 |
# Parse output
|
| 302 |
-
processor.parse_response(response)
|
| 303 |
```
|
| 304 |
|
| 305 |
</details>
|
|
@@ -358,7 +358,7 @@ outputs = model.generate(**inputs, max_new_tokens=512)
|
|
| 358 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 359 |
|
| 360 |
# Parse output
|
| 361 |
-
processor.parse_response(response)
|
| 362 |
```
|
| 363 |
|
| 364 |
</details>
|
|
|
|
| 181 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 182 |
|
| 183 |
# Parse output
|
| 184 |
+
processor.parse_response(response, prefix=inputs["input_ids"])
|
| 185 |
```
|
| 186 |
|
| 187 |
To enable reasoning, set `enable_thinking=True` and the `parse_response` function will take care of parsing the thinking output.
|
|
|
|
| 241 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 242 |
|
| 243 |
# Parse output
|
| 244 |
+
processor.parse_response(response, prefix=inputs["input_ids"])
|
| 245 |
```
|
| 246 |
|
| 247 |
</details>
|
|
|
|
| 299 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 300 |
|
| 301 |
# Parse output
|
| 302 |
+
processor.parse_response(response, prefix=inputs["input_ids"])
|
| 303 |
```
|
| 304 |
|
| 305 |
</details>
|
|
|
|
| 358 |
response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
|
| 359 |
|
| 360 |
# Parse output
|
| 361 |
+
processor.parse_response(response, prefix=inputs["input_ids"])
|
| 362 |
```
|
| 363 |
|
| 364 |
</details>
|
tokenizer_config.json
CHANGED
|
@@ -85,6 +85,52 @@
|
|
| 85 |
"type": "object",
|
| 86 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
"soc_token": "<|channel>",
|
| 89 |
"sot_token": "<|turn>",
|
| 90 |
"stc_token": "<|tool_call>",
|
|
|
|
| 85 |
"type": "object",
|
| 86 |
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
| 87 |
},
|
| 88 |
+
"response_template": {
|
| 89 |
+
"defaults": {
|
| 90 |
+
"role": "assistant"
|
| 91 |
+
},
|
| 92 |
+
"fields": {
|
| 93 |
+
"content": {
|
| 94 |
+
"close": [
|
| 95 |
+
"<turn|>",
|
| 96 |
+
"<|tool_response>",
|
| 97 |
+
"<eos>"
|
| 98 |
+
],
|
| 99 |
+
"content": "text"
|
| 100 |
+
},
|
| 101 |
+
"thinking": {
|
| 102 |
+
"close": "<channel|>",
|
| 103 |
+
"content": "text",
|
| 104 |
+
"open": "<|channel>thought\n"
|
| 105 |
+
},
|
| 106 |
+
"tool_calls": {
|
| 107 |
+
"close": "<tool_call|>",
|
| 108 |
+
"content": "json",
|
| 109 |
+
"content_args": {
|
| 110 |
+
"string_delims": [
|
| 111 |
+
[
|
| 112 |
+
"<|\"|>",
|
| 113 |
+
"<|\"|>"
|
| 114 |
+
]
|
| 115 |
+
],
|
| 116 |
+
"unquoted_keys": true
|
| 117 |
+
},
|
| 118 |
+
"open_pattern": "<\\|tool_call>call:(?P<name>\\w+)",
|
| 119 |
+
"repeats": true,
|
| 120 |
+
"transform": {
|
| 121 |
+
"function": {
|
| 122 |
+
"arguments": "{content}",
|
| 123 |
+
"name": "{name}"
|
| 124 |
+
},
|
| 125 |
+
"type": "function"
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
},
|
| 129 |
+
"start_anchor": [
|
| 130 |
+
"<|turn>model\n",
|
| 131 |
+
"<tool_response|>"
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
"soc_token": "<|channel>",
|
| 135 |
"sot_token": "<|turn>",
|
| 136 |
"stc_token": "<|tool_call>",
|