Instructions to use batiai/gemma-4-31B-it-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use batiai/gemma-4-31B-it-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 batiai/gemma-4-31B-it-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
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 batiai/gemma-4-31B-it-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
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 batiai/gemma-4-31B-it-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
Use Docker
docker model run hf.co/batiai/gemma-4-31B-it-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use batiai/gemma-4-31B-it-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "batiai/gemma-4-31B-it-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": "batiai/gemma-4-31B-it-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/batiai/gemma-4-31B-it-GGUF:Q4_K_M
- Ollama
How to use batiai/gemma-4-31B-it-GGUF with Ollama:
ollama run hf.co/batiai/gemma-4-31B-it-GGUF:Q4_K_M
- Unsloth Desktop
- Pi
How to use batiai/gemma-4-31B-it-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
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": "batiai/gemma-4-31B-it-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use batiai/gemma-4-31B-it-GGUF with Docker Model Runner:
docker model run hf.co/batiai/gemma-4-31B-it-GGUF:Q4_K_M
- Lemonade
How to use batiai/gemma-4-31B-it-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull batiai/gemma-4-31B-it-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.gemma-4-31B-it-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use batiai/gemma-4-31B-it-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 batiai/gemma-4-31B-it-GGUF:Q4_K_M
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 batiai/gemma-4-31B-it-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use batiai/gemma-4-31B-it-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf batiai/gemma-4-31B-it-GGUF:Q4_K_M
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 "batiai/gemma-4-31B-it-GGUF:Q4_K_M" \ --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"
Gemma 4 31B-it GGUF โ Quantized by BatiAI
Optimized GGUF quantizations of google/gemma-4-31B-it โ Google's largest dense Gemma 4 model with native multilingual + vision capabilities. Built directly from official Google BF16 weights by BatiAI for BatiFlow.
Gemma 4 31B-it is a dense 31 B model (every parameter active per token) โ different trade-off from 26B-A4B's MoE design (26 B total / 3.8 B active). Pick 31B for deeper reasoning per query, 26B-A4B for higher throughput.
Quick Start
# 24 GB Mac โ Smaller, imatrix-calibrated
ollama pull batiai/gemma4-31b:iq3
# 24 GB+ Mac โ Imatrix 4-bit (recommended)
ollama pull batiai/gemma4-31b:iq4
# 32 GB+ Mac โ Higher quality
ollama pull batiai/gemma4-31b:q4
# 36 GB+ Mac โ Highest on-device quality
ollama pull batiai/gemma4-31b:q6
Available Quantizations
| Tag | Quant | Recommended For |
|---|---|---|
:iq3 |
IQ3_M (imatrix) | 24 GB Mac, smaller footprint |
:iq4 |
IQ4_XS (imatrix) | 24 GB+ Mac, recommended |
:q4 |
Q4_K_M | 32 GB+ Mac, higher quality |
:q6 |
Q6_K | 36 GB+ Mac, near-lossless |
Two modes โ text-only by default, multimodal opt-in
Upstream Gemma 4 31B-it is multimodal (text + image + video understanding โ but no audio; for audio see the smaller E2B / E4B variants). In the GGUF ecosystem this is delivered as two files: a main model.gguf (text tower) and a separate mmproj.gguf (multi-modal projector โ the vision tower). We ship both, separate, so you can pick:
| Text-only (default) | Multimodal (opt-in) | |
|---|---|---|
| Files needed | main GGUF only | main GGUF + mmproj-*.gguf |
| Capabilities | Q&A, coding, tool calling, RAG, agents | + image / video understanding (OCR, captioning, visual reasoning) |
ollama pull |
โ single command | โ Ollama mmproj integration is still rough โ use llama.cpp directly |
| Disk / RAM | smaller (no vision weights) | larger (+ ~770 MB to ~1.2 GB) |
| Recommended for | most users (chat, code, agents) | OCR, image understanding |
Multimodal usage (llama.cpp)
Download the main GGUF + the mmproj file:
# Pick a main model (text tower)
wget https://huggingface.co/batiai/Gemma-4-31B-it-GGUF/resolve/main/google-gemma-4-31B-it-IQ4_XS.gguf
# Pick the mmproj (vision tower) โ Q6_K is the sweet spot, BF16 if you want zero loss
wget https://huggingface.co/batiai/Gemma-4-31B-it-GGUF/resolve/main/mmproj-Q6_K.gguf
Server mode (OpenAI-compatible Vision API):
llama-server \
-m google-gemma-4-31B-it-IQ4_XS.gguf \
--mmproj mmproj-Q6_K.gguf \
-c 32768 --host 127.0.0.1 --port 8080
curl http://127.0.0.1:8080/v1/chat/completions -d '{
"messages": [{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}},
{"type": "text", "text": "What does this screenshot show?"}
]
}]
}'
One-shot CLI:
llama-mtmd-cli \
-m google-gemma-4-31B-it-IQ4_XS.gguf \
--mmproj mmproj-Q6_K.gguf \
--image ~/Desktop/photo.jpg \
-p "describe this image"
mmproj quantizations available
| File | Quant | Size | When to use |
|---|---|---|---|
mmproj-Q6_K.gguf |
Q6_K | ~770 MB | balanced (recommended) |
mmproj-BF16.gguf |
BF16 | ~1.2 GB | absolute zero quantization loss for vision |
(Q8_0 not available because some vision tensors have shapes incompatible with Q8_0's column alignment โ applies to every quantizer of this model. Q6_K's K-quant block layout handles them.)
Dense vs MoE โ when to pick 31B vs 26B-A4B?
| 31B-it (dense) | 26B-A4B-it (MoE) | |
|---|---|---|
| Active params / token | 31 B (all) | 3.8 B (8 experts of 32) |
| Throughput | slower (more compute per token) | faster |
| Reasoning depth | better (denser computation) | good |
| Memory at IQ4 | ~17 GB | ~13 GB |
| Best for | hard reasoning / single-thread workloads | high-throughput / agents / streaming chat |
Use 31B for quality-per-token, 26B-A4B for tokens-per-second.
Why BatiAI?
| BatiAI | Third-party (unsloth, etc.) | |
|---|---|---|
| Source | Quantized directly from official Google weights | Often re-quantized from other GGUFs |
| Compatibility | โ Verified on Ollama 0.20+ | โ Known issues with Ollama 0.20+ |
| Tested on | Real Mac mini M4 + MacBook Pro M4 Max | Often untested |
| Tool calling | โ Verified with BatiFlow's 57 tool functions | Often broken |
| Korean | โ Validated | Not tested |
| Multimodal | โ Vision mmproj available (this repo) | Often missing |
| Signing | general.author: BatiAI for provenance |
Varies |
About BatiFlow
BatiFlow is a macOS-native AI desktop automation app โ just 5 MB, built with Swift.
- Free & Unlimited โ On-device AI via Ollama, no API costs
- 100 % Private โ All data stays on your Mac
- Ultra Lightweight โ Native macOS app, only 5 MB
- 57 built-in tools โ calendar, notes, reminders, files, email, browser, messaging, and more
Related models in the BatiAI Gemma 4 lineup
| Model | Modalities | Min RAM | Repo |
|---|---|---|---|
| Gemma 4 E2B-it | text + image + audio | 8 GB | batiai/Gemma-4-E2B-it-GGUF |
| Gemma 4 E4B-it | text + image + audio | 8 GB | batiai/Gemma-4-E4B-it-GGUF |
| Gemma 4 26B-A4B-it | text + image / video (MoE) | 24 GB | batiai/Gemma-4-26B-A4B-it-GGUF |
| Gemma 4 31B-it | text + image / video (dense) | 24 GB | this repo |
Technical Details
- Original Model: google/gemma-4-31B-it
- Architecture: Gemma 4 dense (31 B parameters, all active per token)
- Modalities: Text (primary) + Image / Video via opt-in mmproj. Audio not supported (use E2B / E4B for audio)
- Context Window: 128 K tokens
- License: Gemma
- Quantized with: llama.cpp
- Quantized by: BatiAI
- GGUF metadata:
general.author: BatiAI,general.url: https://flow.bati.ai
License
Mirrors the upstream Gemma license. Commercial use permitted per Google's Gemma terms.
BatiAI's quantization pipeline is provided under MIT.
- Downloads last month
- 347
3-bit
4-bit
6-bit