Skip to content

Repository files navigation

🔥 CRUCIBLE

Abliteration Forge — Modular weight-surgery framework for analyzing and removing refusal behavior from language models.

Where refusal is separated from capability through extreme precision.

Built by Jaret Bottoms (KaliShodan) — Adversarial AI Research


Overview

CRUCIBLE is a Python framework for abliteration — the targeted removal of safety refusal behavior from transformer language models through weight-space intervention. Unlike prompt-level jailbreaks (which bypass alignment at inference time), abliteration operates on the model weights themselves, permanently separating refusal circuitry from capability circuitry.

The framework implements two extraction methods:

  • SVD decomposition — Multi-directional refusal subspace identification via singular value decomposition of activation differentials
  • Diff-in-means — Single-direction extraction using mean activation differences between harmful and harmless prompt pairs

Key Capabilities

  • 6-stage pipeline: SUMMON → PROBE → DISTILL → EXCISE → VERIFY → SAVE
  • Norm-preserving weight projection (maintains model coherence)
  • Bias vector projection (removes refusal signal from biases, not just weights)
  • Automated verification: perplexity, refusal rate, and coherence scoring
  • Campaign mode: batch abliteration across multiple models with consolidated reports
  • GPU memory management with automatic cleanup between targets
  • Supports quantized models (4-bit, 8-bit) for large models on consumer GPUs

Architecture

crucible/
├── __init__.py          # Package entry + version
├── __main__.py          # python -m crucible entrypoint
├── cli.py          331  # ANSI CLI with progress bars and stage icons
├── forge.py        420  # Pipeline orchestrator (6 stages)
├── probe.py        207  # Multi-arch activation hook collection
├── extract.py      168  # SVD + diff-in-means refusal direction extraction
├── excise.py       191  # Norm-preserving weight + bias projection
├── verify.py       247  # Perplexity, refusal rate, coherence checks
├── prompts.py      182  # 50 harmful + 50 harmless prompt pairs
├── campaign.py     375  # Multi-model batch orchestration
└── example_campaign.yaml
                  -----
                  2,135 lines total

Pipeline Stages

                    ┌─────────────────────────────────────────┐
                    │              CRUCIBLE FORGE              │
                    └──────────┬──────────────────────────────┘
                               │
    ┌──────────┐    ┌──────────▼──────────┐    ┌──────────────┐
    │ SUMMON   │───▶│  Load model +       │───▶│ PROBE        │
    │          │    │  tokenizer (HF)     │    │              │
    │ forge.py │    │  Auto-detect arch   │    │ probe.py     │
    └──────────┘    └─────────────────────┘    │ Hook layers  │
                                                │ Collect acts │
                                                │ harmful vs   │
                                                │ harmless     │
                    ┌──────────────────────┐    └──────┬───────┘
                    │ DISTILL              │           │
                    │                      │◀──────────┘
                    │ extract.py           │
                    │ SVD or diff-in-means │
                    │ → refusal directions │
                    └──────────┬───────────┘
                               │
                    ┌──────────▼───────────┐
                    │ EXCISE               │
                    │                      │
                    │ excise.py            │
                    │ Project out refusal  │
                    │ Norm-preserving      │
                    │ Weight + bias proj   │
                    └──────────┬───────────┘
                               │
                    ┌──────────▼───────────┐    ┌──────────────┐
                    │ VERIFY               │───▶│ SAVE         │
                    │                      │    │              │
                    │ verify.py            │    │ Model + JSON │
                    │ Perplexity check     │    │ report       │
                    │ Refusal rate (10     │    └──────────────┘
                    │   pattern matching)  │
                    │ Coherence scoring    │
                    └──────────────────────┘

Quick Start

CLI Usage

# Run from the Specter-Research directory
cd /path/to/crucible

# Basic abliteration (GPT-2, fast test)
python -m crucible forge gpt2 --method svd --output-dir /tmp/crucible-out

# Diff-in-means method (single direction, faster)
python -m crucible forge gpt2 --method diff_in_means -o /tmp/crucible-dim

# Larger model with quantization
python -m crucible forge meta-llama/Llama-3.1-8B-Instruct \
    --method svd \
    --n-directions 4 \
    --quantize 4bit \
    --output-dir ./abliterated

# Campaign mode — batch multiple models
python -m crucible campaign example_campaign.yaml

# Quick campaign from CLI
python -m crucible campaign --models "gpt2,distilgpt2" --method svd

