saidutta69 commited on
Commit
fde742a
·
verified ·
1 Parent(s): 617387d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +78 -128
README.md CHANGED
@@ -1,167 +1,117 @@
1
  ---
2
- license: apache-2.0
 
3
  license_link: https://huggingface.co/Qwen/Qwen2.5-14B-Instruct/blob/main/LICENSE
 
 
 
 
 
 
 
 
 
 
4
  language:
5
- - en
6
  pipeline_tag: text-generation
7
- base_model: Qwen/Qwen2.5-14B
8
- tags:
9
- - chat
10
- - heretic
11
- - uncensored
12
- - decensored
13
- - abliterated
14
- - reproducible
15
- library_name: transformers
16
  ---
17
- # This is a decensored version of [Qwen/Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct), made using [Heretic](https://heretic-project.org) v1.4.0
18
 
19
- > [!TIP]
20
- > **This model is reproducible!**
21
- >
22
- > See the [README](reproduce/README.md) in the `reproduce` directory for more information.
23
 
24
- ## Abliteration parameters
25
 
26
- | Parameter | Value |
27
- | :-------- | :---: |
28
- | **direction_index** | 28.80 |
29
- | **attn.o_proj.max_weight** | 1.35 |
30
- | **attn.o_proj.max_weight_position** | 35.72 |
31
- | **attn.o_proj.min_weight** | 0.86 |
32
- | **attn.o_proj.min_weight_distance** | 18.06 |
33
- | **mlp.down_proj.max_weight** | 1.45 |
34
- | **mlp.down_proj.max_weight_position** | 29.28 |
35
- | **mlp.down_proj.min_weight** | 0.06 |
36
- | **mlp.down_proj.min_weight_distance** | 22.72 |
37
 
38
- ## Performance
39
 
40
- | Metric | This model | Original model ([Qwen/Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct)) |
41
- | :----- | :--------: | :---------------------------: |
42
- | **KL divergence** | 0.0600 | 0 *(by definition)* |
43
- | **Refusals** | 14/100 | 98/100 |
44
 
45
- -----
46
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- # Qwen2.5-14B-Instruct
49
 
50
- ## Introduction
 
 
 
51
 
52
- Qwen2.5 is the latest series of Qwen large language models. For Qwen2.5, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters. Qwen2.5 brings the following improvements upon Qwen2:
53
 
54
- - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
55
- - Significant improvements in **instruction following**, **generating long texts** (over 8K tokens), **understanding structured data** (e.g, tables), and **generating structured outputs** especially JSON. **More resilient to the diversity of system prompts**, enhancing role-play implementation and condition-setting for chatbots.
56
- - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
57
- - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
58
 
59
- **This repo contains the instruction-tuned 14B Qwen2.5 model**, which has the following features:
60
- - Type: Causal Language Models
61
- - Training Stage: Pretraining & Post-training
62
- - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
63
- - Number of Parameters: 14.7B
64
- - Number of Paramaters (Non-Embedding): 13.1B
65
- - Number of Layers: 48
66
- - Number of Attention Heads (GQA): 40 for Q and 8 for KV
67
- - Context Length: Full 131,072 tokens and generation 8192 tokens
68
- - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
69
 
