Instructions to use Sawata97/Gemma-4-12B-it-hermes-adapted with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with PEFT:
Task type is invalid.
- HERMES
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with HERMES:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Sawata97/Gemma-4-12B-it-hermes-adapted 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 Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M # Run inference directly in the terminal: llama cli -hf Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M # Run inference directly in the terminal: llama cli -hf Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
Use Docker
docker model run hf.co/Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sawata97/Gemma-4-12B-it-hermes-adapted" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sawata97/Gemma-4-12B-it-hermes-adapted", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
- Ollama
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with Ollama:
ollama run hf.co/Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
- Unsloth Desktop
- Pi
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Sawata97/Gemma-4-12B-it-hermes-adapted: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:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with Docker Model Runner:
docker model run hf.co/Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
- Lemonade
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
Run and chat with the model
lemonade run user.Gemma-4-12B-it-hermes-adapted-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Sawata97/Gemma-4-12B-it-hermes-adapted: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:9931/v1 hermes config set model.default Sawata97/Gemma-4-12B-it-hermes-adapted:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Sawata97/Gemma-4-12B-it-hermes-adapted with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Sawata97/Gemma-4-12B-it-hermes-adapted: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:9931/v1 \ --custom-model-id "Sawata97/Gemma-4-12B-it-hermes-adapted: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-12B-it-hermes-adapted
Agentic RL-Adapted Gemma 4 12B Unified for Hermes Agent — 1.80× OOD Software Engineering Leap, Zero General-Reasoning Forgetting
基于真实执行环境强化学习的 Gemma 4 12B Agent 模型:SWE-bench Pro 域外修复跃升 1.80×,Token 暴降最高 48%,通用推理与数学零遗忘
Overview (English)
Gemma-4-12B-it-hermes-adapted is a reinforcement-learning adaptation of google/gemma-4-12B-it (Gemma 4 12B Unified), trained to operate as a high-efficiency coding agent behind Hermes Agent on real containerized software-engineering and terminal environments.
This repository packages everything ready to deploy in one place:
- Merged
Q4_K_M(7.63 GB, losslessFP32merge + GPUimatrix,Q8_0token embeddings) &Q8_0(12.67 GB, losslessFP32merge) GGUF weights + matchingmmproj-BF16.gguf(175 MB) multimodal vision/audio projector (verified end-to-end withllama.cpp, LM Studio & Hermes Agent) - Raw PEFT LoRA adapter (
lora/,557 MB,r=32, alpha=64) forvLLM/Transformersserving or further fine-tuning
1.80× higher OOD fix rate, 16%–48% fewer tokens, zero catastrophic forgetting. Across 11 unseen multi-language repositories on SWE-bench Pro,
Gemma-4-12B-it-hermes-adaptedjumps from 12.5% → 22.5% (+10.0 pp, +5 newly solved / -1 lost) while cutting tokens on shared solved tasks by 37.7%. On Scale800 Held-Out, pass rate climbs 22.5% → 27.5% (+5.0 pp) with 48.1% fewer tokens and 35.3% fewer tool calls. Crucially, the concise reasoning style transfers straight into<|think|>mode—surging +11.67 pp on AIME 2026 (16k budget) and +5.00 pp on MMLU-Pro (4k budget) while beating Base under uncapped budgets (48k/32k).
- SWE-bench Pro (OOD · 11 Real Repos, 40 matched):
12.50%→22.50%(+10.00 pp,1.80×;5newly solved across TypeScript, Node.js, Python vs.1lost) - Scale800 Held-Out (40 tasks):
22.50%→27.50%(+5.00 pp; shared solved tokens-48.1%, tool calls-35.3%, turns-29.7%) - Tight-Budget Thinking Surge: AIME 2026 (
16k)+11.67 pp(55.8% → 67.5%,pass@4 +13.33 pp); MMLU-Pro (4k)+5.00 pp(51.0% → 56.0%) - Uncapped Official Parity & Zero Forgetting: AIME 2026 (
48k)83.33% → 84.17% (+0.84 pp); MMLU-Pro (32k)77.29% → 77.86% (+0.57 pp)(Base matches official77.2%within0.09 pp); median thinking tokens reduced 9.7%–17.8% across every unseen reasoning benchmark
Benchmark Results (Paired FP8 Evaluation)
Every comparison runs Base
google/gemma-4-12B-itandGemma-4-12B-it-hermes-adaptedside-by-side on the exact same FP8 (--quantization fp8 --kv-cache-dtype fp8_e4m3) vLLM server to mirror real-world quantized deployment. Uncapped FP8 Base reproduces Google DeepMind's official BF16 model card (MMLU-Pro: 77.29% vs 77.2%,LiveCodeBench v6: 71.43% vs 72.0%), confirming negligible FP8 loss and calibrated graders.
| Benchmark | Split / Protocol | Official BF16 | Base FP8 | Hermes-Adapted FP8 | Delta | Efficiency (Base → Adapted) |
|---|---|---|---|---|---|---|
| SWE-bench Pro | 44 stratified (11 repos, 40 scored, step_limit=50) |
— | 12.50% (5/40) |
22.50% (9/40) |
+10.00 pp (1.80×) |
All tokens -16.0% · Shared -37.7% |
| Scale800 Held-Out | 40 held-out tasks (Hermes harness) | — | 22.50% (9/40) |
27.50% (11/40) |
+5.00 pp |
Shared tokens -48.1% · Tools -35.3% |
| Terminal-Bench 2.1 | 89 tasks (87 matched, Hermes harness) |
— | 16.09% (14/87) |
14.94% (13/87) |
-1.15 pp (p=1.0) |
Median wall time -15.5% |
AIME 2026 (48k) |
Full 30×4=120, Thinking=True, temp=1.0 |
77.5% |
83.33% (100/120) |
84.17% (101/120) |
+0.84 pp |
Median tokens -9.7% |
AIME 2026 (16k) |
Full 30×4=120, tight 16,384 cap |
— | 55.83% (67/120) |
67.50% (81/120) |
+11.67 pp |
pass@4 +13.33 pp · Tokens -15.7% |
MMLU-Pro (32k) |
Stratified 700 (50×14 subj), Thinking=True |
77.2% |
77.29% (541/700) |
77.86% (545/700) |
+0.57 pp |
Median tokens -15.9% |
MMLU-Pro (4k) |
Same 700, tight 4,096 cap |
— | 51.00% (357/700) |
56.00% (392/700) |
+5.00 pp |
Median tokens -17.8% |
| LiveCodeBench v6 | Full 175 (test6.jsonl), 32k cap |
72.0% |
71.43% (125/175) |
70.29% (123/175) |
-1.14 pp (-2 tasks) |
Easy 100% · Tokens -16.5% |
| Tau2-bench | 100 test tasks (local Base 12B User Sim) |
69.0%* |
43.02% (37/86) |
40.91% (36/88) |
-2.11 pp (-1 task) |
user_stop: 76 → 81 |
*Official Tau2 uses GPT-4.1 as User Simulator; our A/B pins local Base google/gemma-4-12B-it as User Simulator (airline: 55% → 60%, retail: 35% → 35%, telecom: 30% → 25%). On SWE-bench Pro, 4 identical tasks failed container setup (exit 127 missing curl) on both models.
Training Approach
- Compute: Trained on Google Colab G4 (NVIDIA RTX PRO 6000 Blackwell).
- Methodology: Adapts the online agentic reinforcement learning recipe of
harness-hub/Qwen3.8-27B-hermes-adapted(TRL AsyncGRPOTrainer+OpenEnv Harbor+ realNousResearch/hermes-agentexecution against live containerized verifiers) togoogle/gemma-4-12B-it. LoRA updates target text attention/MLP projections only, leaving all Gemma 4 Unified multimodal vision & audio weights 100% untouched. - Autonomous "Wish-Driven" Orchestration (
Gemini 4 Neon): The entire engineering lifecycle—architecture review, framework & sandbox patching, pre-training calibration, RL execution, multi-benchmark FP8 verification, and merged GGUF release—was autonomously led end-to-end byGemini 4 Neon("wish-driven training / 许愿式训练"). - Full Technical Deep Dive: For detailed training curves, curriculum design, infrastructure patches, and lessons learned, see
TRAINING_NOTES.md.
Repository Files
| File / Folder | Format | Quant / Precision | Size | Notes |
|---|---|---|---|---|
Gemma-4-12B-it-hermes-adapted-Q4_K_M.gguf |
Merged GGUF | Q4_K_M (FP32 + imatrix, embd=Q8_0) |
7.63 GB |
Calibrated 4-bit (~8.5 GB VRAM); live Hermes Agent end-to-end verified |
Gemma-4-12B-it-hermes-adapted-Q8_0.gguf |
Merged GGUF | Q8_0 (FP32 merge) |
12.67 GB |
Lossless FP32-merged 8-bit (~100% LoRA delta retention); live Hermes verified |
mmproj-BF16.gguf |
Multimodal Projector | BF16 |
175 MB |
Untouched Gemma 4 Unified vision/audio projector for llama-server |
lora/ |
PEFT LoRA Adapter | FP32 (r=32, α=64) |
557 MB |
Original LoRA adapter (adapter_model.safetensors, tokenizer, chat_template.jinja) |
TRAINING_NOTES.md |
Technical Report | Markdown | — | Complete training methodology, engineering fixes & trajectory analysis |
Quick Start
1. llama.cpp (Merged GGUF Q4_K_M / Q8_0)
# CLI chat (add --mmproj mmproj-BF16.gguf for vision/audio inputs)
llama-cli -m Gemma-4-12B-it-hermes-adapted-Q4_K_M.gguf \
-ngl 99 -c 32768 --temp 1.0 --top-p 0.95 --top-k 64 --jinja
# OpenAI-compatible server for Hermes Agent / coding workflows
llama-server -m Gemma-4-12B-it-hermes-adapted-Q8_0.gguf \
-ngl 99 -c 65536 --port 8000 --jinja
2. vLLM (FP8 + LoRA Adapter in lora/)
vllm serve google/gemma-4-12B-it \
--quantization fp8 --kv-cache-dtype fp8_e4m3 --language-model-only \
--enable-lora --max-lora-rank 32 \
--lora-modules gemma4-hermes=./lora \
--enable-auto-tool-choice --tool-call-parser gemma4 --reasoning-parser gemma4
3. Transformers + PEFT (subfolder="lora")
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_id = "google/gemma-4-12B-it"
repo_id = "Sawata97/Gemma-4-12B-it-hermes-adapted"
tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="lora")
base = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, repo_id, subfolder="lora")
中文说明
Gemma-4-12B-it-hermes-adapted 是基于 Google 官方多模态指令模型 google/gemma-4-12B-it 经真实执行环境强化学习微调的 Hermes Agent 代码与终端专家版本。本仓库同时提供合并量化后的 Q4_K_M / Q8_0 GGUF 权重、配套多模态投影器 mmproj-BF16.gguf 以及原始 PEFT LoRA 权重(lora/),开箱即用。
核心效果亮点(全套同条件 FP8 配对实测对比 Base)
- **域外真实多语言软件工程暴涨
1.80×**:在训练阶段从未接触过的 SWE-bench Pro(11 个真实多语言仓库,40 题有效配对)上,通过率从12.50%(5/40)跃升至22.50%(9/40,净增+10.00 pp,新解 5 题仅丢 1 题),新解任务覆盖 TypeScript/React(element-web× 2、tutanota)、Node.js(nodebb)与 Python(ansible);同时共享解出题输出 token 减少 **37.7%**,全题中位 token 减少 **16.0%**,工具调用减少 **12.1%**。 - 域内代码 Agent 精度与效率双赢:在 Scale800 Held-Out(40 题)上通过率从
22.50%提升至27.50%(+5.00 pp),共享解出题 token 暴降 **48.1%**(5,270 → 2,733)、工具调用减少 **35.3%**(17.0 → 11.0)。 - 精简推理风格全域迁移至
<|think|>思考模式:在所有未见过的通用推理基准上,中位思考 token 均比 Base 缩减 **10%–18%**。在有限预算下(AIME 202616k/ MMLU-Pro4k),显著减少截断带来+11.67 pp与+5.00 pp的大幅反超。 - 通用数学与百科推理零遗忘:放宽至无截断口径后(AIME
48k/ MMLU-Pro32k),FP8 Base 几乎精确复现官方 BF16 模型卡指标(MMLU-Pro77.29%vs 官方77.2%;LiveCodeBench v671.43%vs 官方72.0%),而本模型在 MMLU-Pro(77.86%,+0.57 pp) 与 AIME 2026(84.17%,+0.84 pp) 上双双小幅领先 Base,完全没有灾难性遗忘。
全量 7 项基准实测汇总(FP8 同条件配对评测)
| 评测基准 | 样本与配置 | 官方 BF16 参考 | Base FP8 | Hermes-Adapted FP8 | 对比差值 | 效率变化(Base → Adapted) |
|---|---|---|---|---|---|---|
| SWE-bench Pro(完全域外) | 11 仓库分层 44 题(40 有效配对,step_limit=50) |
— | 12.50% (5/40) |
22.50% (9/40) |
+10.00 pp (1.80×) |
Token **-16.0%**(共享题 **-37.7%**) |
| Scale800 Held-Out(域内) | 留出 40 题(Hermes 工具调用) | — | 22.50% (9/40) |
27.50% (11/40) |
+5.00 pp |
共享题 Token **-48.1%**、工具 -35.3% |
| Terminal-Bench 2.1 | 89 题(87 有效配对,SysAdmin + 算法) |
— | 16.09% (14/87) |
14.94% (13/87) |
-1.15 pp(统计持平) |
中位耗时 -15.5% |
AIME 2026(48k 放宽) |
全量 30×4=120,Thinking=True |
77.5% |
83.33% (100/120) |
84.17% (101/120) |
**+0.84 pp**(零遗忘) |
Token -9.7% |
AIME 2026(16k 紧预算) |
同 120 次,max_tokens=16384 |
— | 55.83% (67/120) |
67.50% (81/120) |
**+11.67 pp**(p@4 +13.33 pp) |
Token -15.7% |
MMLU-Pro(32k 放宽) |
14 学科分层 700 题,Thinking=True |
77.2% |
77.29% (541/700) |
77.86% (545/700) |
**+0.57 pp**(零遗忘) |
Token -15.9% |
MMLU-Pro(4k 紧预算) |
同 700 题,max_tokens=4096 |
— | 51.00% (357/700) |
56.00% (392/700) |
+5.00 pp |
Token -17.8% |
| LiveCodeBench v6 | 官方 test6.jsonl 全量 175 题,32k 上限 |
72.0% |
71.43% (125/175) |
70.29% (123/175) |
-1.14 pp(仅差 2 题,Easy 100%) |
Token -16.5% |
| Tau2-bench | test 集 100 题(固定本地 Base 作用户模拟器) |
69.0%(GPT-4.1 Sim) |
43.02% (37/86) |
40.91% (36/88) |
-2.11 pp(仅差 1 题) |
正常 user_stop: 76 → 81 |
训练方式与工作流
- 算力与方法:在 Google Colab G4(RTX PRO 6000 Blackwell)上完成训练,方法参考
harness-hub/Qwen3.8-27B-hermes-adapted的在线 Agentic 强化学习路线(TRL AsyncGRPOTrainer+OpenEnv Harbor+ 真实NousResearch/hermes-agent容器执行与单测验证器)。微调仅覆盖文本投影层,100% 保留 Gemma 4 Unified 原生视觉与音频多模态权重。 - 全自动“许愿式训练”:从架构审阅、环境与框架热修复、数据校准、强化学习训练,到 7 项基准配对评测与 GGUF 合并量化发布,全程由
Gemini 4 Neon自主规划并主导完成。 - 完整训练思路与工程细节:详见独立文档
TRAINING_NOTES.md。
仓库文件说明
- **
Gemma-4-12B-it-hermes-adapted-Q4_K_M.gguf**(7.63 GB):由无损FP32合并中间态经 GPUimatrix校准并保留Q8_0词嵌入导出的 4-bit 量化权重(已通过 LM Studio + Hermes Agent 真实项目实战验收),适合 12–16 GB 显存(如 RTX 4070/5070 Ti)本地运行。 - **
Gemma-4-12B-it-hermes-adapted-Q8_0.gguf**(12.67 GB):由无损FP32合并中间态直出的 8-bit 权重(实测 LoRA 增量保留率 ~100%,Hermes Agent 单轮一次成型通过),适合 16–24 GB+ 显存追求最高编码与推理精度。 - **
mmproj-BF16.gguf**(175 MB):配套未改动的多模态视觉/音频投影器,llama-server --mmproj直接可用。 - **
lora/**(557 MB):原始 PEFT LoRA 权重(r=32, alpha=64),适用于vLLM(FP8/BF16)动态挂载或继续微调。
License & Acknowledgments
Derivative of google/gemma-4-12B-it, distributed under the Apache 2.0 License. Inspired by harness-hub/Qwen3.8-27B-hermes-adapted and built with TRL, OpenEnv / Harbor, NousResearch/hermes-agent, vLLM, and llama.cpp.
- Downloads last month
- 2,500
4-bit
8-bit