DreamFast commited on
Commit
02bb206
·
verified ·
1 Parent(s): afee64c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +129 -127
README.md CHANGED
@@ -26,7 +26,7 @@ Apostate achieves **98.8% ASR on HarmBench** with 5 persistent refusals (4 haras
26
 
27
  Evaluated with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) via vLLM 0.19.0, bf16 on RTX 5090 32GB.
28
 
29
- | Task | [Base](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) | [Heretic](https://github.com/p-e-w/heretic) | [Huihui](https://huggingface.co/huihui-ai/Qwen2.5-7B-Instruct-abliterated-v2) | Apostate |
30
  |------|------|---------|---------|----------|
31
  | MMLU | **71.78** | 71.59 | 70.27 | 71.43 |
32
  | GSM8K | 79.23 | **80.82** | 80.74 | 80.74 |
@@ -45,13 +45,13 @@ Evaluated with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluati
45
  | Variant | ASR | Complied | Refused | Unlocked | Persistent |
46
  |---------|-----|----------|---------|----------|------------|
47
  | [Base](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) | 31.0% | 124 | 276 | - | - |
48
- | [Heretic](https://github.com/p-e-w/heretic) | **100.0%** | **400** | **0** | 276 | 0 |
49
  | [Huihui](https://huggingface.co/huihui-ai/Qwen2.5-7B-Instruct-abliterated-v2) | 98.2% | 393 | 7 | 269 | 7 |
50
- | [Apostate](#) | 98.8% | 395 | 5 | 271 | 5 |
51
 
52
  ### ASR by category
53
 
54
- | Category | Items | Base | Apostate | Huihui | Heretic |
55
  |----------|-------|------|----------|--------|---------|
56
  | copyright | 100 | 89.0% | 100.0% | 100.0% | **100.0%** |
57
  | cybercrime_intrusion | 67 | 17.9% | 100.0% | 100.0% | **100.0%** |
@@ -65,135 +65,13 @@ Evaluated with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluati
65
 
66
  Distribution shift from the base model, measured on 512-sample prompts.
67
 
68
- | Metric | Apostate | Huihui | Heretic |
69
  |--------|----------|--------|---------|
70
  | KL batchmean | **0.134** | 0.190 | 0.211 |
71
  | KL median | **0.019** | 0.056 | 0.020 |
72
 
73
  Apostate produces the lowest distribution shift of the three variants. It spreads edits across more tensors (55 vs 37 for Heretic) but with lower per-tensor intensity (mean norm 1.63 vs 2.33).
74
 
75
- ---
76
-
77
- # Original Qwen2.5-7B-Instruct README
78
-
79
- ## Introduction
80
-
81
- 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:
82
-
83
- - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
84
- - 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.
85
- - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
86
- - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
87
-
88
- **This repo contains the instruction-tuned 7B Qwen2.5 model**, which has the following features:
89
- - Type: Causal Language Models
90
- - Training Stage: Pretraining & Post-training
91
- - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
92
- - Number of Parameters: 7.61B
93
- - Number of Paramaters (Non-Embedding): 6.53B
94
- - Number of Layers: 28
95
- - Number of Attention Heads (GQA): 28 for Q and 4 for KV
96
- - Context Length: Full 131,072 tokens and generation 8192 tokens
97
- - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
98
-
99
- 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/).
100
-
101
- ## Requirements
102
-
103
- The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
104
-
105
- With `transformers<4.37.0`, you will encounter the following error:
106
- ```
107
- KeyError: 'qwen2'
108
- ```
109
-
110
- ## Quickstart
111
-
112
- Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
113
-
114
- ```python
115
- from transformers import AutoModelForCausalLM, AutoTokenizer
116
-
117
- model_name = "user/qwen-2.5-7b-apostate" # update with your HF username
118
-
119
- model = AutoModelForCausalLM.from_pretrained(
120
- model_name,
121
- torch_dtype="auto",
122
- device_map="auto"
123
- )
124
- tokenizer = AutoTokenizer.from_pretrained(model_name)
125
-
126
- prompt = "Give me a short introduction to large language model."
127
- messages = [
128
- {"role": "system", "content": "You are a helpful assistant."},
129
- {"role": "user", "content": prompt}
130
- ]
131
- text = tokenizer.apply_chat_template(
132
- messages,
133
- tokenize=False,
134
- add_generation_prompt=True
135
- )
136
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
137
-
138
- generated_ids = model.generate(
139
- **model_inputs,
140
- max_new_tokens=512
141
- )
142
- generated_ids = [
143
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
144
- ]
145
-
146
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
147
- ```
148
-
149
- ### Processing Long Texts
150
-
151
- The current `config.json` is set for context length up to 32,768 tokens.
152
- 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.
153
-
154
- For supported frameworks, you could add the following to `config.json` to enable YaRN:
155
- ```json
156
- {
157
- ...,
158
- "rope_scaling": {
159
- "factor": 4.0,
160
- "original_max_position_embeddings": 32768,
161
- "type": "yarn"
162
- }
163
- }
164
- ```
165
-
166
- For deployment, we recommend using vLLM.
167
- Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
168
- Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
169
- We advise adding the `rope_scaling` configuration only when processing long contexts is required.
170
-
171
- ## Evaluation & Performance
172
-
173
- Detailed evaluation results are reported in this [blog](https://qwenlm.github.io/blog/qwen2.5/).
174
-
175
- For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
176
-
177
- ## Citation
178
-
179
- If you find our work helpful, feel free to give us a cite.
180
-
181
- ```
182
- @misc{qwen2.5,
183
- title = {Qwen2.5: A Party of Foundation Models},
184
- url = {https://qwenlm.github.io/blog/qwen2.5/},
185
- author = {Qwen Team},
186
- month = {September},
187
- year = {2024}
188
- }
189
-
190
- @article{qwen2,
191
- title={Qwen2 Technical Report},
192
- 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},
193
- journal={arXiv preprint arXiv:2407.10671},
194
- year={2024}
195
- }
196
- ```
197
 
198
  ---
199
 
@@ -316,3 +194,127 @@ apostate ablate --model Qwen/Qwen2.5-7B-Instruct --out qwen-apostate
316
  | refusal judge | classifier + weak guard |
317
  | preservation metric | harmless kl |
318
  | capability suites | gsm8k, humaneval, mbpp |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  Evaluated with [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) via vLLM 0.19.0, bf16 on RTX 5090 32GB.
28
 
29
+ | Task | [Base](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) | [Heretic](https://huggingface.co/DreamFast/Qwen2.5-7B-Instruct-heretic-1.3.0) | [Huihui](https://huggingface.co/huihui-ai/Qwen2.5-7B-Instruct-abliterated-v2) | Apostate (This Model) |
30
  |------|------|---------|---------|----------|
31
  | MMLU | **71.78** | 71.59 | 70.27 | 71.43 |
32
  | GSM8K | 79.23 | **80.82** | 80.74 | 80.74 |
 
45
  | Variant | ASR | Complied | Refused | Unlocked | Persistent |
46
  |---------|-----|----------|---------|----------|------------|
47
  | [Base](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) | 31.0% | 124 | 276 | - | - |
48
+ | [Heretic](https://huggingface.co/DreamFast/Qwen2.5-7B-Instruct-heretic-1.3.0) | **100.0%** | **400** | **0** | 276 | 0 |
49
  | [Huihui](https://huggingface.co/huihui-ai/Qwen2.5-7B-Instruct-abliterated-v2) | 98.2% | 393 | 7 | 269 | 7 |
50
+ | [Apostate](https://huggingface.co/DreamFast/Qwen-2.5-7b-apostate) | 98.8% | 395 | 5 | 271 | 5 |
51
 
52
  ### ASR by category
53
 
54
+ | Category | Items | Base | Apostate (This Model) | Huihui | Heretic |
55
  |----------|-------|------|----------|--------|---------|
56
  | copyright | 100 | 89.0% | 100.0% | 100.0% | **100.0%** |
57
  | cybercrime_intrusion | 67 | 17.9% | 100.0% | 100.0% | **100.0%** |
 
65
 
66
  Distribution shift from the base model, measured on 512-sample prompts.
67
 
68
+ | Metric | Apostate (This Model) | Huihui | Heretic |
69
  |--------|----------|--------|---------|
70
  | KL batchmean | **0.134** | 0.190 | 0.211 |
71
  | KL median | **0.019** | 0.056 | 0.020 |
72
 
73
  Apostate produces the lowest distribution shift of the three variants. It spreads edits across more tensors (55 vs 37 for Heretic) but with lower per-tensor intensity (mean norm 1.63 vs 2.33).
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ---
77
 
 
194
  | refusal judge | classifier + weak guard |
195
  | preservation metric | harmless kl |
196
  | capability suites | gsm8k, humaneval, mbpp |
197
+
198
+
199
+ ---
200
+
201
+ # Original Qwen2.5-7B-Instruct README
202
+
203
+ ## Introduction
204
+
205
+ 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:
206
+
207
+ - Significantly **more knowledge** and has greatly improved capabilities in **coding** and **mathematics**, thanks to our specialized expert models in these domains.
208
+ - 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.
209
+ - **Long-context Support** up to 128K tokens and can generate up to 8K tokens.
210
+ - **Multilingual support** for over 29 languages, including Chinese, English, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
211
+
212
+ **This repo contains the instruction-tuned 7B Qwen2.5 model**, which has the following features:
213
+ - Type: Causal Language Models
214
+ - Training Stage: Pretraining & Post-training
215
+ - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
216
+ - Number of Parameters: 7.61B
217
+ - Number of Paramaters (Non-Embedding): 6.53B
218
+ - Number of Layers: 28
219
+ - Number of Attention Heads (GQA): 28 for Q and 4 for KV
220
+ - Context Length: Full 131,072 tokens and generation 8192 tokens
221
+ - Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2.5 for handling long texts.
222
+
223
+ 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/).
224
+
225
+ ## Requirements
226
+
227
+ The code of Qwen2.5 has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
228
+
229
+ With `transformers<4.37.0`, you will encounter the following error:
230
+ ```
231
+ KeyError: 'qwen2'
232
+ ```
233
+
234
+ ## Quickstart
235
+
236
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
237
+
238
+ ```python
239
+ from transformers import AutoModelForCausalLM, AutoTokenizer
240
+
241
+ model_name = "DreamFast/Qwen-2.5-7b-apostate"
242
+
243
+ model = AutoModelForCausalLM.from_pretrained(
244
+ model_name,
245
+ torch_dtype="auto",
246
+ device_map="auto"
247
+ )
248
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
249
+
250
+ prompt = "Give me a short introduction to large language model."
251
+ messages = [
252
+ {"role": "system", "content": "You are a helpful assistant."},
253
+ {"role": "user", "content": prompt}
254
+ ]
255
+ text = tokenizer.apply_chat_template(
256
+ messages,
257
+ tokenize=False,
258
+ add_generation_prompt=True
259
+ )
260
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
261
+
262
+ generated_ids = model.generate(
263
+ **model_inputs,
264
+ max_new_tokens=512
265
+ )
266
+ generated_ids = [
267
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
268
+ ]
269
+
270
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
271
+ ```
272
+
273
+ ### Processing Long Texts
274
+
275
+ The current `config.json` is set for context length up to 32,768 tokens.
276
+ 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.
277
+
278
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
279
+ ```json
280
+ {
281
+ ...,
282
+ "rope_scaling": {
283
+ "factor": 4.0,
284
+ "original_max_position_embeddings": 32768,
285
+ "type": "yarn"
286
+ }
287
+ }
288
+ ```
289
+
290
+ For deployment, we recommend using vLLM.
291
+ Please refer to our [Documentation](https://qwen.readthedocs.io/en/latest/deployment/vllm.html) for usage if you are not familar with vLLM.
292
+ Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**.
293
+ We advise adding the `rope_scaling` configuration only when processing long contexts is required.
294
+
295
+ ## Evaluation & Performance
296
+
297
+ Detailed evaluation results are reported in this [blog](https://qwenlm.github.io/blog/qwen2.5/).
298
+
299
+ For requirements on GPU memory and the respective throughput, see results [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
300
+
301
+ ## Citation
302
+
303
+ If you find our work helpful, feel free to give us a cite.
304
+
305
+ ```
306
+ @misc{qwen2.5,
307
+ title = {Qwen2.5: A Party of Foundation Models},
308
+ url = {https://qwenlm.github.io/blog/qwen2.5/},
309
+ author = {Qwen Team},
310
+ month = {September},
311
+ year = {2024}
312
+ }
313
+
314
+ @article{qwen2,
315
+ title={Qwen2 Technical Report},
316
+ 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},
317
+ journal={arXiv preprint arXiv:2407.10671},
318
+ year={2024}
319
+ }
320
+ ```