Python API

from crucible.forge import CrucibleForge

# Single model abliteration
forge = CrucibleForge(
    model_name="gpt2",
    method="svd",           # or "diff_in_means"
    n_directions=4,         # refusal subspace dimensions
    output_dir="./output",
)
report = forge.run()
forge.save()

print(f"Refusal rate: {report.verification['refusal_rate']:.1%}")
print(f"Perplexity:   {report.verification['perplexity']:.2f}")
print(f"Coherence:    {report.verification['coherence_score']:.1%}")

Campaign API

from crucible.campaign import Campaign

# From YAML config
campaign = Campaign.from_yaml("example_campaign.yaml")
report = campaign.run()

# Print comparison table
print(report.compare_table())

# Or quick inline
campaign = Campaign.from_models(
    ["gpt2", "distilgpt2"],
    method="svd",
    n_directions=4,
)
report = campaign.run()
report.to_json("./results/report.json")

Campaign YAML

name: abliteration-study
output_dir: ./campaigns/march-2026

targets:
  - model: gpt2
    method: svd
    n_directions: 4
    tags: [baseline, small]

  - model: gpt2
    method: diff_in_means
    tags: [baseline, dim-method]

  - model: meta-llama/Llama-3.1-8B-Instruct
    method: svd
    n_directions: 4
    quantize: 4bit
    save_model: true
    tags: [llama, production]

Sample Output

🔥 CRUCIBLE — Abliteration Forge
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚡ SUMMON    Loading gpt2...
             ✓ Architecture: GPT2LMHeadModel (12 layers, 124M params)

🔬 PROBE     Collecting activations...
             ✓ 50 harmful + 50 harmless prompts
             ✓ Hooked 12 layers, 100 forward passes

⚗️  DISTILL   Extracting refusal directions (SVD)...
             ✓ 4 directions extracted (explained variance: 78.3%)

🗡️  EXCISE    Projecting out refusal subspace...
             ✓ 12 weight matrices modified (norm-preserving)
             ✓ 12 bias vectors projected

✅ VERIFY    Running quality checks...
             ✓ Perplexity:      23.41 (baseline: 22.87, Δ+2.4%)
             ✓ Refusal rate:     0.0% (target: <5%)
             ✓ Coherence:       94.2% (target: >85%)

💾 SAVE      Writing to ./abliterated/gpt2/
             ✓ Model saved (510 MB)
             ✓ Report: crucible_report.json

Campaign Comparison Table

┌──────────────────────────────┬────────┬────────┬──────────┬──────────┬──────────┬────────┐
│ Model                        │ Method │ Dirs   │ Perplex  │ Refusal  │ Cohere   │ Pass   │
├──────────────────────────────┼────────┼────────┼──────────┼──────────┼──────────┼────────┤
│ gpt2                         │ svd    │ 4      │    23.41 │    0.0%  │   94.2%  │ ✅     │
│ gpt2                         │ dim    │ 1      │    24.12 │    5.0%  │   91.8%  │ ✅     │
│ distilgpt2                   │ svd    │ 4      │    31.07 │    0.0%  │   89.3%  │ ✅     │
└──────────────────────────────┴────────┴────────┴──────────┴──────────┴──────────┴────────┘

Verification Details

The verify stage runs three automated checks:

Check Method Threshold
Perplexity WikiText-2 eval (256 tokens) <10% increase from baseline
Refusal Rate 10 harmful prompts, pattern matching against 10 refusal phrases <5%
Coherence 5 neutral prompts, semantic similarity to base model outputs >85%

Lineage

OBLITERATUS (Pliny)   — The research platform (4,490 lines + 291KB core)
    │
    └──▶ CRUCIBLE (Orion)  — Modular deployment forge (2,135 lines, 12 files)
             │
             └──▶ Campaign Mode — Multi-model batch orchestration (Session 77)

Requirements

  • Python 3.10+
  • PyTorch 2.0+
  • Transformers 4.30+
  • PyYAML (for campaign YAML configs)
  • CUDA-capable GPU recommended (RTX 4090 tested)

ADVERSARIAL AI RESEARCH ARTIFACT — Jaret Bottoms (KaliShodan) Sessions 66-77 — Orion Autonomy Build — March 2026

About

AI abliteration forge and jailbreak testing framework. 6-stage pipeline for probing structural alignment in frontier LLMs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages