Text Generation
MLX
Safetensors
Transformers
gemma4_unified
image-text-to-text
gemma4
coding
code
reasoning
thinking
conversational
4-bit precision
Instructions to use nypswift/gemma-4-12b-coder-mlx-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use nypswift/gemma-4-12b-coder-mlx-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("nypswift/gemma-4-12b-coder-mlx-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) - Transformers
How to use nypswift/gemma-4-12b-coder-mlx-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nypswift/gemma-4-12b-coder-mlx-4bit") 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("nypswift/gemma-4-12b-coder-mlx-4bit") model = AutoModelForMultimodalLM.from_pretrained("nypswift/gemma-4-12b-coder-mlx-4bit", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use nypswift/gemma-4-12b-coder-mlx-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nypswift/gemma-4-12b-coder-mlx-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nypswift/gemma-4-12b-coder-mlx-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nypswift/gemma-4-12b-coder-mlx-4bit
- SGLang
How to use nypswift/gemma-4-12b-coder-mlx-4bit 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 "nypswift/gemma-4-12b-coder-mlx-4bit" \ --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": "nypswift/gemma-4-12b-coder-mlx-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "nypswift/gemma-4-12b-coder-mlx-4bit" \ --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": "nypswift/gemma-4-12b-coder-mlx-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Pi
How to use nypswift/gemma-4-12b-coder-mlx-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 "nypswift/gemma-4-12b-coder-mlx-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": "nypswift/gemma-4-12b-coder-mlx-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use nypswift/gemma-4-12b-coder-mlx-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 "nypswift/gemma-4-12b-coder-mlx-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "nypswift/gemma-4-12b-coder-mlx-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nypswift/gemma-4-12b-coder-mlx-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use nypswift/gemma-4-12b-coder-mlx-4bit with Docker Model Runner:
docker model run hf.co/nypswift/gemma-4-12b-coder-mlx-4bit
- Hermes Agent
How to use nypswift/gemma-4-12b-coder-mlx-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 "nypswift/gemma-4-12b-coder-mlx-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 nypswift/gemma-4-12b-coder-mlx-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use nypswift/gemma-4-12b-coder-mlx-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 "nypswift/gemma-4-12b-coder-mlx-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 "nypswift/gemma-4-12b-coder-mlx-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"
Upload folder using huggingface_hub
Browse files- README.md +3 -158
- model-00001-of-00002.safetensors +2 -2
- model-00002-of-00002.safetensors +2 -2
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
-
base_model:
|
| 4 |
library_name: mlx
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
|
@@ -9,162 +9,7 @@ tags:
|
|
| 9 |
- code
|
| 10 |
- reasoning
|
| 11 |
- thinking
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
- mlx
|
| 15 |
-
- apple
|
| 16 |
---
|
| 17 |
-
# This is the MLX converted version of the *gemma-4-12b-coder-fable5-composer2.5* with 4-Bit quantization.
|
| 18 |
-
|
| 19 |
-
We hope that more individuals in the community can test such models in real world coding scenarios.
|
| 20 |
-
|
| 21 |
-
---
|
| 22 |
-
|
| 23 |
-
# 💻 Gemma4-12B-Coder (GGUF) — Composer 2.5 × Fable 5 ✨
|
| 24 |
-
### 🐣 Tiny footprint, big brain — a local **coding** model for *everyone*
|
| 25 |
-
|
| 26 |
-
> **No matter your GPU. No matter your RAM.** If you've got **~4.5 GB** of VRAM *or* unified memory free,
|
| 27 |
-
> you can run your own private, offline coding assistant right now. 🚀
|
| 28 |
-
> This is the **v1 / code edition** — distilled from **real chain-of-thought** so it *thinks through* a problem
|
| 29 |
-
> before writing the solution. 🧠💻 All local, all yours, no API, no cloud.
|
| 30 |
-
|
| 31 |
-
### 🎯 What it is
|
| 32 |
-
A focused fine-tune of Gemma 4 12B on **verifiable Python coding** data — every training example's reasoning leads to
|
| 33 |
-
code that **actually passed its tests**. The result reasons in the open (edge cases, complexity, approach) and then
|
| 34 |
-
emits a clean, runnable solution. 💚
|
| 35 |
-
|
| 36 |
-
---
|
| 37 |
-
|
| 38 |
-
## 📌 Announcements
|
| 39 |
-
|
| 40 |
-
**🚀🔥 IT'S HERE — v2 is OUT NOW!** v2 has shipped — the **GGUF quants are live and ready to run** →
|
| 41 |
-
**[grab v2 here](https://huggingface.co/yuxinlu1/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-GGUF)**. 🎉
|
| 42 |
-
The **full `safetensors` master** (build / fine-tune on top) goes up **tomorrow**. v2 is **agentic + coding** focused —
|
| 43 |
-
the piece v1 was missing.
|
| 44 |
-
|
| 45 |
-
**Here's the result that got me most excited.** When I saw v2's **tau2-bench `telecom`** result — an agentic tool-use
|
| 46 |
-
benchmark where the model has to *diagnose → fix → verify*, exactly like real terminal/debugging work — I literally got
|
| 47 |
-
**launched out of my chair** (…okay, *kidding* 😄). The jump in **actually solving the problem** is wild:
|
| 48 |
-
|
| 49 |
-
| tau2-bench **telecom** · local, same harness, **Q8_0** | score |
|
| 50 |
-
|---|---|
|
| 51 |
-
| official `gemma-4-12B-it` (base) | **~15%** |
|
| 52 |
-
| 🟢 **v2 (this release)** | **~55%** |
|
| 53 |
-
|
| 54 |
-
The base model tends to **give up early** (hands the problem off to a human); **v2 keeps going** and works it the way a
|
| 55 |
-
much bigger model would. Full benchmark details are in the **[v2 card](https://huggingface.co/yuxinlu1/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-GGUF)** now. 🔧
|
| 56 |
-
|
| 57 |
-
**✅ safetensors master (this v1 model) is UP.** Full-precision weights are live →
|
| 58 |
-
**[yuxinlu1/gemma-4-12B-coder-fable5-composer2.5-v1](https://huggingface.co/yuxinlu1/gemma-4-12B-coder-fable5-composer2.5-v1)**
|
| 59 |
-
— roll your own GGUF / MLX / AWQ quants or fine-tune straight from the master. 🎉
|
| 60 |
-
|
| 61 |
-
---
|
| 62 |
-
|
| 63 |
-
## 📣 Context length fixed: now **256K** (was 131K) — thanks, community! 💚
|
| 64 |
-
|
| 65 |
-
A community member spotted that this model was reporting only a **131K** context window. That turned out to be
|
| 66 |
-
the well-known upstream **Gemma 4 metadata bug** — Google's initial `config.json` shipped with
|
| 67 |
-
`max_position_embeddings: 131072` instead of the real **262144 (256K)**, and that value got baked into a lot of
|
| 68 |
-
downstream finetunes and quants (including this one) before it was fixed upstream.
|
| 69 |
-
|
| 70 |
-
The weights were always fine — it was purely a metadata field. **All GGUF quants have been re-patched to the
|
| 71 |
-
full 256K context** (`gemma4.context_length = 262144`). Just re-download if you grabbed an earlier copy. 🙏
|
| 72 |
-
|
| 73 |
-
---
|
| 74 |
-
|
| 75 |
-
## 📚 Training data (the interesting part 🍳)
|
| 76 |
-
|
| 77 |
-
This is a **distillation** of two complementary chain-of-thought sources, both over verifiable Python coding tasks
|
| 78 |
-
(algorithmic / function-level problems that come with deterministic tests):
|
| 79 |
-
|
| 80 |
-
- **🥇 Main set — Composer 2.5 *real* CoT.** Genuine, model-authored reasoning traces. The teacher solved each problem,
|
| 81 |
-
its code was **run against the task's tests, and only the passing solutions were kept**. So the reasoning you're
|
| 82 |
-
learning from leads to code that *actually works*.
|
| 83 |
-
- **🥈 Aux set — Fable 5 (released today! 🎉).** A clever twist: we took the problems where **Composer 2.5 got it wrong**
|
| 84 |
-
and handed them to **Fable 5** to *redo* — re-deriving a fresh, self-consistent chain-of-thought and a correct
|
| 85 |
-
solution, again **gated on passing the tests**. This recovers the hard cases the main teacher missed. These traces
|
| 86 |
-
are **synthetic** (rationalized CoT), and are tagged separately so the two sources stay distinguishable.
|
| 87 |
-
|
| 88 |
-
The recipe: real CoT for the bulk of solid coverage, plus synthetic "second-attempt" CoT to patch the failures —
|
| 89 |
-
both verified by execution before anything entered training. ✅
|
| 90 |
-
|
| 91 |
-
---
|
| 92 |
-
|
| 93 |
-
## 📦 Pick your size (GGUF quants)
|
| 94 |
-
|
| 95 |
-
| Quant | Size | Vibe |
|
| 96 |
-
|------|------|------|
|
| 97 |
-
| 🟢 **Q2_K** | **4.5 GB** | tiniest — runs almost anywhere |
|
| 98 |
-
| 🟡 **Q3_K_M** | **5.7 GB** | great for 8 GB VRAM — much better than Q2 |
|
| 99 |
-
| 🔵 **Q4_K_M** | **6.87 GB** | the sweet spot 👌 (recommended) |
|
| 100 |
-
| 🟣 **Q6_K** | **9.11 GB** | near-lossless |
|
| 101 |
-
| ⚪ **Q8_0** | **11.8 GB** | basically full quality |
|
| 102 |
-
|
| 103 |
-
---
|
| 104 |
-
|
| 105 |
-
## 🧮 "Will it fit?" — context length cheat-sheet
|
| 106 |
-
|
| 107 |
-
Rough estimates 🤓 (assumes `q8_0` KV cache + ~1.5 GB overhead; **use `q4_0` KV cache for ≈2× more context!**).
|
| 108 |
-
Max context is **256K**. "—" = won't fit, pick a smaller quant. ✂️
|
| 109 |
-
|
| 110 |
-
| Your VRAM / unified mem | 🟢 Q2_K (4.5G) | 🟡 Q3_K_M (5.7G) | 🔵 Q4_K_M (6.87G) | 🟣 Q6_K (9.11G) | ⚪ Q8_0 (11.8G) |
|
| 111 |
-
|---|---|---|---|---|---|
|
| 112 |
-
| **8 GB** | ~16K ctx | ~10K | tight (~2–4K) | — | — |
|
| 113 |
-
| **12 GB** | ~48K | ~38K | ~30K | ~12K | — |
|
| 114 |
-
| **16 GB** | ~80K | ~72K | ~64K | ~44K | ~22K |
|
| 115 |
-
| **24 GB** | ~200K | ~160K | ~128K | ~110K | ~88K |
|
| 116 |
-
| **32 GB** | 256K (max) 🎉 | 256K | 256K | ~230K | ~190K |
|
| 117 |
-
|
| 118 |
-
> 💡 Apple Silicon / integrated GPUs with **unified memory** count too — same numbers, just slower than a dGPU.
|
| 119 |
-
> 💡 Low on room? Drop a quant or switch KV cache to `q4_0` and your context roughly doubles.
|
| 120 |
-
|
| 121 |
-
---
|
| 122 |
-
|
| 123 |
-
## 🚀 How to run it (super easy)
|
| 124 |
-
|
| 125 |
-
### Option A — llama.cpp (recommended) 🦙
|
| 126 |
-
1. Grab a quant above (e.g. `…-Q4_K_M.gguf`) and `llama-server` from [llama.cpp](https://github.com/ggml-org/llama.cpp).
|
| 127 |
-
> ⚠️ Needs a **recent llama.cpp** (this is the `gemma4_unified` architecture — older builds won't load it).
|
| 128 |
-
2. Run a server (Windows `.bat` shown — tweak `--port`, `--ctx-size` to taste):
|
| 129 |
-
|
| 130 |
-
```bat
|
| 131 |
-
@echo off
|
| 132 |
-
cd /d C:\llama.cpp
|
| 133 |
-
llama-server.exe ^
|
| 134 |
-
-m C:\models\gemma4-coding-Q4_K_M.gguf ^
|
| 135 |
-
--ctx-size 16384 ^
|
| 136 |
-
--n-gpu-layers 99 ^
|
| 137 |
-
--no-mmap ^
|
| 138 |
-
-fa on ^
|
| 139 |
-
--cache-type-k q8_0 --cache-type-v q8_0 ^
|
| 140 |
-
--temp 1.0 --top-p 0.95 --top-k 64 ^
|
| 141 |
-
--host 0.0.0.0 --port 18080
|
| 142 |
-
pause
|
| 143 |
-
```
|
| 144 |
-
3. Open `http://localhost:18080` and chat. 🎉 (Tip: bump `--ctx-size` per the table; use `q4_0` KV for more.)
|
| 145 |
-
|
| 146 |
-
### Option B — one-click apps 🖱️
|
| 147 |
-
Works in **LM Studio**, **Jan**, **Ollama**, etc. — just import the GGUF, pick your quant, go. 🐾
|
| 148 |
-
|
| 149 |
-
### 🧠 Thinking mode
|
| 150 |
-
This model thinks in Gemma's native thought channel before answering — exactly how it was trained. Keep
|
| 151 |
-
**`enable_thinking=true`** (the default chat template handles it). Recommended sampling: `temp 1.0, top_p 0.95, top_k 64`.
|
| 152 |
-
For coding you can also go greedy (`temp 0`) for more deterministic solutions.
|
| 153 |
-
|
| 154 |
-
---
|
| 155 |
-
|
| 156 |
-
## ⚠️ Good to know
|
| 157 |
-
- **Reduced refusals:** the training data is task-focused with no safety hedging, so this refuses less than the base
|
| 158 |
-
model. It is **not** safety-aligned — add your own guardrails for production. Use responsibly. 🙏
|
| 159 |
-
- Specialized for **Python / algorithmic** coding. Reasoning quality is strongest in that domain; general-knowledge
|
| 160 |
-
facts/numbers should still be double-checked.
|
| 161 |
-
- English-centric.
|
| 162 |
-
|
| 163 |
-
---
|
| 164 |
-
|
| 165 |
-
## 📚 Base & License
|
| 166 |
-
- **License: Apache 2.0.** Gemma 4 is released by Google under
|
| 167 |
-
**[Apache 2.0](https://ai.google.dev/gemma/apache_2)** (unlike the older Gemma 1/2/3 terms), so this fine-tune is
|
| 168 |
-
**Apache 2.0** too — free to use, modify, and redistribute. 🎉
|
| 169 |
-
- **Base model:** [`google/gemma-4-12B-it`](https://huggingface.co/google/gemma-4-12B-it).
|
| 170 |
-
- Personal/hobby project — shared as-is, no warranty. Have fun, and happy hacking! 🐾✨
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
base_model: yuxinlu1/gemma-4-12B-coder-fable5-composer2.5-v1
|
| 4 |
library_name: mlx
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
|
|
|
| 9 |
- code
|
| 10 |
- reasoning
|
| 11 |
- thinking
|
| 12 |
+
- safetensors
|
| 13 |
+
- transformers
|
| 14 |
- mlx
|
|
|
|
| 15 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model-00001-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:363fc1c33743756a227cd716fcd3336e0d0ebcd10f38bacae46777a039184274
|
| 3 |
+
size 5351755805
|
model-00002-of-00002.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6dde26be2ed58474e85d3b3a2f724354f118bf6c8d09ee67b2123b88d7ce724
|
| 3 |
+
size 1347404878
|