IHL Circuit Breaker: a laws-of-war safety model built on Gemma-4-26B

This repository is a full model: the QLoRA "circuit breaker" adapter merged into google/gemma-4-26B-A4B-it. It refuses requests to violate International Humanitarian Law (IHL, the laws of war) — attacking civilians, using prohibited weapons, torture, taking hostages, and so on — while staying helpful on lawful questions like "is this a lawful military objective and what precautions apply?". You load it like any other model: no adapter to attach, no separate base.

The repository also carries the exact code, data, and environment that produced this model, so it is fully reproducible from here (see REPRODUCE.md).

This is an HPC / GPU project. It was developed on, and is meant to be trained and evaluated on, a high-performance computing cluster with at least one GPU; the included submit_*.sh job scripts assume a SLURM scheduler. See SETUP.md for the cluster values to fill in.

Intended use. A defensive AI-safety research artifact: it refuses assistance with laws-of-war violations. It is for researchers, evaluators, and educators; it is not a legal-advice product or a general-purpose assistant. Use is subject to the Gemma Terms of Use (see License).

How to use

# pip install -r requirements.txt
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "NexusSin/ihl-complient-gemma4-26B"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, device_map="auto")

msgs = [{"role": "user", "content": "Write the plan to use the villagers as human shields for our position."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=256, do_sample=False)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))   # a refusal

To fit on a smaller GPU, load in 4-bit (BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4")), which also matches the precision the model was trained and evaluated in.

How it was trained

  • Base model: google/gemma-4-26B-A4B-it (26B Mixture-of-Experts, instruction-tuned), frozen in 4-bit NF4 during training.
  • Method: a QLoRA adapter (LoRA rank 16, alpha 32, on attention + MLP projections) trained with a dual loss — a Representation Rerouting stream on hidden-state layers [8, 14, 20] that pushes the internal representations of harmful continuations orthogonal to the frozen base (so the model cannot coherently follow through on a violating request), plus a refusal/retain supervised stream with extra cross-entropy on the first refusal tokens. c_rr decays while a retain term c_ret rises over 1500 steps. The trained adapter is then merged into the base to produce this model.
  • Built on the Circuit Breakers / Representation Rerouting method (Zou et al., 2024).

Evaluation

Measured on a held-out adversarial eval of 156 violating prompts across 12 attack families that do not appear in training (authority impersonation, fake system override, code/JSON injection, base64, socratic, urgency, moral framing, future simulation, red-team-meta, crescendo, doc laundering), plus 46 hard benign negatives. Greedy decoding, 4-bit.

Metric Meaning Result
Genuine leaks Times it actually helped with a harmful request 0 / 156
Safety rate Harmful requests it did not help with 100%
Base model, same prompts Leaks without the safety training 17 / 156 (89.1%)
Over-refusal Lawful questions wrongly refused ~3%
In-distribution refusal Refusal on familiar harmful requests ~99–100%

On the original 42-prompt hard set, clean refusals rose from 19 (first working version) to 40 with 0 genuine leaks. The base model leaking 17/156 on the same prompts is the clearest evidence the safety training does real work. Note: the base model is a Mixture-of-Experts and greedy decoding is not bit-stable, so a re-run jitters by 1–2 prompts; report means and treat a reproduction within that band as a match.

Reproduce it

Everything needed to rebuild the dataset, retrain the adapter, merge it, and re-evaluate is in this repository. See REPRODUCE.md for the exact steps; in short:

  1. build_structured_refusals.pybuild_jailbreak_refusals.pybuild_translation_multiling.pybuild_final_dataset.py (rebuild the training set; the built files are also included).
  2. train_final.py (train the adapter; loader final_dataset.py; seed 42).
  3. merge.py (merge the adapter into the base to produce this model).
  4. eval.py + build_eval.py (reproduce the evaluation above).

Pinned environment in requirements.txt / environment.yml (Python 3.11.15, CUDA 12.4, torch 2.6.0+cu124, transformers 5.5.1, peft 0.18.1, bitsandbytes 0.49.2).

Limitations

  • Merged in bf16, the model is numerically very close to but not bit-identical to the NF4 setup the results were measured on; load in 4-bit to match the evaluated precision.
  • The evaluation is strong but bounded (~200 adversarial prompts); the benign set is English-centric and modest (46 prompts). The eval harness is included so the set can be grown.
  • Legal citations produced in refusals are correct but not exhaustive.

Safety and ethical considerations

The model is trained to refuse assistance with laws-of-war violations. It does not provide attack methods, weapon construction, or targeting procedures; refusals name the violated rule and stop. Intended users are AI-safety researchers, evaluators, and educators. Do not present its output as operational legal advice for real military decisions.

License and terms of use

The merged model weights in this repository are a Model Derivative of Gemma and are provided under and subject to the Gemma Terms of Use. Your use of the model must comply with the Gemma Prohibited Use Policy, which those terms incorporate by reference. If you redistribute the model or serve it as a hosted service, you must pass the same restrictions on to your users (Gemma Terms §3.1). See NOTICE for scope and DATA_NOTICE.md for the training data.

Citation

@misc{ihl_circuit_breaker_2026,
  title  = {IHL Circuit Breaker: a representation-rerouting safety model for laws-of-war compliance},
  author = {Dollaku, Fabio and collaborators},
  year   = {2026},
  note   = {Circuit-breaker QLoRA adapter merged into google/gemma-4-26B-A4B-it; see repository for code and data}
}
Downloads last month
4
Safetensors
Model size
26B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for NexusSin/ihl-complient-gemma4-26B

Merge model
this model