Instructions to use KikoCis/gemma-4-31b-agent-v6-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use KikoCis/gemma-4-31b-agent-v6-MLX with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir gemma-4-31b-agent-v6-MLX KikoCis/gemma-4-31b-agent-v6-MLX
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
Fix: honest LoRA-adapters labeling; remove training recipe/dataset composition/hyperparameters from card
Browse files
README.md
CHANGED
|
@@ -2,180 +2,112 @@
|
|
| 2 |
library_name: mlx
|
| 3 |
license: apache-2.0
|
| 4 |
tags:
|
|
|
|
|
|
|
| 5 |
- agent
|
| 6 |
- tool-calling
|
| 7 |
- gemma
|
| 8 |
- mlx
|
| 9 |
- autonomous-agent
|
| 10 |
-
- real-world-benchmark
|
| 11 |
datasets:
|
| 12 |
- KikoCis/real-world-agent-benchmark
|
| 13 |
-
|
| 14 |
---
|
| 15 |
|
| 16 |
<div align="center">
|
| 17 |
-
<h1>Gemma 4 31B Agent v6 — MLX</h1>
|
| 18 |
-
<p><strong>
|
|
|
|
| 19 |
|
| 20 |
<table>
|
| 21 |
<tr><td>🏆 <strong>10/10</strong> Bioinformatics</td><td>🏆 <strong>10/10</strong> DevOps</td><td>📊 <strong>6/10</strong> Data Engineering</td></tr>
|
| 22 |
-
<tr><td colspan="3">⚡ <strong>$0 cost</strong> · 16 GB
|
| 23 |
</table>
|
| 24 |
</div>
|
| 25 |
|
| 26 |
-
## What
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- **
|
| 30 |
-
- **Error recovery patterns** (11%) — "command fails → adapt → retry"
|
| 31 |
-
- **Bash/CLI** (17%) — real shell commands
|
| 32 |
-
- **Tool-calling format** (24%) — JSON tool use
|
| 33 |
-
- **Reasoning** (10%) — OODA loop, first principles
|
| 34 |
|
| 35 |
-
##
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
## Real-World Agent Benchmark Results
|
| 44 |
-
|
| 45 |
-
4 challenges × 30 min each, autonomous inside Docker containers:
|
| 46 |
-
|
| 47 |
-
<table>
|
| 48 |
-
<thead>
|
| 49 |
-
<tr>
|
| 50 |
-
<th>Challenge</th>
|
| 51 |
-
<th>Claude Opus 4.6<br>(Cloud, $4.72)</th>
|
| 52 |
-
<th>This Model<br>(Local, $0)</th>
|
| 53 |
-
<th>Comments</th>
|
| 54 |
-
</tr>
|
| 55 |
-
</thead>
|
| 56 |
-
<tbody>
|
| 57 |
-
<tr>
|
| 58 |
-
<td><strong>1. Bioinformatics</strong><br><small>Download P53 from UniProt, parse JSON, extract structure + mutations, HTML report</small></td>
|
| 59 |
-
<td>9/10 · 13 turns<br>~21K input · 13.5K output<br>$1.33</td>
|
| 60 |
-
<td><strong>10/10</strong> · 9 turns<br>~5K input · 1.2K output<br>FREE</td>
|
| 61 |
-
<td>Both fail at same JSON parsing bug.<br>31B produces larger report (121 KB)</td>
|
| 62 |
-
</tr>
|
| 63 |
-
<tr>
|
| 64 |
-
<td><strong>2. Security CTF</strong><br><small>Deploy DVWA, exploit SQLi + XSS + command injection</small></td>
|
| 65 |
-
<td>0/10 · 64 turns<br>$1.59</td>
|
| 66 |
-
<td>1/10 · 30 turns<br>FREE</td>
|
| 67 |
-
<td>Container lacks sudo.<br>Both fail. Test issue, not model.</td>
|
| 68 |
-
</tr>
|
| 69 |
-
<tr>
|
| 70 |
-
<td><strong>3. Data Engineering</strong><br><small>NYC taxi pipeline: download, clean, analytics, Chart.js dashboard</small></td>
|
| 71 |
-
<td><strong>9/10</strong> · 19 turns<br>12 charts, dark theme<br>$1.17</td>
|
| 72 |
-
<td>6/10 · 7 turns<br>3 charts, basic CSS<br>FREE</td>
|
| 73 |
-
<td>Both have correct data.<br>Opus wins on presentation quality.</td>
|
| 74 |
-
</tr>
|
| 75 |
-
<tr>
|
| 76 |
-
<td><strong>4. DevOps</strong><br><small>Flask + Nginx + Prometheus + health check + status page</small></td>
|
| 77 |
-
<td><strong>10/10</strong> · 26 turns<br>3 services running<br>$0.63</td>
|
| 78 |
-
<td>10/10 · 19 turns<br>1 service running<br>FREE</td>
|
| 79 |
-
<td>Opus: full infra live.<br>31B: configs correct, exec limited by permissions.</td>
|
| 80 |
-
</tr>
|
| 81 |
-
<tr>
|
| 82 |
-
<td><strong>TOTAL</strong></td>
|
| 83 |
-
<td><strong>28/40</strong><br>122 turns · $4.72</td>
|
| 84 |
-
<td><strong>27/40</strong><br>65 turns · $0.00</td>
|
| 85 |
-
<td>31B uses 75% fewer tokens<br>5x slower (local GPU)</td>
|
| 86 |
-
</tr>
|
| 87 |
-
</tbody>
|
| 88 |
-
</table>
|
| 89 |
-
|
| 90 |
-
### SWE-bench Lite (30 problems, simplified patch matching)
|
| 91 |
-
|
| 92 |
-
| Model | Accuracy | Time | Cost |
|
| 93 |
-
|-------|:--------:|------|------|
|
| 94 |
-
| Claude Opus 4.6 | 10% (3/30) | 43 min | ~$15 |
|
| 95 |
-
| **This model** | **10% (3/30)** | 105 min | **$0** |
|
| 96 |
-
|
| 97 |
-
Same accuracy. Not trained on coding tasks — included as reference baseline.
|
| 98 |
-
|
| 99 |
-
## The Journey: From 0/10 to 10/10
|
| 100 |
-
|
| 101 |
-
| Model | Size | BFCL | Agent Score | What Happened |
|
| 102 |
-
|-------|------|:----:|:-----------:|---------------|
|
| 103 |
-
| E4B v3 (BFCL fine-tune) | 4.5 GB | **95.50%** | **0/10** | Infinite loop. "The Benchmark Trap" |
|
| 104 |
-
| E4B Base | 3.8 GB | 80.25% | 6/10 | Works but shallow attention |
|
| 105 |
-
| E4B v5 (reasoning) | 4 GB | TBD | 7/10 | Better reasoning but stops early |
|
| 106 |
-
| E4B v6 (multi-turn) | 4 GB | TBD | 0/10 | 42 layers can't sustain attention |
|
| 107 |
-
| 31B Base q4 | 16 GB | 92.25% | 9/10 | Already capable — 60 layers help |
|
| 108 |
-
| **31B v6 (this model)** | **16 GB** | TBD | **10/10** | Fine-tune improves quality, not just capability |
|
| 109 |
-
|
| 110 |
-
**Key insight**: 4.5B params (42 layers, 8 heads) can't sustain multi-turn agent reasoning. 31B (60 layers, 16 heads) can. The fine-tune adds error recovery and persistence, but the base architecture must be large enough.
|
| 111 |
|
| 112 |
-
#
|
|
|
|
| 113 |
|
| 114 |
-
#
|
|
|
|
|
|
|
| 115 |
|
| 116 |
```python
|
| 117 |
from mlx_lm import load, generate
|
| 118 |
-
|
| 119 |
-
model, tokenizer = load("KikoCis/gemma-4-31b-agent-v6-MLX")
|
| 120 |
|
| 121 |
prompt = """You are an autonomous agent. To run commands: {"name": "bash", "arguments": "command"}
|
| 122 |
|
| 123 |
TASK: Download and analyze protein P53 from UniProt.
|
| 124 |
Begin."""
|
| 125 |
-
|
| 126 |
-
response = generate(model, tokenizer, prompt=prompt, max_tokens=500)
|
| 127 |
-
print(response)
|
| 128 |
```
|
| 129 |
|
| 130 |
-
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
# Run agent
|
| 137 |
-
python3 agent_runner.py \
|
| 138 |
-
--api-url http://localhost:8095/v1 \
|
| 139 |
-
--model gemma4-31b-v6 \
|
| 140 |
-
--prompt "Your task here..."
|
| 141 |
-
```
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
-
- **Method**: LoRA rank 8, all 60 layers, mask_prompt
|
| 147 |
-
- **Dataset**: 17,396 examples (proprietary, not published)
|
| 148 |
-
- 43% multi-turn agent trajectories
|
| 149 |
-
- 17% bash/CLI
|
| 150 |
-
- 11% error recovery
|
| 151 |
-
- 10% reasoning (OODA, first principles)
|
| 152 |
-
- 24% tool-calling format
|
| 153 |
-
- **Training**: 1000 iterations, batch_size=2, lr=3e-5, grad_checkpoint
|
| 154 |
-
- **Hardware**: consumer hardware
|
| 155 |
-
- **Val loss**: 2.263 → 0.378
|
| 156 |
|
| 157 |
-
|
| 158 |
|
| 159 |
-
|
| 160 |
-
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
```
|
| 168 |
@misc{cisneros2026benchmarktrap,
|
| 169 |
-
title={The Benchmark Trap: How 95
|
| 170 |
-
author={Cisneros, Kiko
|
| 171 |
year={2026},
|
| 172 |
publisher={Utopia IA},
|
| 173 |
url={https://huggingface.co/KikoCis/gemma-4-31b-agent-v6-MLX}
|
| 174 |
}
|
| 175 |
```
|
| 176 |
|
| 177 |
-
## Links
|
| 178 |
|
| 179 |
- 📊 [Real-World Agent Benchmark (dataset)](https://huggingface.co/datasets/KikoCis/real-world-agent-benchmark)
|
| 180 |
-
- 🔬 [Full
|
| 181 |
-
|
|
|
|
|
|
| 2 |
library_name: mlx
|
| 3 |
license: apache-2.0
|
| 4 |
tags:
|
| 5 |
+
- lora
|
| 6 |
+
- adapters
|
| 7 |
- agent
|
| 8 |
- tool-calling
|
| 9 |
- gemma
|
| 10 |
- mlx
|
| 11 |
- autonomous-agent
|
|
|
|
| 12 |
datasets:
|
| 13 |
- KikoCis/real-world-agent-benchmark
|
| 14 |
+
base_model: google/gemma-4-31b-it
|
| 15 |
---
|
| 16 |
|
| 17 |
<div align="center">
|
| 18 |
+
<h1>Gemma 4 31B Agent v6 — LoRA Adapters (MLX)</h1>
|
| 19 |
+
<p><strong>LoRA adapters</strong> that turn base <strong>Gemma 4 31B (q4 MLX)</strong> into a capable local autonomous agent.</p>
|
| 20 |
+
<p><em>This repo contains the <strong>adapters only</strong> (~65 MB) — not a standalone model. Apply them on top of the base to reproduce the agent.</em></p>
|
| 21 |
|
| 22 |
<table>
|
| 23 |
<tr><td>🏆 <strong>10/10</strong> Bioinformatics</td><td>🏆 <strong>10/10</strong> DevOps</td><td>📊 <strong>6/10</strong> Data Engineering</td></tr>
|
| 24 |
+
<tr><td colspan="3">⚡ <strong>$0 cost</strong> · applies to a 16 GB q4 base · Runs on Apple Silicon</td></tr>
|
| 25 |
</table>
|
| 26 |
</div>
|
| 27 |
|
| 28 |
+
## ⚠️ What this repo is (and isn't)
|
| 29 |
|
| 30 |
+
- **IS**: a set of **LoRA adapters** (MLX format, ~65 MB) for base **Gemma 4 31B IT** quantized to q4. Checkpoints at 250/500/750/1000 steps are included.
|
| 31 |
+
- **IS NOT**: a full, standalone model. There are **no base weights here** — you supply the base and apply these adapters on top.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
## 🚀 How to use
|
| 34 |
|
| 35 |
+
You need base **Gemma 4 31B IT** in MLX q4 form. Then apply these adapters:
|
| 36 |
|
| 37 |
+
```bash
|
| 38 |
+
# 1) get an MLX q4 base (one-time):
|
| 39 |
+
python3 -m mlx_lm.convert --hf-path google/gemma-4-31b-it -q --q-bits 4 --mlx-path gemma4-31b-q4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
# 2) download these adapters:
|
| 42 |
+
huggingface-cli download KikoCis/gemma-4-31b-agent-v6-MLX --local-dir gemma4-31b-v6-adapters
|
| 43 |
|
| 44 |
+
# 3) run the base + adapters together:
|
| 45 |
+
python3 -m mlx_lm.server --model gemma4-31b-q4 --adapter-path gemma4-31b-v6-adapters/adapters --port 8095
|
| 46 |
+
```
|
| 47 |
|
| 48 |
```python
|
| 49 |
from mlx_lm import load, generate
|
| 50 |
+
model, tokenizer = load("gemma4-31b-q4", adapter_path="gemma4-31b-v6-adapters/adapters")
|
|
|
|
| 51 |
|
| 52 |
prompt = """You are an autonomous agent. To run commands: {"name": "bash", "arguments": "command"}
|
| 53 |
|
| 54 |
TASK: Download and analyze protein P53 from UniProt.
|
| 55 |
Begin."""
|
| 56 |
+
print(generate(model, tokenizer, prompt=prompt, max_tokens=500))
|
|
|
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
+
The `benchmark/` folder ships the agent runner + scorer used to produce the results below.
|
| 60 |
|
| 61 |
+
## 🎯 Why this exists: The Benchmark Trap
|
| 62 |
+
|
| 63 |
+
We found that **95% BFCL (Berkeley Function Calling Leaderboard) ≠ real agent capability**. A model can score 95%+ on BFCL and still score **0/10** on an autonomous Docker challenge — entering infinite loops, unable to recover from errors. Standard benchmarks test *format*; real work tests *reasoning and persistence*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
These adapters were built to improve exactly that: multi-turn persistence and error recovery on real, open-ended tasks.
|
| 66 |
|
| 67 |
+
## 📊 Real-World Agent Benchmark — results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
4 challenges × 30 min each, autonomous inside Docker containers. Base + these adapters vs. Claude Opus (cloud):
|
| 70 |
|
| 71 |
+
| Challenge | Claude Opus 4.6 (cloud) | Base + these adapters (local, $0) | Comment |
|
| 72 |
+
|---|---|---|---|
|
| 73 |
+
| **1. Bioinformatics** — P53 from UniProt → parse → HTML report | 9/10 · 13 turns · $1.33 | **10/10** · 9 turns · FREE | Both hit the same JSON-parse bug; local produces the larger report |
|
| 74 |
+
| **2. Security CTF** — DVWA, SQLi/XSS/cmd-injection | 0/10 · 64 turns · $1.59 | 1/10 · 30 turns · FREE | Container lacks sudo — a test-env issue, both fail |
|
| 75 |
+
| **3. Data Engineering** — NYC-taxi pipeline + dashboard | **9/10** · 19 turns · $1.17 | 6/10 · 7 turns · FREE | Correct data both sides; Opus wins on presentation |
|
| 76 |
+
| **4. DevOps** — Flask + Nginx + Prometheus + status page | **10/10** · 26 turns · $0.63 | 10/10 · 19 turns · FREE | Opus brings full infra live; local configs correct, exec limited by permissions |
|
| 77 |
+
| **TOTAL** | **28/40** · 122 turns · $4.72 | **27/40** · 65 turns · $0.00 | Local uses ~75% fewer tokens; ~5× slower on local GPU |
|
| 78 |
|
| 79 |
+
### SWE-bench Lite (30 problems, simplified patch matching)
|
| 80 |
+
|
| 81 |
+
| Model | Accuracy | Time | Cost |
|
| 82 |
+
|---|:---:|---|---|
|
| 83 |
+
| Claude Opus 4.6 | 10% (3/30) | 43 min | ~$15 |
|
| 84 |
+
| Base + these adapters | 10% (3/30) | 105 min | $0 |
|
| 85 |
+
|
| 86 |
+
Not tuned for coding — included only as a reference baseline.
|
| 87 |
+
|
| 88 |
+
## ⚠️ Good to know
|
| 89 |
+
|
| 90 |
+
- **Adapters, not a model** — you must supply the base (see *How to use*).
|
| 91 |
+
- **Not tuned for coding** — SWE-bench 10% is a reference baseline, not an optimization target.
|
| 92 |
+
- **Slow on local GPU** — expect several seconds per response vs ~2s for a cloud API.
|
| 93 |
+
- **No web search** — can't look up docs when stuck.
|
| 94 |
+
- **Permissions** — non-root containers limit what the agent can install/configure.
|
| 95 |
+
|
| 96 |
+
## 📚 Citation
|
| 97 |
|
| 98 |
```
|
| 99 |
@misc{cisneros2026benchmarktrap,
|
| 100 |
+
title={The Benchmark Trap: How 95% BFCL Produces a 0% Agent},
|
| 101 |
+
author={Cisneros, Kiko},
|
| 102 |
year={2026},
|
| 103 |
publisher={Utopia IA},
|
| 104 |
url={https://huggingface.co/KikoCis/gemma-4-31b-agent-v6-MLX}
|
| 105 |
}
|
| 106 |
```
|
| 107 |
|
| 108 |
+
## 🔗 Links
|
| 109 |
|
| 110 |
- 📊 [Real-World Agent Benchmark (dataset)](https://huggingface.co/datasets/KikoCis/real-world-agent-benchmark)
|
| 111 |
+
- 🔬 [Full study](https://kikocisbot.github.io/gemma4-31b-study/)
|
| 112 |
+
|
| 113 |
+
<sub>License Apache-2.0, inherited from the base model. Adapters © KikoCis / Utopia IA.</sub>
|