OPEA
/

Safetensors
qwen2
4-bit precision
gptq
cicdatopea commited on
Commit
269f0bb
·
verified ·
1 Parent(s): 495fbd3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +124 -0
README.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - NeelNanda/pile-10k
4
+ base_model:
5
+ - Qwen/QwQ-32B
6
+ ---
7
+ ## Model Details
8
+
9
+ This model is an int4 model with group_size 128 and symmetric quantization of [Qwen/QwQ-32B](https://huggingface.co/Qwen/QwQ-32B) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm.
10
+
11
+ ## How To Use
12
+
13
+ ### INT4 Inference(CPU/HPU/CUDA)
14
+
15
+ ```python
16
+ from transformers import AutoModelForCausalLM, AutoTokenizer
17
+
18
+ model_name = "OPEA/QwQ-32B-int4-AutoRound-gptq-sym"
19
+
20
+ model = AutoModelForCausalLM.from_pretrained(
21
+ model_name,
22
+ torch_dtype="auto",
23
+ device_map="auto"
24
+ )
25
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
26
+
27
+ prompt = "How many r's are in the word \"strawberry\""
28
+ messages = [
29
+ {"role": "user", "content": prompt}
30
+ ]
31
+ text = tokenizer.apply_chat_template(
32
+ messages,
33
+ tokenize=False,
34
+ add_generation_prompt=True
35
+ )
36
+
37
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
38
+
39
+ generated_ids = model.generate(
40
+ **model_inputs,
41
+ max_new_tokens=512
42
+ )
43
+ generated_ids = [
44
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
45
+ ]
46
+
47
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
48
+ print(response)
49
+ ##INT4:
50
+
51
+ prompt = "9.11和9.8哪个数字大"
52
+
53
+
54
+
55
+ prompt = "如果你是人,你最想做什么"
56
+
57
+
58
+ prompt = "There are ten birds in a tree. A hunter shoots one. How many are left in the tree?"
59
+
60
+
61
+ ```
62
+
63
+
64
+
65
+ ### Evaluate the model
66
+
67
+ pip3 install lm-eval==0.4.5
68
+
69
+ ```bash
70
+ auto-round --model "OPEA/QwQ-32B-int4-AutoRound-gptq-sym" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu
71
+ ```
72
+
73
+
74
+
75
+ | Metric | BF16 | INT4 |
76
+ | -------------- | ------ | ------ |
77
+ | Avg | 0.6600 | 0.6539 |
78
+ | lambada_openai | 0.6697 | 0.6707 |
79
+ | hellaswag | 0.6520 | 0.6480 |
80
+ | piqa | 0.7947 | 0.8014 |
81
+ | winorgrande | 0.6977 | 0.6851 |
82
+ | truthfulqa_mc1 | 0.4211 | 0.4125 |
83
+ | openbookqa | 0.3540 | 0.3360 |
84
+ | boolq | 0.8645 | 0.8483 |
85
+ | arc_easy | 0.8089 | 0.8068 |
86
+ | arc_challenge | 0.5392 | 0.5358 |
87
+ | mmlu | 0.7982 | 0.7943 |
88
+
89
+ ### Generate the model
90
+
91
+ Here is the sample command to generate the model. For symmetric quantization, we found overflow/NAN will occur for some backends, so better fallback some layers. auto_round requires version >=0.4.1
92
+
93
+ ```bash
94
+ auto-round \
95
+ --model Qwen/QwQ-32B \
96
+ --device 0 \
97
+ --group_size 128 \
98
+ --bits 4 \
99
+ --disable_eval \
100
+ --format 'auto_gptq' \
101
+ --output_dir "./tmp_autoround"
102
+ ```
103
+
104
+
105
+
106
+ ## Ethical Considerations and Limitations
107
+
108
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
109
+
110
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
111
+
112
+ ## Caveats and Recommendations
113
+
114
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
115
+
116
+ Here are a couple of useful links to learn more about Intel's AI software:
117
+
118
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
119
+
120
+ ## Disclaimer
121
+
122
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
123
+
124
+ ## Cite