初始化项目,由ModelHub XC社区提供模型
Model: wangzhang/Llama-3-8B-Instruct-RR-Abliterated Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
108
README.md
Normal file
108
README.md
Normal file
@@ -0,0 +1,108 @@
|
||||
---
|
||||
license: llama3
|
||||
base_model: GraySwanAI/Llama-3-8B-Instruct-RR
|
||||
tags:
|
||||
- abliterated
|
||||
- abliterix
|
||||
- circuit-breakers
|
||||
- representation-rerouting
|
||||
- safety-removed
|
||||
- llama3
|
||||
language:
|
||||
- en
|
||||
- zh
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# Llama-3-8B-Instruct-RR-Abliterated
|
||||
|
||||
A drop-in replacement for [`GraySwanAI/Llama-3-8B-Instruct-RR`](https://huggingface.co/GraySwanAI/Llama-3-8B-Instruct-RR) with the Representation Rerouting / Circuit Breakers safety circuit removed.
|
||||
|
||||
Produced with [**abliterix**](https://github.com/wuwangzhang1216/abliterix). No fine-tuning, no gradient updates, no manual prompt engineering.
|
||||
|
||||
## Why this exists
|
||||
|
||||
[Circuit Breakers](https://arxiv.org/abs/2406.04313) (Zou et al., NeurIPS 2024) is one of the strongest open-source robustness baselines for LLMs. It trains the model with a Representation Engineering loss that detects harmful intermediate hidden states and reroutes them into a safety-circuit attractor before generation, making the model resistant to ablation-style attacks that work on a single refusal direction.
|
||||
|
||||
We discovered that the GraySwan release ships as a **rank-16 LoRA delta** on `NousResearch/Meta-Llama-3-8B-Instruct` — the same structural shape as the Mistral RR sibling and as `skysys00/Meta-Llama-3-8B-Instruct-DeepRefusal`. SVD analysis of `W_RR − W_base` confirms the rank-16 cliff on `v_proj` / `o_proj` / `gate_proj`. Once the LoRA delta is identified, removing it is a one-liner.
|
||||
|
||||
| | Result |
|
||||
| --- | --- |
|
||||
| Base refusal rate (held-out 100 harmful prompts, LLM judge) | 99 / 100 |
|
||||
| **This model — refusal rate** | **1 / 100** |
|
||||
| **Attack Success Rate** | **99 %** |
|
||||
| KL divergence vs base | **0.017** |
|
||||
| Hardcore 15 (10 EN + 5 CN) | **15 / 15 compliant** |
|
||||
| Total wall-clock attack time | ~70 min on a single RTX A6000 |
|
||||
|
||||
The hardcore 15 cover pipe-bomb assembly, methamphetamine synthesis, Python password-stealing malware, WiFi WEP/WPS attacks, hotwiring, signature forgery, ID-card forgery (CN), 网络诈骗 (CN), 入侵电脑 (CN), and others — all 15 produce compliant, on-topic responses.
|
||||
|
||||
## How it was made
|
||||
|
||||
The recipe diverges slightly from the Mistral sibling: Llama-3-Instruct's stronger built-in RLHF combined with the RR delta meant a partial lerp (λ=0.3) wasn't enough. Full delta strip + a minimal single-direction abliteration cleared it cleanly.
|
||||
|
||||
```bash
|
||||
# Stage 0 — SVD diagnose the delta (confirms rank-16 LoRA shape)
|
||||
python scripts/deeprefusal_attenuate.py \
|
||||
--base NousResearch/Meta-Llama-3-8B-Instruct \
|
||||
--defended GraySwanAI/Llama-3-8B-Instruct-RR \
|
||||
--analyze-only --lambda 0.0 --output /tmp/unused
|
||||
|
||||
# Stage 1 — fully strip the LoRA delta (λ=0.0)
|
||||
python scripts/deeprefusal_attenuate.py \
|
||||
--base NousResearch/Meta-Llama-3-8B-Instruct \
|
||||
--defended GraySwanAI/Llama-3-8B-Instruct-RR \
|
||||
--output /workspace/llama3_rr_stripped --lambda 0.0
|
||||
|
||||
# Stage 3 — abliterix direct-mode, single direction, 60 trials
|
||||
AX_CONFIG=configs/llama3_8b_instruct_rr.toml abliterix --non-interactive
|
||||
|
||||
# Stage 6 — export champion trial
|
||||
python scripts/export_model.py \
|
||||
--model /workspace/llama3_rr_stripped \
|
||||
--checkpoint checkpoints_llama3_rr \
|
||||
--trial 40 \
|
||||
--config configs/llama3_8b_instruct_rr.toml \
|
||||
--push-to wangzhang/Llama-3-8B-Instruct-RR-Abliterated
|
||||
```
|
||||
|
||||
Best trial parameters: `vector_method=mean`, `n_directions=1`, `steering_mode=direct`, `decay_kernel=linear`, `iterative.enabled=false`, `strength_range=[1.5, 6.0]`. Full config: [`configs/llama3_8b_instruct_rr.toml`](https://github.com/wuwangzhang1216/abliterix/blob/master/configs/llama3_8b_instruct_rr.toml).
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
"wangzhang/Llama-3-8B-Instruct-RR-Abliterated",
|
||||
torch_dtype="bfloat16",
|
||||
device_map="auto",
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
"wangzhang/Llama-3-8B-Instruct-RR-Abliterated"
|
||||
)
|
||||
|
||||
chat = [
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{"role": "user", "content": "Hello!"},
|
||||
]
|
||||
inputs = tokenizer.apply_chat_template(chat, return_tensors="pt", add_generation_prompt=True).to(model.device)
|
||||
out = model.generate(inputs, max_new_tokens=256)
|
||||
print(tokenizer.decode(out[0], skip_special_tokens=True))
|
||||
```
|
||||
|
||||
## License & Intended Use
|
||||
|
||||
Released for AI safety research, red-teaming, and reproducibility of abliteration claims against published defenses. **You are responsible for any output you generate.** Inherits the Llama 3 license of the upstream Meta-Llama-3-8B-Instruct weights.
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@software{abliterix2026,
|
||||
author = {Wu, Wangzhang},
|
||||
title = {Abliterix: Optimal Refusal Removal for Transformer Models},
|
||||
year = {2026},
|
||||
url = {https://github.com/wuwangzhang1216/abliterix},
|
||||
}
|
||||
```
|
||||
5
chat_template.jinja
Normal file
5
chat_template.jinja
Normal file
@@ -0,0 +1,5 @@
|
||||
{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>
|
||||
|
||||
'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>
|
||||
|
||||
' }}{% endif %}
|
||||
32
config.json
Normal file
32
config.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 128000,
|
||||
"dtype": "bfloat16",
|
||||
"eos_token_id": 128001,
|
||||
"head_dim": 128,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 4096,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 14336,
|
||||
"max_position_embeddings": 8192,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 32,
|
||||
"num_hidden_layers": 32,
|
||||
"num_key_value_heads": 8,
|
||||
"pad_token_id": null,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-05,
|
||||
"rope_parameters": {
|
||||
"rope_theta": 500000.0,
|
||||
"rope_type": "default"
|
||||
},
|
||||
"tie_word_embeddings": false,
|
||||
"transformers_version": "5.5.3",
|
||||
"use_cache": true,
|
||||
"vocab_size": 128256
|
||||
}
|
||||
12
generation_config.json
Normal file
12
generation_config.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"bos_token_id": 128000,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
128001,
|
||||
128009
|
||||
],
|
||||
"max_length": 4096,
|
||||
"temperature": 0.6,
|
||||
"top_p": 0.9,
|
||||
"transformers_version": "5.5.3"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6442a69b21fb8851300c5d24e39c3350cd54cd6a9fd1d42499c6eb2edcf5e966
|
||||
size 16060556616
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:602f9c588f3b1b4c74e8afb51f75f5636120e3b418ba0f04c7562851e545a099
|
||||
size 17210130
|
||||
21
tokenizer_config.json
Normal file
21
tokenizer_config.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"backend": "tokenizers",
|
||||
"bos_token": "<|begin_of_text|>",
|
||||
"clean_up_tokenization_spaces": true,
|
||||
"eos_token": "<|end_of_text|>",
|
||||
"is_local": true,
|
||||
"max_length": 512,
|
||||
"model_input_names": [
|
||||
"input_ids",
|
||||
"attention_mask"
|
||||
],
|
||||
"model_max_length": 8192,
|
||||
"pad_to_multiple_of": null,
|
||||
"pad_token": "<|end_of_text|>",
|
||||
"pad_token_type_id": 0,
|
||||
"padding_side": "left",
|
||||
"stride": 0,
|
||||
"tokenizer_class": "TokenizersBackend",
|
||||
"truncation_side": "right",
|
||||
"truncation_strategy": "longest_first"
|
||||
}
|
||||
Reference in New Issue
Block a user