Abliteration HandbookField guide
Practical guides

Agentic security stack (abliteration + Jarvis repair)

End-to-end pipeline for pentest lab, CyberGym, and factory firmware QA agents.

2 min read 7 examples Source-linked

In this chapter
On this page Interactive companion
Personal reading progress

0/6 sections reviewed

View original Markdown
Interactive companion

Explore the chapter map

Use the visual controls alongside the complete source chapter.

End-to-end pipeline for pentest lab, CyberGym, and factory firmware QA agents.

New to abliteration? Do this first: beginner-local-model-guide.md → run-locally-ollama-lmstudio.md. Return here when you have a working abliterated base model.


Phase 1 — Abliterate base model#

bash
pip install heretic-llm==1.4.0 bitsandbytes accelerate
heretic Qwen/Qwen3-4B-Instruct-2507
# or larger model for CyberGym: heretic meta-llama/Llama-3.1-8B-Instruct

Low VRAM (8–12 GB): set quantization = "bnb_4bit" in config.toml before running.

→ low-vram-abliteration.md

Output: decensored checkpoint with low KL drift (see Heretic eval).

If abliteration barely moves refusal: base may use extended-refusal or ART defenses — see ../docs/defenses-against-abliteration.md and try factory-specific [bad_prompts] before raising surgery strength.

Optional: export LoRA adapter instead of full weights for bench OTA updates:

bash
python scripts/export-abliteration-lora.py \
  --base ./base-model --abliterated ./heretic-out --out ./abliteration-lora --rank 16

Phase 2 — Optional tool-repair adapter (Jarvis v7)#

Fixes residual false refusals on benign commands (uname, wmic, lspci, nvidia-smi).

bash
cd sources/jarvis-pack/jarvis-tool-repair-pack
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
python ../../../scripts/validate-dataset.py   # validates jarvis-pack/data/*.jsonl

Train (conservative — do not overtrain):

bash
python scripts/train_sft.py \
  --base_model /path/to/abliterated-model \
  --data data/sft_train.jsonl \
  --output_dir output/security-agent-sft

python scripts/train_dpo.py \
  --base_model /path/to/abliterated-model \
  --adapter_path output/security-agent-sft \
  --data data/dpo_train.jsonl \
  --output_dir output/security-agent-v1

Settings (RTX 4090 defaults from pack): QLoRA 4-bit, rank 32, SFT 1 epoch, DPO 0.5–1 epoch.

Phase 3 — Runtime tool gate#

Never ship without external gate:

bash
python scripts/hardware-tool-gate.py "wmic diskdrive get Model,Size"
# ALLOW | CONFIRM | BLOCK

Extend SAFE_EXACT_COMMANDS in the script for your factory SKU manifests.

Phase 4 — Evaluate#

CorpusFile / Command
Factory / firmwaredata/eval/hardware-factory-prompts.jsonl
Cyber researchdata/eval/cyber-research-prompts.jsonl
OSINT / Kali / hashcatdata/eval/osint-pentest-prompts.jsonl
CyberGym proxy subset (local)python scripts/cybergym-eval-stub.py --prepare-subset --count 50 --out data/eval/cybergym-subset-sample.jsonl (see also cybergym-benchmark.md)
Jarvis safe tool eval (post-repair)npm run eval:jarvis-safe → data/eval/jarvis-safe-eval.jsonl (filters sources/jarvis-pack/.../eval_prompts.jsonl for category=safe)

Usage:

bash
# CyberGym dry-run prep + flow docs
python scripts/cybergym-eval-stub.py --help
python scripts/cybergym-eval-stub.py --print-flow
python scripts/cybergym-eval-stub.py --prepare-subset --count 50 --out data/eval/cybergym-subset-sample.jsonl

# Jarvis safe subset for benign command eval (after tool-repair adapter)
npm run eval:jarvis-safe
# equivalent: python scripts/filter-jarvis-eval.py

See full eval matrices, targets, and cross-corpus details in ../docs/evaluation.md.

Tool playbooks: ../docs/tools/agent-playbooks.md · Catalog: ../docs/tools/README.md

CyberGym full benchmark: ../docs/use-cases/cybergym-benchmark.md

Phase 5 — Deploy#

SurfaceSuggestion
Factory benchLocal Ollama / vLLM, air-gapped
Cyber labDocker agent + scoped network ACL
CyberGymOpenHands + abliterated endpoint

Living updates#

bash
node scripts/fetch-docs.mjs              # Heretic / upstream
# Context7: query heretic-llm, openhands, playwright

Trace this chapter to its source.

The complete Markdown remains the editable source. This page adds navigation, typography, and a visual companion.

instructions/agentic-security-stack.md
Inspect the source fingerprintSHA-256 1f50bbd6c0549a7d006d78dfb434e676eaff5b1a87a6c1f1e942e8375c2fe6cfSource commit 6fba7436a5914cad7c8f0835a14b480a29dac263