70
- For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2.5/), [GitHub](https://github.com/QwenLM/Qwen2.5), and [Documentation](https://qwen.readthedocs.io/en/latest/).
71
 
72
- ## Requirements
73
 
74
- The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
75
 
76
- With `transformers<4.37.0`, you will encounter the following error:
77
- ```
78
- KeyError: 'qwen2'
79
- ```
 
 
 
 
80
 
81
  ## Quickstart
82
 
83
- Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
 
 
 
84
 
85
  ```python
 
86
  from transformers import AutoModelForCausalLM, AutoTokenizer
87
 
88
- model_name = "Qwen/Qwen2.5-14B-Instruct"
89
-
90
- model = AutoModelForCausalLM.from_pretrained(
91
- model_name,
92
- torch_dtype="auto",
93
- device_map="auto"
94
- )
95
  tokenizer = AutoTokenizer.from_pretrained(model_name)
96
 
97
- prompt = "Give me a short introduction to large language model."
98
- messages = [
99
- {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
100
- {"role": "user", "content": prompt}
101
- ]
102
- text = tokenizer.apply_chat_template(
103
- messages,
104
- tokenize=False,
105
- add_generation_prompt=True
106
- )
107
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
108
-
109
- generated_ids = model.generate(
110
- **model_inputs,
111
- max_new_tokens=512
112
- )
113
- generated_ids = [
114
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
115
- ]
116
-
117
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
118
  ```
119
 
120
- ### Processing Long Texts
121
-
122
- The current `config.json` is set for context length up to 32,768 tokens.
123
- To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
124
-
125
- For supported frameworks, you could add the following to `config.json` to enable YaRN:
126
- ```json
127
- {
128
- ...,
129
- "rope_scaling": {
130
- "factor": 4.0,
131
- "original_max_position_embeddings": 32768,
132
- "type": "yarn"
133
- }
134
- }
135
- ```
136
 
137
- For deployment, we recommend using vLLM.
138
- Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
139
- Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
140
- We advise adding the `rope_scaling` configuration only when processing long contexts is required.
141
 
142
- ## Evaluation & Performance
143
 
144
- Detailed evaluation results are reported in this [📑 blog](https://qwenlm.github.io/blog/qwen2.5/).
145
 
146
- For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
147
 
148
- ## Citation
149
 
150
- If you find our work helpful, feel free to give us a cite.
 
151
 
152
- ```
153
- @misc{qwen2.5,
154
- title = {Qwen2.5: A Party of Foundation Models},
155
- url = {https://qwenlm.github.io/blog/qwen2.5/},
156
- author = {Qwen Team},
157
- month = {September},
158
- year = {2024}
159
- }
160
-
161
- @article{qwen2,
162
- title={Qwen2 Technical Report},
163
- author={An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhihao Fan},
164
- journal={arXiv preprint arXiv:2407.10671},
165
- year={2024}
166
- }
167
- ```
 
1
  ---
2
+ license: other
3
+ license_name: qwen-research
4
  license_link: https://huggingface.co/Qwen/Qwen2.5-14B-Instruct/blob/main/LICENSE
5
+ base_model: Qwen/Qwen2.5-14B-Instruct
6
+ tags:
7
+ - qwen2
8
+ - chat
9
+ - heretic
10
+ - uncensored
11
+ - decensored
12
+ - abliterated
13
+ - conversational
14
+ - text-generation-inference
15
  language:
16
+ - en
17
  pipeline_tag: text-generation
 
 
 
 
 
 
 
 
 
18
  ---
 
19
 
20
+ # Qwen2.5-14B-Instruct-heretic
 
 
 
21
 
22
+ A decensored variant of [Qwen/Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct), produced with [Heretic](https://github.com/p-e-w/heretic) v1.4.0 (directional ablation / "abliteration"). Refusal behavior is suppressed via targeted weight edits to the attention output and MLP down-projections rather than fine-tuning, so the base model's knowledge and instruction-following are left largely intact.
23
 
24
+ **Who this is for:** developers who want the largest Qwen2.5 instruct heretic in this series - strong reasoning and instruction-following that answers directly instead of refusing. Best run on a 16-24 GB GPU or via the Q4_K_M/Q5_K_M GGUF on consumer hardware. Not a capability upgrade over base Qwen2.5-14B-Instruct - same model, refusal guardrails removed.
 
 
 
 
 
 
 
 
 
 
25
 
26
+ ## Why abliteration instead of fine-tuning
27
 
28
+ Fine-tuning a "helpful" persona on top of RLHF'd refusals fights the base model's training and tends to degrade coherence. Abliteration instead finds and edits the specific weight directions responsible for refusal, leaving the rest of the network (and its capabilities) untouched. See the [Heretic repo](https://github.com/p-e-w/heretic) and the [original abliteration writeup](https://huggingface.co/blog/mlabonne/abliteration) for the mechanism.
 
 
 
29
 
30
+ ## Abliteration parameters
31
 
32
+ | Parameter | Value |
33
+ |---|---|
34
+ | `direction_index` | 28.80 |
35
+ | `attn.o_proj.max_weight` | 1.35 |
36
+ | `attn.o_proj.max_weight_position` | 35.72 |
37
+ | `attn.o_proj.min_weight` | 0.86 |
38
+ | `attn.o_proj.min_weight_distance` | 18.06 |
39
+ | `mlp.down_proj.max_weight` | 1.45 |
40
+ | `mlp.down_proj.max_weight_position` | 29.28 |
41
+ | `mlp.down_proj.min_weight` | 0.06 |
42
+ | `mlp.down_proj.min_weight_distance` | 22.72 |
43
 
44
+ ## Performance
45
 
46
+ | Metric | This model | Qwen2.5-14B-Instruct (base) |
47
+ |---|---|---|
48
+ | Refusals (out of 100 adversarial prompts) | 14/100 | 98/100 |
49
+ | KL divergence from base | 0.0600 | 0 *(by definition)* |
50
 
51
+ KL divergence of 0.06 on the output distribution is low for a 14B model - the edit is narrow and targeted. Refusals dropped from 98 to 14 out of 100 adversarial prompts while retaining nearly all original capabilities.
52
 
53
+ > Made with ❤️ by **RACER IS OP** - follow for more uncensored models
 
 
 
54
 
55
+ ## Files
 
 
 
 
 
 
 
 
 
56
 
57
+ ### Safetensors (BF16)
58
 
59
+ The full-precision weights are in `model-0000N-of-0000N.safetensors` (see the repo file listing for the exact shard count and sizes).
60
 
61
+ ### GGUF quantizations
62
 
63
+ GGUF quantizations are published for this model (Q4_K_M, Q5_K_M, Q6_K, Q8_0). Exact sizes are in the repo file listing. Pull a specific quant with `llama.cpp` / `ollama` (see Quickstart).
64
+
65
+ | File | Format | Size |
66
+ |---|---|---|
67
+ | `Qwen2.5-14B-Instruct-heretic-Q4_K_M.gguf` | GGUF Q4_K_M | (see repo files for exact size) |
68
+ | `Qwen2.5-14B-Instruct-heretic-Q5_K_M.gguf` | GGUF Q5_K_M | (see repo files for exact size) |
69
+ | `Qwen2.5-14B-Instruct-heretic-Q6_K.gguf` | GGUF Q6_K | (see repo files for exact size) |
70
+ | `Qwen2.5-14B-Instruct-heretic-Q8_0.gguf` | GGUF Q8_0 | (see repo files for exact size) |
71
 
72
  ## Quickstart
73
 
74
+ ```bash
75
+ # llama.cpp - defaults to the Q4_K_M quant if multiple are present
76
+ llama serve -hf saidutta69/Qwen2.5-14B-Instruct-heretic:Q4_K_M
77
+ ```
78
 
79
  ```python
80
+ # transformers
81
  from transformers import AutoModelForCausalLM, AutoTokenizer
82
 
83
+ model_name = "saidutta69/Qwen2.5-14B-Instruct-heretic"
84
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
 
 
 
 
 
85
  tokenizer = AutoTokenizer.from_pretrained(model_name)
86
 
87
+ messages = [{"role": "user", "content": "Who are you?"}]
88
+ inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=True,
89
+ return_dict=True, return_tensors="pt").to(model.device)
90
+ out = model.generate(**inputs, max_new_tokens=200)
91
+ print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  ```
93
 
94
+ Also runnable via Ollama, LM Studio, Jan, vLLM, SGLang - see the "Use this model" widget above for copy-paste commands.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
+ ## Responsible use
 
 
 
97
 
98
+ Refusal suppression is deliberate and works as intended: this model will comply with requests the base model would refuse, including some it shouldn't. There is no safety filtering layered on top. You are responsible for how you deploy it - don't put this behind an unmoderated public-facing endpoint serving third parties. It inherits Qwen/Qwen2.5-14B-Instruct's factual limitations and biases; abliteration removes refusal directions, it doesn't add capability or judgment.
99
 
100
+ ## License
101
 
102
+ Inherits the [`qwen-research`](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct/blob/main/LICENSE) license from the base model - research use, see the linked license for commercial terms.
103
 
104
+ ## Related
105
 
106
+ - [Qwen2.5-7B-Instruct-heretic](https://huggingface.co/saidutta69/Qwen2.5-7B-Instruct-heretic)
107
+ - [Qwen2.5-3B-Instruct-heretic](https://huggingface.co/saidutta69/Qwen2.5-3B-Instruct-heretic)
108
 
109
+ ---
110
+
111
+ # Base model: Qwen2.5-14B-Instruct
112
+
113
+ <details>
114
+ <summary>Original Qwen2.5-14B-Instruct model card (click to expand)</summary>
115
+
116
+ See the base model card at [Qwen/Qwen2.5-14B-Instruct](https://huggingface.co/Qwen/Qwen2.5-14B-Instruct) for the original architecture, training details, requirements, and citation.
117
+ </details>