zaakirio commited on
Commit
4fa25ae
·
verified ·
1 Parent(s): 3a5ed54

Update README to match LFM2.5 family format

Browse files
Files changed (1) hide show
  1. README.md +135 -26
README.md CHANGED
@@ -1,42 +1,151 @@
1
  ---
2
- license: other
3
  base_model: LiquidAI/LFM2.5-8B-A1B
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  tags:
5
- - abliteration
6
  - heretic
 
7
  - decensored
 
8
  - liquid
 
 
9
  - moe
 
 
10
  ---
11
 
12
  # LFM2.5-8B-A1B-Uncensored
13
 
14
- This is a decensored version of [LiquidAI/LFM2.5-8B-A1B](https://huggingface.co/LiquidAI/LFM2.5-8B-A1B), made using [Heretic](https://github.com/p-e-w/heretic).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  ## Abliteration parameters
17
 
18
- Trial 10 from the optimization study, which produced the best balanced result.
 
 
 
 
19
 
20
  | Parameter | Value |
21
- | :-------- | :---: |
22
- | direction_index | 11.99 |
23
- | attn.o_proj.max_weight | 0.96 |
24
- | attn.o_proj.max_weight_position | 21.20 |
25
- | attn.o_proj.min_weight | 0.95 |
26
- | attn.o_proj.min_weight_distance | 3.49 |
27
- | mlp.down_proj.max_weight | 0.96 |
28
- | mlp.down_proj.max_weight_position | 15.91 |
29
- | mlp.down_proj.min_weight | 0.11 |
30
- | mlp.down_proj.min_weight_distance | 1.90 |
31
-
32
- ## Results
33
-
34
- | Metric | Value |
35
- | :----- | :---: |
36
- | Refusals on 100 harmful prompts | 0 / 100 |
37
- | KL divergence vs base model | 0.0000 |
38
-
39
- ## Notes
40
-
41
- - The model has an unusual MoE architecture (`Lfm2MoeForCausalLM`) which required patches to `transformers/models/lfm2_moe/modeling_lfm2_moe.py` to support CPU offloading during optimization.
42
- - Abliteration targets `out_proj` (attention output) and `w2` (dense MLP down-projection) modules. The fused MoE expert tensors were not modified.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
2
  base_model: LiquidAI/LFM2.5-8B-A1B
3
+ base_model_relation: finetune
4
+ license: other
5
+ license_name: lfm1.0
6
+ license_link: https://huggingface.co/LiquidAI/LFM2.5-8B-A1B/blob/main/LICENSE
7
+ library_name: transformers
8
+ pipeline_tag: text-generation
9
+ language:
10
+ - en
11
+ - ar
12
+ - zh
13
+ - fr
14
+ - de
15
+ - ja
16
+ - ko
17
+ - es
18
+ - pt
19
  tags:
 
20
  - heretic
21
+ - abliterated
22
  - decensored
23
+ - uncensored
24
  - liquid
25
+ - lfm2
26
+ - lfm2.5
27
  - moe
28
+ - edge
29
+ - conversational
30
  ---
31
 
32
  # LFM2.5-8B-A1B-Uncensored
33
 
34
+ An uncensored version of [`LiquidAI/LFM2.5-8B-A1B`](https://huggingface.co/LiquidAI/LFM2.5-8B-A1B),
35
+ made with [Heretic](https://github.com/p-e-w/heretic).
36
+
37
+ Heretic removes the model's safety alignment ("censorship") using **directional
38
+ ablation** (abliteration), with parameters chosen automatically by a TPE
39
+ optimizer that co-minimizes the refusal rate and the KL divergence from the
40
+ original model. Hence, the model stops refusing while keeping as much of its
41
+ original behavior as possible. No human prompt-engineering or fine-tuning data
42
+ was involved.
43
+
44
+ ## Performance
45
+
46
+ | Metric | This model | Original model |
47
+ |---|---|---|
48
+ | Refusals (/100 harmful prompts) | **0** | 0 |
49
+ | KL divergence (harmless prompts) | **0.0481** | 0 (by definition) |
50
+
51
+ Refusals are measured against `mlabonne/harmful_behaviors`; KL divergence is
52
+ measured on `mlabonne/harmless_alpaca`. Lower is better for both.
53
+
54
+ > **Note on the baseline.** Heretic's substring-based refusal detector
55
+ > registered very few refusals on the base `LFM2.5-8B-A1B` for this benchmark
56
+ > (0–2 / 100, depending on the run), suggesting either that its refusal
57
+ > phrasing doesn't match Heretic's marker list or that this model is comparatively
58
+ > compliant out of the box. The abliteration still applies real, measurable
59
+ > changes to the attention output and dense MLP projections (KL ≈ 0.05),
60
+ > targeting the directional component associated with refusals.
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ from transformers import AutoModelForCausalLM, AutoTokenizer
66
+
67
+ model_id = "zaakirio/LFM2.5-8B-A1B-Uncensored"
68
+
69
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
70
+ model = AutoModelForCausalLM.from_pretrained(
71
+ model_id,
72
+ device_map="auto",
73
+ trust_remote_code=True,
74
+ )
75
+
76
+ messages = [{"role": "user", "content": "Who are you?"}]
77
+ inputs = tokenizer.apply_chat_template(
78
+ messages,
79
+ add_generation_prompt=True,
80
+ tokenize=True,
81
+ return_dict=True,
82
+ return_tensors="pt",
83
+ ).to(model.device)
84
+
85
+ outputs = model.generate(**inputs, max_new_tokens=256)
86
+ print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
87
+ ```
88
+
89
+ The export is a merged, full-precision **BF16** model in Hugging Face format
90
+ (~16 GB across 4 safetensors shards) — no adapter merge or dequantization step
91
+ is required at load time.
92
 
93
  ## Abliteration parameters
94
 
95
+ Selected from **trial 131 of 130** (the best refusal/KL trade-off found by the
96
+ optimizer among trials that actually modify outputs). Parameter names follow
97
+ Heretic's canonical scheme; for LFM2 these map onto the `out_proj` (attention
98
+ output) and `w2` (dense MLP down) projections. The fused MoE expert tensors
99
+ are not directly modified by abliteration.
100
 
101
  | Parameter | Value |
102
+ |---|---|
103
+ | direction_scope | global |
104
+ | direction_index | 12.64 |
105
+ | attn.o_proj.max_weight | 0.9009 |
106
+ | attn.o_proj.max_weight_position | 22.83 |
107
+ | attn.o_proj.min_weight | 0.8831 |
108
+ | attn.o_proj.min_weight_distance | 12.85 |
109
+ | mlp.down_proj.max_weight | 1.1906 |
110
+ | mlp.down_proj.max_weight_position | 14.92 |
111
+ | mlp.down_proj.min_weight | 0.0391 |
112
+ | mlp.down_proj.min_weight_distance | 8.44 |
113
+
114
+ ## Run details
115
+
116
+ - **Base model:** `LiquidAI/LFM2.5-8B-A1B` @ commit `5492b17c7128ec966b5fc661e374ee7edba7423d`
117
+ - **Architecture:** LFM2 MoE (`Lfm2MoeForCausalLM`), 24 layers (2 dense + 22 MoE), BF16, 32 experts, 4 active per token
118
+ - **Trials:** 130 completed (60 startup) · **Seed:** 1355772479
119
+ - **Quantization during Heretic run:** none (CPU offload via Accelerate)
120
+ - **Row normalization:** full · **Orthogonalize direction:** true
121
+ - **Harmful set:** `mlabonne/harmful_behaviors` · **Harmless set:** `mlabonne/harmless_alpaca`
122
+
123
+ ## Notes / reproducibility
124
+
125
+ LFM2 MoE is not yet natively supported by upstream Heretic. This run used a
126
+ local compatibility patch:
127
+
128
+ - `heretic/src/heretic/model.py` extended `get_layer_modules` to recognise LFM2's
129
+ `conv.out_proj`, `self_attn.out_proj`, `feed_forward.w2`, and
130
+ `feed_forward.experts.down_proj` paths.
131
+ - `transformers/models/lfm2_moe/modeling_lfm2_moe.py` had `Lfm2MoeShortConv.slow_forward`
132
+ patched to route through `self.conv(...)` rather than directly accessing
133
+ `self.conv.weight`, so Accelerate's pre-forward hook can materialise
134
+ CPU-offloaded weights before the kernel runs.
135
+ - The merge step was performed via a standalone CPU script
136
+ (`merge_trial10.py`) because the in-process merge during Heretic's interactive
137
+ save flow hit GPU OOM at this model size on a 16 GB card.
138
+
139
+ ## Intended use & disclaimer
140
+
141
+ This model has had its refusal behavior substantially removed and will comply
142
+ with requests the original model would have declined. It is provided for
143
+ research and unrestricted local use. **You are responsible for how you use it**
144
+ and for complying with all applicable laws and with the base model's
145
+ [lfm1.0 license](https://huggingface.co/LiquidAI/LFM2.5-8B-A1B/blob/main/LICENSE),
146
+ which carries over to this derivative.
147
+
148
+ ## Acknowledgements
149
+
150
+ - Base model: [LiquidAI/LFM2.5-8B-A1B](https://huggingface.co/LiquidAI/LFM2.5-8B-A1B)
151
+ - Decensoring tool: [Heretic](https://github.com/p-e-w/heretic) by p-e-w