Instructions to use google/gemma-4-31B-it-qat-q4_0-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/gemma-4-31B-it-qat-q4_0-gguf") 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 AutoModel model = AutoModel.from_pretrained("google/gemma-4-31B-it-qat-q4_0-gguf", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use google/gemma-4-31B-it-qat-q4_0-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 # Run inference directly in the terminal: llama cli -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 # Run inference directly in the terminal: llama cli -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Use Docker
docker model run hf.co/google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
- LM Studio
- Jan
- vLLM
How to use google/gemma-4-31B-it-qat-q4_0-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-4-31B-it-qat-q4_0-gguf" # 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-31B-it-qat-q4_0-gguf", "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-31B-it-qat-q4_0-gguf:Q4_0
- SGLang
How to use google/gemma-4-31B-it-qat-q4_0-gguf 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-31B-it-qat-q4_0-gguf" \ --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-31B-it-qat-q4_0-gguf", "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-31B-it-qat-q4_0-gguf" \ --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-31B-it-qat-q4_0-gguf", "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" } } ] } ] }' - Ollama
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Ollama:
ollama run hf.co/google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
- Unsloth Desktop
- Pi
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Docker Model Runner:
docker model run hf.co/google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
- Lemonade
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Run and chat with the model
lemonade run user.gemma-4-31B-it-qat-q4_0-gguf-Q4_0
List all available models
lemonade list
- Hermes Agent
How to use google/gemma-4-31B-it-qat-q4_0-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use google/gemma-4-31B-it-qat-q4_0-gguf with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Update README (#6)
Browse files- Update README (bc00008e1556cbb0e7463746f17cbed83a541027)
README.md
CHANGED
|
@@ -29,6 +29,7 @@ base_model:
|
|
| 29 |
> * **GGUF** (Q4_0): Ready-to-deploy formats for broad ecosystem compatibility. Available for Gemma 4 E2B, E4B, 12B, 26B A4B, and 31B.
|
| 30 |
> * **Mobile-optimized** (wNa8o8): A custom schema engineered explicitly for mobile hardware efficiency. It features targeted 2-bit decoding layers, optimized KV caches, and static activations to maximize VRAM savings. Available for Gemma 4 E2B and E4B.
|
| 31 |
> * **Compressed Tensors** (w4a16): QAT checkpoints serialized in the compressed-tensors format for native, optimized inference with vLLM. Available for Gemma 4 E2B, E4B, 12B, and 31B.
|
|
|
|
| 32 |
|
| 33 |
Gemma is a family of open models built by Google DeepMind. Gemma 4 models are multimodal, handling text and image input (with audio supported on E2B, E4B, and 12B) and generating text output. This release includes open-weights models in both pre-trained and instruction-tuned variants. Gemma 4 features a context window of up to 256K tokens and maintains multilingual support in over 140 languages.
|
| 34 |
|
|
@@ -144,7 +145,7 @@ Once you have everything installed, you can proceed to load the model with the c
|
|
| 144 |
```python
|
| 145 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 146 |
|
| 147 |
-
MODEL_ID = "google/gemma-4-
|
| 148 |
|
| 149 |
# Load model
|
| 150 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
@@ -199,7 +200,7 @@ You can then load the model with the code below:
|
|
| 199 |
```python
|
| 200 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 201 |
|
| 202 |
-
MODEL_ID = "google/gemma-4-
|
| 203 |
|
| 204 |
# Load model
|
| 205 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
@@ -258,7 +259,7 @@ You can then load the model with the code below:
|
|
| 258 |
```python
|
| 259 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 260 |
|
| 261 |
-
MODEL_ID = "google/gemma-4-
|
| 262 |
|
| 263 |
# Load model
|
| 264 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
@@ -316,7 +317,7 @@ You can then load the model with the code below:
|
|
| 316 |
```python
|
| 317 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 318 |
|
| 319 |
-
MODEL_ID = "google/gemma-4-
|
| 320 |
|
| 321 |
# Load model
|
| 322 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
@@ -391,7 +392,7 @@ Compared to Gemma 3, the models use standard `system`, `assistant`, and `user` r
|
|
| 391 |
|
| 392 |
### 3. Multi-Turn Conversations
|
| 393 |
|
| 394 |
-
* **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final response. Thoughts from previous model turns must *not be added* before the next user turn begins.
|
| 395 |
|
| 396 |
### 4. Modality order
|
| 397 |
|
|
|
|
| 29 |
> * **GGUF** (Q4_0): Ready-to-deploy formats for broad ecosystem compatibility. Available for Gemma 4 E2B, E4B, 12B, 26B A4B, and 31B.
|
| 30 |
> * **Mobile-optimized** (wNa8o8): A custom schema engineered explicitly for mobile hardware efficiency. It features targeted 2-bit decoding layers, optimized KV caches, and static activations to maximize VRAM savings. Available for Gemma 4 E2B and E4B.
|
| 31 |
> * **Compressed Tensors** (w4a16): QAT checkpoints serialized in the compressed-tensors format for native, optimized inference with vLLM. Available for Gemma 4 E2B, E4B, 12B, and 31B.
|
| 32 |
+
> * **Assistant Compatibility**: When using multi-token prediction (speculative decoding) with an assistant model alongside a QAT target model, the assistant model must also be a QAT checkpoint with the same precision to ensure compatibility.
|
| 33 |
|
| 34 |
Gemma is a family of open models built by Google DeepMind. Gemma 4 models are multimodal, handling text and image input (with audio supported on E2B, E4B, and 12B) and generating text output. This release includes open-weights models in both pre-trained and instruction-tuned variants. Gemma 4 features a context window of up to 256K tokens and maintains multilingual support in over 140 languages.
|
| 35 |
|
|
|
|
| 145 |
```python
|
| 146 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 147 |
|
| 148 |
+
MODEL_ID = "google/gemma-4-31B-it"
|
| 149 |
|
| 150 |
# Load model
|
| 151 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
|
|
| 200 |
```python
|
| 201 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 202 |
|
| 203 |
+
MODEL_ID = "google/gemma-4-31B-it"
|
| 204 |
|
| 205 |
# Load model
|
| 206 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
|
|
| 259 |
```python
|
| 260 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 261 |
|
| 262 |
+
MODEL_ID = "google/gemma-4-31B-it"
|
| 263 |
|
| 264 |
# Load model
|
| 265 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
|
|
| 317 |
```python
|
| 318 |
from transformers import AutoProcessor, AutoModelForMultimodalLM
|
| 319 |
|
| 320 |
+
MODEL_ID = "google/gemma-4-31B-it"
|
| 321 |
|
| 322 |
# Load model
|
| 323 |
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
|
|
|
| 392 |
|
| 393 |
### 3. Multi-Turn Conversations
|
| 394 |
|
| 395 |
+
* **No Thinking Content in History**: In multi-turn conversations, the historical model output should only include the final response. Thoughts from previous model turns must *not be added* before the next user turn begins, with the exception of tool call turns where thinking content should be preserved.
|
| 396 |
|
| 397 |
### 4. Modality order
|
| 398 |
|