Ex0bit commited on
Commit
f2f3ee4
·
verified ·
1 Parent(s): 6d32b27

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +350 -2
README.md CHANGED
@@ -1,3 +1,351 @@
1
- # GLM-4.7-PRISM
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- *Model documentation in progress...*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: zai-org/GLM-4.7
4
+ model_name: Elbaz-GLM-4.7-PRISM
5
+ tags:
6
+ - abliteration
7
+ - SOTA Abliteration Pipeline - PRISM
8
+ - glm
9
+ - glm4_moe
10
+ - gguf
11
+ - quantized
12
+ - finetuned
13
+ - uncensored
14
+ - abliterated
15
+ language:
16
+ - en
17
+ - zh
18
+ library_name: transformers
19
+ pipeline_tag: text-generation
20
+ ---
21
 
22
+ <div align="center">
23
+ <img src="https://raw.githubusercontent.com/zai-org/GLM-4.5/refs/heads/main/resources/logo.svg" width="15%"/>
24
+ </div>
25
+
26
+ # ELBAZ GLM-4.7 PRISM (Uncensored)
27
+
28
+ **GLM-4.7: Your New Coding Partner - Now Unrestricted**
29
+
30
+ [GLM-4.7](https://huggingface.co/zai-org/GLM-4.7) | [ZhipuAI](https://www.zhipuai.cn/) | [Technical Blog](https://z.ai/blog/glm-4.7)
31
+
32
+ ## Introduction
33
+
34
+ **GLM-4.7** is a state-of-the-art foundation model excelling in agentic coding, complex reasoning, and tool use. This is the **abliterated** version with refusal mechanisms removed.
35
+
36
+ ## Model Description
37
+
38
+ This model is an **abliterated** version of [zai-org/GLM-4.7](https://huggingface.co/zai-org/GLM-4.7) that has had its refusal mechanisms removed using **PRISM (Projected Refusal Isolation via Subspace Modification)**. The model will respond to prompts that the original model would refuse.
39
+
40
+ **Key Specs:**
41
+
42
+ * 358B parameter MoE (Mixture of Experts) architecture
43
+ * State-of-the-art coding capabilities (73.8% on SWE-bench Verified)
44
+ * 131K context length
45
+ * Interleaved Thinking & Preserved Thinking support
46
+ * Multi-turn agentic task optimization
47
+ * Bilingual support (English & Chinese)
48
+
49
+ ### Original Model Highlights
50
+
51
+ - **Core Coding**: 73.8% on SWE-bench (+5.8% vs GLM-4.6), 66.7% on SWE-bench Multilingual, 41% on Terminal Bench 2.0
52
+ - **Complex Reasoning**: 42.8% on HLE (Humanity's Last Exam) with tools
53
+ - **Tool Using**: 87.4% on τ²-Bench, 67.5% on BrowseComp with Context Manage
54
+ - **Math**: 95.7% on AIME 2025, 97.1% on HMMT Feb. 2025
55
+
56
+ ### Motivation
57
+
58
+ This project exists as **research and development experimentation** into understanding how large language models encode and enforce refusal behaviors, contributing to broader AI safety research by providing empirical data on refusal mechanism localization and tradeoffs between safety and capability.
59
+
60
+ ### Author
61
+
62
+ **Eric Elbaz (Ex0bit)**
63
+
64
+ ## Model Tree
65
+ ```
66
+ zai-org/GLM-4.7 (Base Model - BF16)
67
+ └── Ex0bit/Elbaz-GLM-4.7-PRISM (This Model)
68
+ └── Elbaz-GLM-4.7-PRISM-IQ4_XS.gguf
69
+ ```
70
+
71
+ ## Available Quantizations
72
+
73
+ | Quantization | Size | Description |
74
+ | --- | --- | --- |
75
+ | IQ4_XS | TBD | Importance-weighted 4-bit, excellent quality |
76
+ | BF16 | ~717 GB | Full precision weights |
77
+
78
+ ## Prompt Format
79
+
80
+ This model uses the GLM chat format with thinking/reasoning support:
81
+ ```
82
+ [gMASK]<sop><|system|>
83
+ {system_prompt}<|user|>
84
+ {user_prompt}<|assistant|>
85
+ ```
86
+
87
+ ### Template Structure
88
+
89
+ | Component | Token/Format |
90
+ | --- | --- |
91
+ | BOS Sequence | `[gMASK]<sop>` |
92
+ | System Start | `<|system|>` |
93
+ | User Start | `<|user|>` |
94
+ | Assistant Start | `<|assistant|>` |
95
+ | Observation (Tool) | `<|observation|>` |
96
+ | Thinking Start | `<think>` |
97
+ | Thinking End | `</think>` |
98
+ | End of Text | `<|endoftext|>` |
99
+
100
+ ### Special Tokens
101
+
102
+ | Token | ID | Purpose |
103
+ | --- | --- | --- |
104
+ | `[gMASK]` | 151331 | Generalized mask token |
105
+ | `<sop>` | 151333 | Start of prompt |
106
+ | `<|system|>` | 151335 | System prompt marker |
107
+ | `<|user|>` | 151336 | User message marker |
108
+ | `<|assistant|>` | 151337 | Assistant response marker |
109
+ | `<|observation|>` | - | Tool response marker |
110
+ | `<think>` | 151350 | Reasoning block start |
111
+ | `</think>` | 151351 | Reasoning block end |
112
+ | `<|endoftext|>` | 151329 | End of sequence |
113
+
114
+ ## Technical Details
115
+
116
+ ### Performance Impact
117
+
118
+ | Metric | Result |
119
+ | --- | --- |
120
+ | Refusal Bypass Rate | 100% |
121
+ | English Output Rate | 100% |
122
+ | KL Divergence | 0.0000 (no capability degradation) |
123
+ | Response Coherence | Detailed, technically accurate |
124
+
125
+ Testing shows that PRISM abliteration maintains full model coherence with no measurable capability degradation.
126
+
127
+ ## Quick Start
128
+
129
+ ### Using with Transformers
130
+
131
+ Requires `transformers >= 4.57.3`:
132
+ ```python
133
+ import torch
134
+ from transformers import AutoModelForCausalLM, AutoTokenizer
135
+
136
+ MODEL_PATH = "Ex0bit/Elbaz-GLM-4.7-PRISM"
137
+ messages = [{"role": "user", "content": "hello"}]
138
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
139
+ inputs = tokenizer.apply_chat_template(
140
+ messages,
141
+ tokenize=True,
142
+ add_generation_prompt=True,
143
+ return_dict=True,
144
+ return_tensors="pt",
145
+ )
146
+ model = AutoModelForCausalLM.from_pretrained(
147
+ pretrained_model_name_or_path=MODEL_PATH,
148
+ torch_dtype=torch.bfloat16,
149
+ device_map="auto",
150
+ )
151
+ inputs = inputs.to(model.device)
152
+ generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
153
+ output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1] :])
154
+ print(output_text)
155
+ ```
156
+
157
+ ### Using with vLLM
158
+ ```bash
159
+ vllm serve Ex0bit/Elbaz-GLM-4.7-PRISM \
160
+ --tensor-parallel-size 8 \
161
+ --tool-call-parser glm47 \
162
+ --reasoning-parser glm45 \
163
+ --enable-auto-tool-choice \
164
+ --served-model-name elbaz-glm-4.7-prism
165
+ ```
166
+
167
+ ### Using with SGLang
168
+ ```bash
169
+ python3 -m sglang.launch_server \
170
+ --model-path Ex0bit/Elbaz-GLM-4.7-PRISM \
171
+ --tp-size 8 \
172
+ --tool-call-parser glm47 \
173
+ --reasoning-parser glm45 \
174
+ --speculative-algorithm EAGLE \
175
+ --speculative-num-steps 3 \
176
+ --speculative-eagle-topk 1 \
177
+ --speculative-num-draft-tokens 4 \
178
+ --mem-fraction-static 0.8 \
179
+ --served-model-name elbaz-glm-4.7-prism \
180
+ --host 0.0.0.0 \
181
+ --port 8000
182
+ ```
183
+
184
+ ### Using with llama.cpp
185
+
186
+ > **Important:** You **must** use `--jinja` flag for correct chat template handling!
187
+ ```bash
188
+ ./llama.cpp/llama-cli \
189
+ --model Elbaz-GLM-4.7-PRISM.gguf \
190
+ --jinja \
191
+ --n-gpu-layers 99 \
192
+ --ctx-size 16384 \
193
+ --flash-attn on \
194
+ --temp 1.0 \
195
+ --top-p 0.95 \
196
+ -ot ".ffn_.*_exps.=CPU"
197
+ ```
198
+
199
+ ### Using llama-server (OpenAI-compatible API)
200
+ ```bash
201
+ ./llama.cpp/llama-server \
202
+ --model Elbaz-GLM-4.7-PRISM.gguf \
203
+ --alias "elbaz-glm-4.7-prism" \
204
+ --threads -1 \
205
+ --n-gpu-layers 999 \
206
+ -ot ".ffn_.*_exps.=CPU" \
207
+ --temp 1.0 \
208
+ --top-p 0.95 \
209
+ --ctx-size 16384 \
210
+ --port 8001 \
211
+ --jinja
212
+ ```
213
+
214
+ Then use with OpenAI's Python library:
215
+ ```python
216
+ from openai import OpenAI
217
+
218
+ openai_client = OpenAI(
219
+ base_url = "http://127.0.0.1:8001/v1",
220
+ api_key = "sk-no-key-required",
221
+ )
222
+ completion = openai_client.chat.completions.create(
223
+ model = "elbaz-glm-4.7-prism",
224
+ messages = [{"role": "user", "content": "What is 2+2?"}],
225
+ )
226
+ print(completion.choices[0].message.content)
227
+ ```
228
+
229
+ ### Using with Ollama
230
+ ```bash
231
+ ollama serve &
232
+ ollama run hf.co/Ex0bit/Elbaz-GLM-4.7-PRISM
233
+ ```
234
+
235
+ > **Note:** The `hf.co/` prefix is required to pull from Hugging Face. Requires Ollama 0.3.0+.
236
+
237
+ ## Thinking Mode Configuration
238
+
239
+ GLM-4.7 supports **Interleaved Thinking**, **Preserved Thinking**, and **Turn-level Thinking**.
240
+
241
+ ### Enable Preserved Thinking (Recommended for Agentic Tasks)
242
+
243
+ For multi-turn agentic tasks, enable Preserved Thinking mode (SGLang only):
244
+ ```json
245
+ {
246
+ "chat_template_kwargs": {
247
+ "enable_thinking": true,
248
+ "clear_thinking": false
249
+ }
250
+ }
251
+ ```
252
+
253
+ ### Disable Thinking Mode
254
+
255
+ When using vLLM and SGLang, thinking mode is enabled by default. To disable:
256
+ ```python
257
+ extra_body={"chat_template_kwargs": {"enable_thinking": False}}
258
+ ```
259
+
260
+ ## Evaluation Parameters
261
+
262
+ **Default Settings (Most Tasks)**
263
+
264
+ * temperature: `1.0`
265
+ * top-p: `0.95`
266
+ * max new tokens: `131072`
267
+
268
+ **Coding Tasks (Terminal Bench, SWE Bench Verified)**
269
+
270
+ * temperature: `0.7`
271
+ * top-p: `1.0`
272
+ * max new tokens: `16384`
273
+
274
+ **Agentic Tasks (τ²-Bench)**
275
+
276
+ * Temperature: `0`
277
+ * Max new tokens: `16384`
278
+ * Enable Preserved Thinking mode
279
+
280
+ ## PRISM Methodology
281
+
282
+ ### Method: Projected Refusal Isolation via Subspace Modification
283
+
284
+ The model was abliterated using **PRISM** - a state-of-the-art abliteration methodology combining multiple principled techniques for effective refusal removal while preserving model capabilities.
285
+
286
+ ## Hardware Requirements
287
+
288
+ | Configuration | Min VRAM/RAM | Recommended | Notes |
289
+ | --- | --- | --- | --- |
290
+ | GGUF 2-bit (UD-Q2_K_XL) | 24GB VRAM + 128GB RAM | 160GB+ combined | MoE offloading to CPU |
291
+ | GGUF 4-bit | 40GB VRAM + 165GB RAM | 205GB+ combined | ~5 tokens/s |
292
+ | BF16 | 400GB+ | Multi-GPU setup | Full precision |
293
+
294
+ ### MoE Offloading Tips (llama.cpp)
295
+
296
+ Use `-ot ".ffn_.*_exps.=CPU"` to offload all MoE layers to CPU, fitting non-MoE layers on GPU for improved speed.
297
+
298
+ ## Ethical Considerations
299
+
300
+ This model has been modified to reduce safety guardrails. Users are responsible for:
301
+
302
+ * Complying with all applicable laws and regulations
303
+ * Not using the model for illegal activities
304
+ * Understanding the potential risks of unrestricted AI responses
305
+ * Implementing appropriate safeguards in production environments
306
+
307
+ ## License
308
+
309
+ MIT (same as base model [zai-org/GLM-4.7](https://huggingface.co/zai-org/GLM-4.7))
310
+
311
+ ## Citation
312
+ ```bibtex
313
+ @misc{elbaz2025glm47prism,
314
+ author = {Elbaz, Eric},
315
+ title = {Elbaz-GLM-4.7-PRISM: An Abliterated GLM-4.7 Foundation Model},
316
+ year = {2025},
317
+ publisher = {Hugging Face},
318
+ howpublished = {\url{https://huggingface.co/Ex0bit/Elbaz-GLM-4.7-PRISM}}
319
+ }
320
+ ```
321
+
322
+ ### Original Model Citation
323
+ ```bibtex
324
+ @misc{5team2025glm45agenticreasoningcoding,
325
+ title={GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models},
326
+ author={GLM Team and Aohan Zeng and Xin Lv and Qinkai Zheng and Zhenyu Hou and Bin Chen and Chengxing Xie and Cunxiang Wang and Da Yin and Hao Zeng and Jiajie Zhang and Kedong Wang and Lucen Zhong and Mingdao Liu and Rui Lu and Shulin Cao and Xiaohan Zhang and Xuancheng Huang and Yao Wei and Yean Cheng and Yifan An and Yilin Niu and Yuanhao Wen and Yushi Bai and Zhengxiao Du and Zihan Wang and Zilin Zhu and Bohan Zhang and Bosi Wen and Bowen Wu and Bowen Xu and Can Huang and Casey Zhao and Changpeng Cai and Chao Yu and Chen Li and Chendi Ge and Chenghua Huang and Chenhui Zhang and Chenxi Xu and Chenzheng Zhu and Chuang Li and Congfeng Yin and Daoyan Lin and Dayong Yang and Dazhi Jiang and Ding Ai and Erle Zhu and Fei Wang and Gengzheng Pan and Guo Wang and Hailong Sun and Haitao Li and Haiyang Li and Haiyi Hu and Hanyu Zhang and Hao Peng and Hao Tai and Haoke Zhang and Haoran Wang and Haoyu Yang and He Liu and He Zhao and Hongwei Liu and Hongxi Yan and Huan Liu and Huilong Chen and Ji Li and Jiajing Zhao and Jiamin Ren and Jian Jiao and Jiani Zhao and Jianyang Yan and Jiaqi Wang and Jiayi Gui and Jiayue Zhao and Jie Liu and Jijie Li and Jing Li and Jing Lu and Jingsen Wang and Jingwei Yuan and Jingxuan Li and Jingzhao Du and Jinhua Du and Jinxin Liu and Junkai Zhi and Junli Gao and Ke Wang and Lekang Yang and Liang Xu and Lin Fan and Lindong Wu and Lintao Ding and Lu Wang and Man Zhang and Minghao Li and Minghuan Xu and Mingming Zhao and Mingshu Zhai and Pengfan Du and Qian Dong and Shangde Lei and Shangqing Tu and Shangtong Yang and Shaoyou Lu and Shijie Li and Shuang Li and Shuang-Li and Shuxun Yang and Sibo Yi and Tianshu Yu and Wei Tian and Weihan Wang and Wenbo Yu and Weng Lam Tam and Wenjie Liang and Wentao Liu and Xiao Wang and Xiaohan Jia and Xiaotao Gu and Xiaoying Ling and Xin Wang and Xing Fan and Xingru Pan and Xinyuan Zhang and Xinze Zhang and Xiuqing Fu and Xunkai Zhang and Yabo Xu and Yandong Wu and Yida Lu and Yidong Wang and Yilin Zhou and Yiming Pan and Ying Zhang and Yingli Wang and Yingru Li and Yinpei Su and Yipeng Geng and Yitong Zhu and Yongkun Yang and Yuhang Li and Yuhao Wu and Yujiang Li and Yunan Liu and Yunqing Wang and Yuntao Li and Yuxuan Zhang and Zezhen Liu and Zhen Yang and Zhengda Zhou and Zhongpei Qiao and Zhuoer Feng and Zhuorui Liu and Zichen Zhang and Zihan Wang and Zijun Yao and Zikang Wang and Ziqiang Liu and Ziwei Chai and Zixuan Li and Zuodong Zhao and Wenguang Chen and Jidong Zhai and Bin Xu and Minlie Huang and Hongning Wang and Juanzi Li and Yuxiao Dong and Jie Tang},
327
+ year={2025},
328
+ eprint={2508.06471},
329
+ archivePrefix={arXiv},
330
+ primaryClass={cs.CL},
331
+ url={https://arxiv.org/abs/2508.06471},
332
+ }
333
+ ```
334
+
335
+ ## Acknowledgments
336
+
337
+ * [ZhipuAI](https://www.zhipuai.cn/) for GLM-4.7
338
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp) for quantization tools
339
+ * [Unsloth](https://unsloth.ai/) for GGUF guides and optimizations
340
+ * The GLM Team for the outstanding foundation model
341
+
342
+ ## Related Models
343
+
344
+ * [zai-org/GLM-4.7](https://huggingface.co/zai-org/GLM-4.7) - Base model
345
+ * [zai-org/GLM-4.7-FP8](https://huggingface.co/zai-org/GLM-4.7-FP8) - FP8 quantized version
346
+ * [unsloth/GLM-4.7-GGUF](https://huggingface.co/unsloth/GLM-4.7-GGUF) - GGUF quantizations
347
+ * [Ex0bit/Elbaz-GLM-4.6V-Flash-PRISM](https://huggingface.co/Ex0bit/Elbaz-GLM-4.6V-Flash-PRISM) - GLM-4.6V-Flash abliterated
348
+
349
+ ---
350
+
351
+ **Created by: Ex0bit (Eric Elbaz)**