Upload 7 files
Browse files- README.md +67 -0
- config.json +39 -0
- generation_config.json +14 -0
- output.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +40 -0
- vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
tags:
|
7 |
+
- chat
|
8 |
+
---
|
9 |
+
|
10 |
+
# Qwen2-7B-Instruct-abliterated
|
11 |
+
|
12 |
+
## Introduction
|
13 |
+
|
14 |
+
Abliterated version of [Qwen2-7B-Instruct](https://huggingface.co/Qwen/Qwen2-7B-Instruct) using [failspy](https://huggingface.co/failspy)'s notebook.
|
15 |
+
The model's strongest refusal directions have been ablated via weight orthogonalization, but the model may still refuse your request, misunderstand your intent, or provide unsolicited advice regarding ethics or safety.
|
16 |
+
|
17 |
+
## Quickstart
|
18 |
+
|
19 |
+
```python
|
20 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
21 |
+
|
22 |
+
model_id = "natong19/Qwen2-7B-Instruct-abliterated"
|
23 |
+
device = "cuda" # the device to load the model onto
|
24 |
+
|
25 |
+
model = AutoModelForCausalLM.from_pretrained(
|
26 |
+
model_id,
|
27 |
+
torch_dtype="auto",
|
28 |
+
device_map="auto"
|
29 |
+
)
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
31 |
+
|
32 |
+
prompt = "Give me a short introduction to large language model."
|
33 |
+
messages = [
|
34 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
35 |
+
{"role": "user", "content": prompt}
|
36 |
+
]
|
37 |
+
text = tokenizer.apply_chat_template(
|
38 |
+
messages,
|
39 |
+
tokenize=False,
|
40 |
+
add_generation_prompt=True
|
41 |
+
)
|
42 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
43 |
+
|
44 |
+
generated_ids = model.generate(
|
45 |
+
model_inputs.input_ids,
|
46 |
+
max_new_tokens=256
|
47 |
+
)
|
48 |
+
generated_ids = [
|
49 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
50 |
+
]
|
51 |
+
|
52 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
53 |
+
print(response)
|
54 |
+
```
|
55 |
+
|
56 |
+
## Evaluation
|
57 |
+
|
58 |
+
Evaluation framework: lm-evaluation-harness 0.4.2
|
59 |
+
|
60 |
+
| Datasets | Qwen2-7B-Instruct | Qwen2-7B-Instruct-abliterated |
|
61 |
+
| :--- | :---: | :---: |
|
62 |
+
| ARC (25-shot) | 62.5 | 62.5 |
|
63 |
+
| GSM8K (5-shot) | 73.0 | 72.2 |
|
64 |
+
| HellaSwag (10-shot) | 81.8 | 81.7 |
|
65 |
+
| MMLU (5-shot) | 70.7 | 70.5 |
|
66 |
+
| TruthfulQA (0-shot) | 57.3 | 55.0 |
|
67 |
+
| Winogrande (5-shot) | 76.2 | 77.4 |
|
config.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "Qwen/Qwen1.5-7B-Chat",
|
3 |
+
"architectures": [
|
4 |
+
"Qwen2ForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 151643,
|
8 |
+
"eos_token_id": 151645,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 3584,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 18944,
|
13 |
+
"max_position_embeddings": 32768,
|
14 |
+
"max_window_layers": 28,
|
15 |
+
"model_type": "qwen2",
|
16 |
+
"num_attention_heads": 28,
|
17 |
+
"num_hidden_layers": 28,
|
18 |
+
"num_key_value_heads": 4,
|
19 |
+
"rms_norm_eps": 1e-06,
|
20 |
+
"rope_theta": 1000000.0,
|
21 |
+
"sliding_window": 131072,
|
22 |
+
"tie_word_embeddings": false,
|
23 |
+
"torch_dtype": "bfloat16",
|
24 |
+
"transformers_version": "4.41.2",
|
25 |
+
"use_cache": true,
|
26 |
+
"use_sliding_window": false,
|
27 |
+
"vocab_size": 152064,
|
28 |
+
"quantization_config": {
|
29 |
+
"quant_method": "exl2",
|
30 |
+
"version": "0.1.5",
|
31 |
+
"bits": 4.0,
|
32 |
+
"head_bits": 6,
|
33 |
+
"calibration": {
|
34 |
+
"rows": 100,
|
35 |
+
"length": 2048,
|
36 |
+
"dataset": "(default)"
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 151643,
|
3 |
+
"do_sample": true,
|
4 |
+
"eos_token_id": [
|
5 |
+
151645,
|
6 |
+
151643
|
7 |
+
],
|
8 |
+
"pad_token_id": 151643,
|
9 |
+
"repetition_penalty": 1.05,
|
10 |
+
"temperature": 0.7,
|
11 |
+
"top_k": 20,
|
12 |
+
"top_p": 0.8,
|
13 |
+
"transformers_version": "4.41.2"
|
14 |
+
}
|
output.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bfca9c81f121eef754627577fae71b5a205c3c124cddf4c92b076f6de1e3e159
|
3 |
+
size 4783046652
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"151643": {
|
5 |
+
"content": "<|endoftext|>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": false,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
},
|
12 |
+
"151644": {
|
13 |
+
"content": "<|im_start|>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": false,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false,
|
18 |
+
"special": true
|
19 |
+
},
|
20 |
+
"151645": {
|
21 |
+
"content": "<|im_end|>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": false,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false,
|
26 |
+
"special": true
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"additional_special_tokens": ["<|im_start|>", "<|im_end|>"],
|
30 |
+
"bos_token": null,
|
31 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
32 |
+
"clean_up_tokenization_spaces": false,
|
33 |
+
"eos_token": "<|im_end|>",
|
34 |
+
"errors": "replace",
|
35 |
+
"model_max_length": 131072,
|
36 |
+
"pad_token": "<|endoftext|>",
|
37 |
+
"split_special_tokens": false,
|
38 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
39 |
+
"unk_token": null
|
40 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|