Instructions to use jokernifty/gemma-4-12B-it-mlx-4bit-multimodal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use jokernifty/gemma-4-12B-it-mlx-4bit-multimodal with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("jokernifty/gemma-4-12B-it-mlx-4bit-multimodal") config = load_config("jokernifty/gemma-4-12B-it-mlx-4bit-multimodal") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use jokernifty/gemma-4-12B-it-mlx-4bit-multimodal with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use jokernifty/gemma-4-12B-it-mlx-4bit-multimodal with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal"
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 "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Hermes Agent
How to use jokernifty/gemma-4-12B-it-mlx-4bit-multimodal with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal"
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 jokernifty/gemma-4-12B-it-mlx-4bit-multimodal
Run Hermes
hermes
gemma-4-12B-it — MLX 4-bit, multimodal weights preserved
The first MLX conversion of google/gemma-4-12B-it that preserves the encoder-free vision_embedder and audio_embedder weights, not just the text backbone.
Status: Text inference works today. Vision + audio inference requires the companion package
mlx-gemma4-unified(preview — image/audio preprocessors are next).
Why this exists
google/gemma-4-12B-it is Google's unique encoder-free Gemma 4 model: text, image, and audio inputs all flow directly into the LLM via lightweight embedder modules (no SigLIP or Conformer tower). When this model dropped, mlx-community published every other Gemma 4 size (e2b/e4b/26b-a4b/31b) within 48h, but skipped 12B — because mlx-lm and mlx-vlm didn't know about the gemma4_unified architecture, and the encoder-free embedder weights got stripped by every available converter.
This checkpoint keeps them all.
What's in the box
| Component | Format | Size |
|---|---|---|
| Token embedding (262k × 3840) | bf16 | 2.0 GB |
| 48 transformer layers (KV-shared, sliding/full alternating) | 4-bit, group_size 64 | ~5.7 GB |
embed_vision (patch_ln + patch_dense + pos_embedding + pos_norm + projection) |
bf16 | ~30 MB |
embed_audio (scaleless RMSNorm + Linear 640→3840) |
bf16 | ~5 MB |
| Tokenizer + chat template + processor config | — | <10 MB |
| Total | — | ~8.2 GB across 5 shards |
The token embedding stays in bf16 because quantizing 262k × 3840 in one Metal command exceeded the macOS GPU watchdog (5s). The multimodal embedders are tiny and also kept bf16 for fidelity.
Quick start — text inference (works today)
pip install mlx-lm --break-system-packages
Then either:
Option A — Use the mlx-gemma4-unified package (recommended; loads multimodal weights without warnings):
import json, mlx.core as mx, mlx.nn as nn
from mlx_gemma4_unified.model import Gemma4UnifiedModel, ModelArgs
src = "jokernifty/gemma-4-12B-it-mlx-4bit-multimodal" # or local path after hf download
# (full loader code in the repo)
Option B — Use mlx-lm with a 4-line alias (text-only; ignores the multimodal weights):
# Drop this at mlx_lm/models/gemma4_unified.py
from . import gemma4
ModelArgs = gemma4.ModelArgs
_SKIP = ("vision_embedder.", "embed_vision.", "embed_audio.")
class Model(gemma4.Model):
def sanitize(self, weights):
f = {k: v for k, v in weights.items()
if not any((k[6:] if k.startswith("model.") else k).startswith(p) for p in _SKIP)}
return super().sanitize(f)
Then:
python -m mlx_lm chat --model jokernifty/gemma-4-12B-it-mlx-4bit-multimodal
Vision + audio inference (work in progress)
The model weights are all here, but you need the image/audio preprocessors to actually use them. Those live in mlx-gemma4-unified:
- ✅
VisionEmbedderMLX module — implemented, tested - ✅
AudioEmbedderMLX module — implemented, tested - ✅ Token-splicing forward pass — implemented, tested
- 🚧 Image preprocessor (resize → bucket to 70/140/280/560/1120 tokens → 48×48 patches → factorized 2D position IDs) — next
- 🚧 Audio preprocessor (16kHz waveform → 640-sample frames) — next
- 🚧 Chat-template integration for
<boi>...<eoi>and<boa>...<eoa>blocks — next
Track progress on the GitHub repo.
Recommended sampling (from Google's model card)
temperature = 1.0,top_p = 0.95,top_k = 64- Enable "thinking" mode by prepending
<|think|>to the system prompt.
Architecture notes
model_type: gemma4_unified(1 of 5 Gemma 4 sizes; the only "Unified" encoder-free one)- 48 layers, hidden_size 3840, 16 heads, head_dim 256 (sliding) / 512 (full), context 256k
- Tied word embeddings (no separate
lm_head) - Sliding/full attention pattern from explicit
layer_types(every 6th layer is full) attention_k_eq_v=true,final_logit_softcapping=30.0
License
Apache 2.0 (inherited from upstream). Use is also subject to Google's Gemma Terms and Prohibited Use Policy. All credit for the model itself goes to Google DeepMind. This repository only contains the MLX conversion.
- Downloads last month
- 19
4-bit