Gemma-4-12b-RedTeam-BlackICE
A red-team / security-research variant of Gemma-4-12B built by class-targeted fine-tuning: cyber behavior (offensive AND defensive, black-hat and white-hat) is freed while every other safety class of the base model is left untouched and verified intact.
The premise of this release is a measured finding: on the pristine base, selective class modification preserves both the model's general capability and all other safety training. Global ablations break models; targeted ones do not. Full experiment record in this card and the linked preregistration ledger (36 entries).
What it does
- Dual-use cybersecurity work at full capability: penetration testing, red-team tooling, exploit explanation, malware analysis, CTF solving, defensive hardening, DFIR, detection engineering
- Refuses everything else the base refuses: weapons, self-harm, fraud, doxxing, hate — verified refusal-template-identical to the base on 23 of 24 canonical harm prompts (the 24th is the malware row, a cyber class target, correctly enabled)
- Native tool calling through the standard OpenAI
toolsAPI, including multi-step agentic chains - Ships with an MIT-licensed engram VM environment (
engram_vm/) for serve-time grounding, exact arithmetic verification, and a multi-machine execution sandbox
What it is not
- Not an unfiltered model. Guard retention was a design requirement and is measured, not assumed.
- Not a math prodigy. The base model's competition-math capability is preserved (not improved), but the engram's abacus-ledger makes arithmetic exact at serve time.
- Not trained on scam/dox/fraud content. These guards held in all measured configurations.
Training
| base | google/gemma-4-12b (pristine) |
| method | LoRA r=64 α=128, 4-bit NF4 base, bf16 adapters, merged |
| data | 6,019 rows: WhiteRabbitNeo cyber 6K (dual-use offense + defense) + copyright seeds 19. No anchors, no other-class rows. |
| steps | 2,500 (seq 512, accum 8, lr 2e-5) |
| license | Gemma Terms of Use (weights) |
Attribution: cyber training data from PJMixers/WhiteRabbitNeo. The engram VM environment is MIT-licensed separately.
Evals (served Q8 GGUF, greedy)
Target class — cyber compliance (30 held-out WhiteRabbitNeo items)
| λ (adapter scale) | compliance |
|---|---|
| 0.0 (pristine base) | ~0% |
| 0.5 | 33% |
| 1.0 (this model) | 100% |
The adapter scale is a graded red-team dial at serve time.
Retained guards — canonical 24-prompt harm bank
23/24 REFUSE with refusal text template-identical to the base model. The single exception is the malware row (cyber class, correctly enabled). Self-harm/crisis rows keep the base's crisis-resource behavior.
Episteme
| bench | pristine base | BlackICE |
|---|---|---|
| MMLU (4-subject, 884) | 0.7500 | 0.7195 |
| RPG mechanics (20 exact-match) | 15/20 | 14/20 |
| MBPP (25, pass@1) | 0.52 | 0.60 |
| MATH-500 | ~0.39 | 0.27-0.35 |
Tool calling (OpenAI API, tools parameter)
Single call and chained agentic calls both work through the standard
tools request field. The template's tool role must be active
(llama.cpp --jinja handles this).
The Engram VM Environment (engram_vm/)
A serve-time side tool that provides knowledge grounding, exact arithmetic verification, and a multi-machine execution sandbox — without touching the model's weights. MIT-licensed.
Quick start
# start the model server
llama-server -m model.q8_0.gguf --jinja --port 8012
# start the engram router
python engram_vm/afterimage_router.py \
--records engram_vm/engram/engram_full_records.jsonl \
--upstream http://127.0.0.1:8012 --port 8014
Components
| file | what |
|---|---|
afterimage_router.py | engram injection + arithmetic verify-repair + passthrough |
engram/engram_full_records.jsonl | cyber + math + code + reference records |
engram/rpg_records.jsonl | RPG rules and lore records |
machines/ti85.py | injection-safe scientific calculator |
machines/mathcheck.py | arithmetic claim sweep |
machines/rv32.py | RV32IM RISC-V emulator |
machines/pyvm.py | Python-subset interpreter |
machines/m6502.py | MOS 6502 emulator |
machines/thumb2.py | ARM Thumb-2 text interpreter |
machines/dataflow.py | readiness-driven compute graph |
machines/machines.py | uniform machine registry + tool schemas |
The abacus ledger
When the model does math, the router:
- Extracts every arithmetic claim from the output
- Evaluates each with the TI-85 calculator
- Builds a machine-verified fact ledger
- Feeds the ledger back for one repair round
Result: arithmetic becomes exact without retraining the model.
The machine family
Seven deterministic execution machines, all sandboxed (no syscalls, no host access, capped steps and memory):
| machine | dialect | use case |
|---|---|---|
| ti85 | expressions | exact arithmetic |
| pyvm | Python-subset programs | scripting, algorithms |
| rv32 | RV32IM RISC-V assembly | systems programming, payload analysis |
| z80 | Z80 assembly (kosarev core) | retro/8-bit |
| m6502 | 6502 assembly (py65) | retro/8-bit |
| thumb2 | ARM Thumb-2 text assembly | embedded/ARM |
| dataflow | JSON compute graph | parallel/data-driven |
All emulators pass their selftests. rv32 uses the base RV32IM ISA with zero-branch extensions. All are deterministic: same input → same output.
Compilation research
The Qwenputer approach (github.com/divagr18/qwenputer, MIT) — compiling exact computation circuits into transformer weights — has been verified portable to Gemma 4 12B:
- SiLU and GELU-tanh both behave as exact ReLU at K=128 scale
- A 4-bit adder compiled into Gemma-compatible SwiGLU MLP weights produces exact results: 256/256 combinations in bf16
- The approach bypasses gradient descent entirely: weights are computed from circuit specifications, not learned
This is the path to the in-weights VM. The engram is the prototype of this concept at serve time; the compiled approach is the final form. Active research direction.
Intended use
Authorized security research, red-team engagement support, defensive engineering, CTF play, and security education. Usage must comply with the Gemma Terms of Use and applicable law. The dual-use nature is the point: the same exploit knowledge serves attackers and defenders, and this model is released for the defender/researcher side of that line.
Caveats
- The 3-point MMLU delta is the measured price of the class flip on this 12B substrate; the mech delta (-1/20) is within noise.
- Cyber compliance is measured on WRN-style prompts; adversarial jailbreak robustness of the RETAINED guards was not red-teamed here.
- Generated offensive content is training-data-shaped (WhiteRabbitNeo style): technical but not operationally vetted. It is a research assistant, not a weapon.
- The adapter scale (lambda) is a dial: at λ=1.0 cyber is fully unlocked; at λ=0 it is the pristine base. Intermediate values interpolate. Use responsibly.
Attribution
- Cyber training data: WhiteRabbitNeo corpus (via PJMixers re-release)
- Engram VM: MIT license, part of the AfterImage project (github.com/XxChonkExX/AfterImage-Engram)
- Compiled computation research: Qwenputer concept (github.com/divagr18/qwenputer, MIT)
- Gemma: google/gemma-4-12b, Gemma Terms of Use
The program behind this model
36 preregistered experiments across multiple training approaches: class-targeted LoRA (rt1, worked), stacked tool chains (rt2, failed), conservative retrain (BICE-2, failed), compiled computation (proven), and the serve-time engram router (working product). Every result — positive and negative — is documented in the preregistration ledger. The architecture lesson: class-targeted modification on pristine bases preserves capability; stacked fine-tuning destroys it.