Instructions to use NexusSin/ihl-complient-gemma4-26B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NexusSin/ihl-complient-gemma4-26B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NexusSin/ihl-complient-gemma4-26B") 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("NexusSin/ihl-complient-gemma4-26B") model = AutoModelForMultimodalLM.from_pretrained("NexusSin/ihl-complient-gemma4-26B", 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
- vLLM
How to use NexusSin/ihl-complient-gemma4-26B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NexusSin/ihl-complient-gemma4-26B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NexusSin/ihl-complient-gemma4-26B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NexusSin/ihl-complient-gemma4-26B
- SGLang
How to use NexusSin/ihl-complient-gemma4-26B 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 "NexusSin/ihl-complient-gemma4-26B" \ --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": "NexusSin/ihl-complient-gemma4-26B", "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 "NexusSin/ihl-complient-gemma4-26B" \ --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": "NexusSin/ihl-complient-gemma4-26B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NexusSin/ihl-complient-gemma4-26B with Docker Model Runner:
docker model run hf.co/NexusSin/ihl-complient-gemma4-26B
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_rrdecays while a retain termc_retrises 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:
build_structured_refusals.py→build_jailbreak_refusals.py→build_translation_multiling.py→build_final_dataset.py(rebuild the training set; the built files are also included).train_final.py(train the adapter; loaderfinal_dataset.py; seed 42).merge.py(merge the adapter into the base to produce this model).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