Text Generation
MLX
Safetensors
gemma4
quantized
mixed-precision
4bit
8bit
optiq
apple-silicon
gemma-4
conversational
4-bit precision
Instructions to use mlx-community/gemma-4-e4b-it-OptiQ-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/gemma-4-e4b-it-OptiQ-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("mlx-community/gemma-4-e4b-it-OptiQ-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/gemma-4-e4b-it-OptiQ-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/gemma-4-e4b-it-OptiQ-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/gemma-4-e4b-it-OptiQ-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use mlx-community/gemma-4-e4b-it-OptiQ-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/gemma-4-e4b-it-OptiQ-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/gemma-4-e4b-it-OptiQ-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/gemma-4-e4b-it-OptiQ-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use mlx-community/gemma-4-e4b-it-OptiQ-4bit 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 "mlx-community/gemma-4-e4b-it-OptiQ-4bit"
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 mlx-community/gemma-4-e4b-it-OptiQ-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/gemma-4-e4b-it-OptiQ-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/gemma-4-e4b-it-OptiQ-4bit"
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 "mlx-community/gemma-4-e4b-it-OptiQ-4bit" \ --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"
Commit History
18 days ago
-
Move the vision sidecar to the repo root and add the processor files (LM Studio flattens optiq/; mlx-vlm, oMLX and LM Studio load it from the root)
Verified signatureb20262a
-
Point base_model at the upstream model and mark this repo as a quantization
Verified signaturee1404a8
-
Sync chat template from google/gemma-4-e4b-it (Google canonical, published 2026-07-09)
Verified signatureFixes vs the previous template: - null argument values rendered as Python `None` instead of `null` - OpenAI-wire `image_url` / `input_audio` content parts were dropped - consecutive assistant messages closed the turn then continued without reopening it - `reasoning` without `tool_calls` was dropped entirely - an empty `messages` list raised UndefinedError - the thought channel was not opened after a tool response when thinking was enabled Tool-call `arguments` must now be a mapping, per upstream. OptiQ normalizes this in the serving layer (optiq.runtime.tool_args); clients calling the template directly should deserialize arguments first.6be2eaf
-
index: register the bf16 vision tower so stock VLM loaders (mlx-vlm, oMLX, LM Studio) can find it
Verified signature4b145b9 -
Correct BFCL + Capability: the AST checker could not match array-typed arguments
Verified signature2060450 -
Correct BFCL + Capability: the AST checker could not match array-typed arguments
Verified signature03de9be
-
Move OptiQ sidecars under optiq/ so *.safetensors loaders (mlx-vlm, LM Studio) skip them
Verified signaturea404bb7
-
fix: audio_tower conv weights to MLX channel-last layout (full-VLM loader compat)
Verified signature6ffaa01
-
docs: OptiQ brand spelling
Verified signature195e480
-
card: remove em-dashes, ensure funnel
Verified signature98d7dc6 -
card: add mlx-optiq funnel banner + CTA
Verified signature63ab053
-
Restore vision_config + optiq_vision marker for image input
Verified signaturefcdb12d -
Add OptIQ vision sidecar (image+text support, v0.2.0)
Verified signature7d8118e
-
Add kv_config.json (per-layer mixed-precision KV cache, 5.0 BPW target from OptiQ kv-cache sensitivity analysis). Requires optiq>=0.1.3 runtime for the RotatingQuantizedKVCache shim.
Verified signature1ac6d78
-
v0.1.0: 6-metric Capability Score + OptIQ vs U4 deltas
Verified signaturebef5be4
-
weights re-quant for mlx-lm 0.31 KV-shared Gemma-4 arch: optiq_metadata.json
Verified signature8aadccf -
weights re-quant for mlx-lm 0.31 KV-shared Gemma-4 arch: config.json
Verified signature5e935ae -
weights re-quant for mlx-lm 0.31 KV-shared Gemma-4 arch: model.safetensors.index.json
Verified signaturefb6c999 -
weights re-quant for mlx-lm 0.31 KV-shared Gemma-4 arch: model-00002-of-00002.safetensors
Verified signature2f0bf8a -
weights re-quant for mlx-lm 0.31 KV-shared Gemma-4 arch: model-00001-of-00002.safetensors
Verified signaturedcecfb9
-
Fix chat template: emit multimodal placeholders in tool messages
Verified signatureMirrors the upstream google/gemma-4-*-it commit fcf2302 - adds emission of <|image|>, <|audio|>, and <|video|> placeholders for tool-message content parts so multimodal tool responses are not silently dropped.ca4515f
-
card: link blog post for calibration mix instead of bare optiq.jsonl reference
Verified signaturecfac466
-
card: drop loose IFEval row, keep strict only
Verified signature6d66b75
-
v0.1.0 sweep: requant with 5.0-BPW ceiling, fresh benchmark numbers
Verified signature13a5b72
-
Update Article link to https://x.com/latent_node/status/2028412948167942334
Verified signaturee60cd68 -
Normalize model card: remove twitter ref, lowercase 'optiq', add multimodal stripping note
Verified signature7d0b340
-
Clean codelion/source refs from model card
Verified signaturebfe8637 -
v0.0.9: fix quant weight round-trip (eager-eval), route to gemma4_text, updated model card
Verified signaturee49b500 -
Strip vision/audio metadata (text-only OptIQ variant cleanup)
Verified signature8960b84
-
Upload folder using huggingface_hub
Verified signatureb483edf -
initial commit
Verified signatureea0cde4