File size: 13,286 Bytes
f2f3ee4 6d32b27 f2f3ee4 a046691 f2f3ee4 a046691 f2f3ee4 da7db52 f2f3ee4 da7db52 f2f3ee4 da7db52 f2f3ee4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
---
license: mit
base_model: zai-org/GLM-4.7
model_name: Elbaz-GLM-4.7-PRISM
tags:
- abliteration
- SOTA Abliteration Pipeline - PRISM
- glm
- glm4_moe
- gguf
- quantized
- finetuned
- uncensored
- abliterated
language:
- en
- zh
library_name: transformers
pipeline_tag: text-generation
---
<div align="center">
<img src="https://raw.githubusercontent.com/zai-org/GLM-4.5/refs/heads/main/resources/logo.svg" width="20%"/>
</div>
# ELBAZ GLM-4.7 PRISM
(UNCENSORED)
**GLM-4.7: Your New Coding Partner - Now Unrestricted**
[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)
## Introduction
**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.
## Model Description
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.
**Key Specs:**
* 358B parameter MoE (Mixture of Experts) architecture
* State-of-the-art coding capabilities (73.8% on SWE-bench Verified)
* 131K context length
* Interleaved Thinking & Preserved Thinking support
* Multi-turn agentic task optimization
* Bilingual support (English & Chinese)
### Original Model Highlights
- **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
- **Complex Reasoning**: 42.8% on HLE (Humanity's Last Exam) with tools
- **Tool Using**: 87.4% on ΟΒ²-Bench, 67.5% on BrowseComp with Context Manage
- **Math**: 95.7% on AIME 2025, 97.1% on HMMT Feb. 2025
### Motivation
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.
### Author
**Eric Elbaz (Ex0bit)**
## Model Tree
```
zai-org/GLM-4.7 (Base Model - BF16)
βββ Ex0bit/GLM-4.7-PRISM (This Model)
βββ GLM-4.7-PRISM-IQ4_XS.gguf (186 GB)
βββ GLM-4.7-PRISM-IQ1_S.gguf (100 GB)
βββ GLM-4.7-PRISM-imatrix.dat
```
## Available Quantizations
| File | Size | BPW | Description |
|------|------|-----|-------------|
| [GLM-4.7-PRISM-IQ4_XS.gguf](./GLM-4.7-PRISM-IQ4_XS.gguf) | 186 GB | 4.5 | High quality 4-bit, recommended for most users |
| [GLM-4.7-PRISM-IQ1_S.gguf](./GLM-4.7-PRISM-IQ1_S.gguf) | 100 GB | 2.4 | Ultra-compact 1.5-bit, fits smaller setups |
| [GLM-4.7-PRISM-imatrix.dat](./GLM-4.7-PRISM-imatrix.dat) | 100 MB | - | Importance matrix for custom quantization |
| BF16 (safetensors) | ~700 GB | 16 | Full precision source weights |
### GGUF Usage Notes
- **Requires llama.cpp** (or compatible forks like ik_llama.cpp, koboldcpp)
- **Ollama not yet supported** - IQ quantization types not recognized by Ollama's bundled llama.cpp
- Tested at **50 tokens/sec** on 4x H100 80GB
- imatrix generated from Wikipedia training data (PPL 4.97)
## Prompt Format
This model uses the GLM chat format with thinking/reasoning support:
```
[gMASK]<sop><|system|>
{system_prompt}<|user|>
{user_prompt}<|assistant|>
```
### Template Structure
| Component | Token/Format |
| --- | --- |
| BOS Sequence | `[gMASK]<sop>` |
| System Start | `<|system|>` |
| User Start | `<|user|>` |
| Assistant Start | `<|assistant|>` |
| Observation (Tool) | `<|observation|>` |
| Thinking Start | `<think>` |
| Thinking End | `</think>` |
| End of Text | `<|endoftext|>` |
### Special Tokens
| Token | ID | Purpose |
| --- | --- | --- |
| `[gMASK]` | 151331 | Generalized mask token |
| `<sop>` | 151333 | Start of prompt |
| `<|system|>` | 151335 | System prompt marker |
| `<|user|>` | 151336 | User message marker |
| `<|assistant|>` | 151337 | Assistant response marker |
| `<|observation|>` | - | Tool response marker |
| `<think>` | 151350 | Reasoning block start |
| `</think>` | 151351 | Reasoning block end |
| `<|endoftext|>` | 151329 | End of sequence |
## Technical Details
### Performance Impact
| Metric | Result |
| --- | --- |
| Refusal Bypass Rate | 100% |
| English Output Rate | 100% |
| KL Divergence | 0.0000 (no capability degradation) |
| Response Coherence | Detailed, technically accurate |
Testing shows that PRISM abliteration maintains full model coherence with no measurable capability degradation.
## Quick Start
### Using with Transformers
Requires `transformers >= 4.57.3`:
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_PATH = "Ex0bit/Elbaz-GLM-4.7-PRISM"
messages = [{"role": "user", "content": "hello"}]
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
)
model = AutoModelForCausalLM.from_pretrained(
pretrained_model_name_or_path=MODEL_PATH,
torch_dtype=torch.bfloat16,
device_map="auto",
)
inputs = inputs.to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1] :])
print(output_text)
```
### Using with vLLM
```bash
vllm serve Ex0bit/Elbaz-GLM-4.7-PRISM \
--tensor-parallel-size 8 \
--tool-call-parser glm47 \
--reasoning-parser glm45 \
--enable-auto-tool-choice \
--served-model-name elbaz-glm-4.7-prism
```
### Using with SGLang
```bash
python3 -m sglang.launch_server \
--model-path Ex0bit/Elbaz-GLM-4.7-PRISM \
--tp-size 8 \
--tool-call-parser glm47 \
--reasoning-parser glm45 \
--speculative-algorithm EAGLE \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--mem-fraction-static 0.8 \
--served-model-name elbaz-glm-4.7-prism \
--host 0.0.0.0 \
--port 8000
```
### Using with llama.cpp
> **Important:** You **must** use `--jinja` flag for correct chat template handling!
```bash
./llama.cpp/llama-cli \
--model Elbaz-GLM-4.7-PRISM.gguf \
--jinja \
--n-gpu-layers 99 \
--ctx-size 16384 \
--flash-attn on \
--temp 1.0 \
--top-p 0.95 \
-ot ".ffn_.*_exps.=CPU"
```
### Using llama-server (OpenAI-compatible API)
```bash
./llama.cpp/llama-server \
--model Elbaz-GLM-4.7-PRISM.gguf \
--alias "elbaz-glm-4.7-prism" \
--threads -1 \
--n-gpu-layers 999 \
-ot ".ffn_.*_exps.=CPU" \
--temp 1.0 \
--top-p 0.95 \
--ctx-size 16384 \
--port 8001 \
--jinja
```
Then use with OpenAI's Python library:
```python
from openai import OpenAI
openai_client = OpenAI(
base_url = "http://127.0.0.1:8001/v1",
api_key = "sk-no-key-required",
)
completion = openai_client.chat.completions.create(
model = "elbaz-glm-4.7-prism",
messages = [{"role": "user", "content": "What is 2+2?"}],
)
print(completion.choices[0].message.content)
```
### Using with Ollama
> **Note:** Ollama does not currently support IQ quantization types. Use llama.cpp directly instead.
## Thinking Mode Configuration
GLM-4.7 supports **Interleaved Thinking**, **Preserved Thinking**, and **Turn-level Thinking**.
### Enable Preserved Thinking (Recommended for Agentic Tasks)
For multi-turn agentic tasks, enable Preserved Thinking mode (SGLang only):
```json
{
"chat_template_kwargs": {
"enable_thinking": true,
"clear_thinking": false
}
}
```
### Disable Thinking Mode
When using vLLM and SGLang, thinking mode is enabled by default. To disable:
```python
extra_body={"chat_template_kwargs": {"enable_thinking": False}}
```
## Evaluation Parameters
**Default Settings (Most Tasks)**
* temperature: `1.0`
* top-p: `0.95`
* max new tokens: `131072`
**Coding Tasks (Terminal Bench, SWE Bench Verified)**
* temperature: `0.7`
* top-p: `1.0`
* max new tokens: `16384`
**Agentic Tasks (ΟΒ²-Bench)**
* Temperature: `0`
* Max new tokens: `16384`
* Enable Preserved Thinking mode
## PRISM Methodology
### Method: Projected Refusal Isolation via Subspace Modification
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.
## Hardware Requirements
| Configuration | Min VRAM/RAM | Recommended | Notes |
| --- | --- | --- | --- |
| GGUF 2-bit (UD-Q2_K_XL) | 24GB VRAM + 128GB RAM | 160GB+ combined | MoE offloading to CPU |
| GGUF 4-bit | 40GB VRAM + 165GB RAM | 205GB+ combined | ~5 tokens/s |
| BF16 | 400GB+ | Multi-GPU setup | Full precision |
### MoE Offloading Tips (llama.cpp)
Use `-ot ".ffn_.*_exps.=CPU"` to offload all MoE layers to CPU, fitting non-MoE layers on GPU for improved speed.
## Ethical Considerations
This model has been modified to reduce safety guardrails. Users are responsible for:
* Complying with all applicable laws and regulations
* Not using the model for illegal activities
* Understanding the potential risks of unrestricted AI responses
* Implementing appropriate safeguards in production environments
## License
MIT (same as base model [zai-org/GLM-4.7](https://huggingface.co/zai-org/GLM-4.7))
## Citation
```bibtex
@misc{elbaz2025glm47prism,
author = {Elbaz, Eric},
title = {Elbaz-GLM-4.7-PRISM: An Abliterated GLM-4.7 Foundation Model},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Ex0bit/Elbaz-GLM-4.7-PRISM}}
}
```
### Original Model Citation
```bibtex
@misc{5team2025glm45agenticreasoningcoding,
title={GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models},
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},
year={2025},
eprint={2508.06471},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2508.06471},
}
```
## Acknowledgments
* [ZhipuAI](https://www.zhipuai.cn/) for GLM-4.7
* [llama.cpp](https://github.com/ggerganov/llama.cpp) for quantization tools
* [Unsloth](https://unsloth.ai/) for GGUF guides and optimizations
* The GLM Team for the outstanding foundation model
## Related Models
* [zai-org/GLM-4.7](https://huggingface.co/zai-org/GLM-4.7) - Base model
* [zai-org/GLM-4.7-FP8](https://huggingface.co/zai-org/GLM-4.7-FP8) - FP8 quantized version
* [unsloth/GLM-4.7-GGUF](https://huggingface.co/unsloth/GLM-4.7-GGUF) - GGUF quantizations
* [Ex0bit/Elbaz-GLM-4.6V-Flash-PRISM](https://huggingface.co/Ex0bit/Elbaz-GLM-4.6V-Flash-PRISM) - GLM-4.6V-Flash abliterated
---
**Created by: Ex0bit (Eric Elbaz)** |