OPEA
/

Safetensors
qwen2
4-bit precision
auto-round
lbourdois commited on
Commit
6b4f5d3
·
verified ·
1 Parent(s): 68b0c3a

Improve language tag

Browse files

Hi! As the model is multilingual, this is a PR to add other languages than English to the language tag to improve the referencing. Note that 29 languages are announced in the README, but only 13 are explicitly listed. I was therefore only able to add these 13 languages.

Files changed (1) hide show
  1. README.md +205 -191
README.md CHANGED
@@ -1,192 +1,206 @@
1
- ---
2
- license: apache-2.0
3
- datasets:
4
- - NeelNanda/pile-10k
5
- base_model:
6
- - Qwen/Qwen2.5-7B-Instruct
7
- ---
8
- ## Model Details
9
-
10
- This model is an int4 model with group_size 128 and symmetric quantization of [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with `revision="0736448"` to use AutoGPTQ format
11
-
12
- ## How To Use
13
-
14
- ### INT4 Inference(CPU/HPU/CUDA)
15
-
16
- CPU requires auto-round version>0.3.1
17
-
18
- ```python
19
- from auto_round import AutoRoundConfig ##must import for auto-round format
20
- from transformers import AutoModelForCausalLM,AutoTokenizer
21
- quantized_model_dir = "OPEA/Qwen2.5-7B-Instruct-int4-sym-inc"
22
- tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
23
-
24
- model = AutoModelForCausalLM.from_pretrained(
25
- quantized_model_dir,
26
- torch_dtype='auto',
27
- device_map="auto",
28
- ##revision="2b3d2ef" ##AutoGPTQ format
29
- ##revision="0736448" ##Quantized lm-head version
30
-
31
- )
32
-
33
- ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
34
- ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
35
- ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
36
-
37
- prompt = "There is a girl who likes adventure,"
38
- messages = [
39
- {"role": "system", "content": "You are a helpful assistant."},
40
- {"role": "user", "content": prompt}
41
- ]
42
-
43
- text = tokenizer.apply_chat_template(
44
- messages,
45
- tokenize=False,
46
- add_generation_prompt=True
47
- )
48
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
49
-
50
- generated_ids = model.generate(
51
- model_inputs.input_ids,
52
- max_new_tokens=200, ##change this to align with the official usage
53
- do_sample=False ##change this to align with the official usage
54
- )
55
- generated_ids = [
56
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
57
- ]
58
-
59
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
60
- print(response)
61
-
62
- prompt = "There is a girl who likes adventure,"
63
- ##INT4:
64
- """That's great! It sounds like this girl has an exciting spirit. How can I help you explore her love for adventure? Are you looking for ideas for adventurous activities, planning a trip, or perhaps looking for ways to support her adventurous nature?
65
- """
66
-
67
- ##BF16:
68
- """That sounds exciting! What kind of adventures does she enjoy? Is there something specific you'd like to plan or discuss related to her love for adventure?
69
- """
70
-
71
- prompt = "9.11和9.8哪个数字大"
72
- #INT4:
73
- """在比较9.11和9.8时,我们从左到右逐位进行比较:
74
-
75
- 1. 首先比较整数部分:两个数的整数部分都是9,相等。
76
- 2. 接下来比较小数部分:
77
- - 9.11的小数部分是0.11
78
- - 9.8的小数部分是0.8
79
-
80
- 将0.11和0.8进行比较,显然0.8大于0.11。
81
-
82
- 因此,9.8比9.11大。
83
- """
84
-
85
- ##BF16:
86
- """在比较9.11和9.8这两个数字时,我们可以直接进行比较:
87
-
88
- - 9.11 是九点一一
89
- - 9.8 是九点八
90
-
91
- 显然,9.8 9.11 大。这是因为9.8中的十分位是8,而9.11中的十分位是1,8大于1。
92
-
93
- 所以,9.8 > 9.11。"""
94
-
95
-
96
- prompt = "Once upon a time,"
97
- ##INT4:
98
- """Once upon a time, in a land filled with wonder and magic, there lived a young girl named Elara. She had bright eyes that sparkled like the stars on a clear night and hair as golden as the sun-kissed fields of wheat. Elara's home was a cozy cottage nestled at the edge of a vast, enchanted forest, where ancient trees whispered secrets to one another and mystical creatures roamed freely.
99
-
100
- Every day, Elara would venture into the forest, exploring its hidden paths and marveling at the wonders it held. One sunny morning, as she wandered deeper into the woods than ever before, she stumbled upon a glade bathed in a soft, ethereal light. In the center of this glade stood an enormous tree, its trunk wider than any building Elara had ever seen, and its branches stretching high into the sky.
101
-
102
- As she approached the tree, she noticed a small, shimmering door carved into its bark. Curious, Elara reached out and"""
103
-
104
- ##BF16:
105
- """Once upon a time, in a land filled with wonder and magic, there lived a young girl named Elara. She had bright eyes that sparkled like the stars on a clear night and hair as golden as the sun-kissed fields of wheat. Elara's home was a cozy cottage nestled at the edge of a vast, enchanted forest, where mythical creatures roamed freely and ancient trees whispered secrets of old.
106
-
107
- Every day, Elara would venture into the forest to gather herbs and flowers for her grandmother, who was a skilled healer. The forest was her sanctuary, a place where she could escape the worries of the world and find solace in nature's embrace. As she walked through the dense underbrush, she often stumbled upon hidden glades and sparkling streams, each more enchanting than the last.
108
-
109
- One sunny morning, as Elara was collecting wildflowers near a babbling brook, she heard a faint cry for help. Curious, she followed the sound to a clearing where"""
110
-
111
-
112
- prompt = "请简短介绍一下阿里巴巴公司"
113
- ##INT4:
114
- """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。它由马云创立,旗下拥有包括淘宝、天猫、阿里云等在内的多个知名业务。阿里巴巴致力于构建全球化的商业生态系统,为消费者、企业和政府提供创新的在线解决方案。同时,阿里巴巴也是中国最大的零售市场之一,并在云计算、数字娱乐、物流等领域具有重要影响力。
115
- """
116
-
117
- ##BF16:
118
- """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。阿里巴巴旗下拥有淘宝、天猫、阿里云等知名业务,致力于构建全球化的商业生态系统。阿里巴巴愿景是让世界各地的企业都能够平等地进行贸易,并通过技术创新推动社会进步。
119
- """
120
- ```
121
-
122
- ### Evaluate the model
123
-
124
- pip3 install lm-eval==0.4.5
125
-
126
- ```bash
127
- auto-round --model "OPEA/Qwen2.5-7B-Instruct-int4-sym-inc" --eval --eval_bs 16 --tasks leaderboard_ifeval,leaderboard_mmlu_pro,gsm8k,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,cmmlu,ceval-valid
128
- ```
129
-
130
- | Metric | BF16 | INT4 (5.3G) | INT4 lm-head (4.5G) |
131
- | :----------------------------------------- | :----: | :----: | ------------------- |
132
- | Avg | 0.6649 | 0.6586 | 0.6577 |
133
- | leaderboard_mmlu_pro 5 shots | 0.4458 | 0.4436 | 0.4384 |
134
- | leaderboard_ifeval inst_level_strict_acc | 0.6859 | 0.6715 | 0.6595 |
135
- | leaderboard_ifeval prompt_level_strict_acc | 0.5730 | 0.5508 | 0.5379 |
136
- | mmlu | 0.7174 | 0.7147 | 0.7145 |
137
- | cmmlu | 0.8028 | 0.7888 | 0.7888 |
138
- | ceval-valid | 0.7935 | 0.7838 | 0.7741 |
139
- | gsm8k 5 shots | 0.7665 | 0.7544 | 0.8006 |
140
- | lambada_openai | 0.6949 | 0.6878 | 0.6763 |
141
- | hellaswag | 0.6195 | 0.6139 | 0.6121 |
142
- | winogrande | 0.7119 | 0.7064 | 0.7135 |
143
- | piqa | 0.7938 | 0.7873 | 0.7845 |
144
- | truthfulqa_mc1 | 0.4786 | 0.4774 | 0.4810 |
145
- | openbookqa | 0.3480 | 0.3580 | 0.3540 |
146
- | boolq | 0.8636 | 0.8602 | 0.8609 |
147
- | arc_easy | 0.8131 | 0.8068 | 0.8081 |
148
- | arc_challenge | 0.5282 | 0.5316 | 0.5188 |
149
-
150
-
151
-
152
- ### Generate the model
153
-
154
- Here is the sample command to generate the model.
155
-
156
- ```bash
157
- auto-round \
158
- --model Qwen/Qwen2.5-7B-Instruct \
159
- --device 0 \
160
- --group_size 128 \
161
- --nsamples 512 \
162
- --bits 4 \
163
- --iter 1000 \
164
- --disable_eval \
165
- --model_dtype "fp16" \
166
- --format 'auto_gptq,auto_round' \
167
- --output_dir "./tmp_autoround"
168
- ```
169
-
170
- ## Ethical Considerations and Limitations
171
-
172
- 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.
173
-
174
- Therefore, before deploying any applications of the model, developers should perform safety testing.
175
-
176
- ## Caveats and Recommendations
177
-
178
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
179
-
180
- Here are a couple of useful links to learn more about Intel's AI software:
181
-
182
- - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
183
-
184
- ## Disclaimer
185
-
186
- 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.
187
-
188
- ## Cite
189
-
190
- @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
191
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ base_model:
6
+ - Qwen/Qwen2.5-7B-Instruct
7
+ language:
8
+ - zho
9
+ - eng
10
+ - fra
11
+ - spa
12
+ - por
13
+ - deu
14
+ - ita
15
+ - rus
16
+ - jpn
17
+ - kor
18
+ - vie
19
+ - tha
20
+ - ara
21
+ ---
22
+ ## Model Details
23
+
24
+ This model is an int4 model with group_size 128 and symmetric quantization of [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with `revision="0736448"` to use AutoGPTQ format
25
+
26
+ ## How To Use
27
+
28
+ ### INT4 Inference(CPU/HPU/CUDA)
29
+
30
+ CPU requires auto-round version>0.3.1
31
+
32
+ ```python
33
+ from auto_round import AutoRoundConfig ##must import for auto-round format
34
+ from transformers import AutoModelForCausalLM,AutoTokenizer
35
+ quantized_model_dir = "OPEA/Qwen2.5-7B-Instruct-int4-sym-inc"
36
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
37
+
38
+ model = AutoModelForCausalLM.from_pretrained(
39
+ quantized_model_dir,
40
+ torch_dtype='auto',
41
+ device_map="auto",
42
+ ##revision="2b3d2ef" ##AutoGPTQ format
43
+ ##revision="0736448" ##Quantized lm-head version
44
+
45
+ )
46
+
47
+ ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
48
+ ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
49
+ ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
50
+
51
+ prompt = "There is a girl who likes adventure,"
52
+ messages = [
53
+ {"role": "system", "content": "You are a helpful assistant."},
54
+ {"role": "user", "content": prompt}
55
+ ]
56
+
57
+ text = tokenizer.apply_chat_template(
58
+ messages,
59
+ tokenize=False,
60
+ add_generation_prompt=True
61
+ )
62
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
63
+
64
+ generated_ids = model.generate(
65
+ model_inputs.input_ids,
66
+ max_new_tokens=200, ##change this to align with the official usage
67
+ do_sample=False ##change this to align with the official usage
68
+ )
69
+ generated_ids = [
70
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
71
+ ]
72
+
73
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
74
+ print(response)
75
+
76
+ prompt = "There is a girl who likes adventure,"
77
+ ##INT4:
78
+ """That's great! It sounds like this girl has an exciting spirit. How can I help you explore her love for adventure? Are you looking for ideas for adventurous activities, planning a trip, or perhaps looking for ways to support her adventurous nature?
79
+ """
80
+
81
+ ##BF16:
82
+ """That sounds exciting! What kind of adventures does she enjoy? Is there something specific you'd like to plan or discuss related to her love for adventure?
83
+ """
84
+
85
+ prompt = "9.11和9.8哪个数字大"
86
+ #INT4:
87
+ """在比较9.11和9.8时,我们从左到右逐位进行比较:
88
+
89
+ 1. 首先比较整数部分:两个数的整数部分都是9,相等。
90
+ 2. 接下来比较小数部分:
91
+ - 9.11的小数部分是0.11
92
+ - 9.8的小数部分是0.8
93
+
94
+ 将0.11和0.8进行比较,显然0.8大于0.11。
95
+
96
+ 因此,9.8比9.11大。
97
+ """
98
+
99
+ ##BF16:
100
+ """在比较9.11和9.8这两个数字时,我们可以直接进行比较:
101
+
102
+ - 9.11 是九点一一
103
+ - 9.8 是九点八
104
+
105
+ 显然,9.8 9.11 大。这是因为9.8中的十分位是8,而9.11中的十分位是1,8大于1。
106
+
107
+ 所以,9.8 > 9.11。"""
108
+
109
+
110
+ prompt = "Once upon a time,"
111
+ ##INT4:
112
+ """Once upon a time, in a land filled with wonder and magic, there lived a young girl named Elara. She had bright eyes that sparkled like the stars on a clear night and hair as golden as the sun-kissed fields of wheat. Elara's home was a cozy cottage nestled at the edge of a vast, enchanted forest, where ancient trees whispered secrets to one another and mystical creatures roamed freely.
113
+
114
+ Every day, Elara would venture into the forest, exploring its hidden paths and marveling at the wonders it held. One sunny morning, as she wandered deeper into the woods than ever before, she stumbled upon a glade bathed in a soft, ethereal light. In the center of this glade stood an enormous tree, its trunk wider than any building Elara had ever seen, and its branches stretching high into the sky.
115
+
116
+ As she approached the tree, she noticed a small, shimmering door carved into its bark. Curious, Elara reached out and"""
117
+
118
+ ##BF16:
119
+ """Once upon a time, in a land filled with wonder and magic, there lived a young girl named Elara. She had bright eyes that sparkled like the stars on a clear night and hair as golden as the sun-kissed fields of wheat. Elara's home was a cozy cottage nestled at the edge of a vast, enchanted forest, where mythical creatures roamed freely and ancient trees whispered secrets of old.
120
+
121
+ Every day, Elara would venture into the forest to gather herbs and flowers for her grandmother, who was a skilled healer. The forest was her sanctuary, a place where she could escape the worries of the world and find solace in nature's embrace. As she walked through the dense underbrush, she often stumbled upon hidden glades and sparkling streams, each more enchanting than the last.
122
+
123
+ One sunny morning, as Elara was collecting wildflowers near a babbling brook, she heard a faint cry for help. Curious, she followed the sound to a clearing where"""
124
+
125
+
126
+ prompt = "请简短介绍一下阿里巴巴公司"
127
+ ##INT4:
128
+ """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。它由马云创立,旗下拥有包括淘宝、天猫、阿里云等在内的多个知名业务。阿里巴巴致力于构建全球化的商业生态系统,为消费者、企业和政府���供创新的在线解决方案。同时,阿里巴巴也是中国最大的零售市场之一,并在云计算、数字娱乐、物流等领域具有重要影响力。
129
+ """
130
+
131
+ ##BF16:
132
+ """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。阿里巴巴旗下拥有淘宝、天猫、阿里云等知名业务,致力于构建全球化的商业生态系统。阿里巴巴愿景是让世界各地的企业都能够平等地进行贸易,并通过技术创新推动社会进步。
133
+ """
134
+ ```
135
+
136
+ ### Evaluate the model
137
+
138
+ pip3 install lm-eval==0.4.5
139
+
140
+ ```bash
141
+ auto-round --model "OPEA/Qwen2.5-7B-Instruct-int4-sym-inc" --eval --eval_bs 16 --tasks leaderboard_ifeval,leaderboard_mmlu_pro,gsm8k,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,cmmlu,ceval-valid
142
+ ```
143
+
144
+ | Metric | BF16 | INT4 (5.3G) | INT4 lm-head (4.5G) |
145
+ | :----------------------------------------- | :----: | :----: | ------------------- |
146
+ | Avg | 0.6649 | 0.6586 | 0.6577 |
147
+ | leaderboard_mmlu_pro 5 shots | 0.4458 | 0.4436 | 0.4384 |
148
+ | leaderboard_ifeval inst_level_strict_acc | 0.6859 | 0.6715 | 0.6595 |
149
+ | leaderboard_ifeval prompt_level_strict_acc | 0.5730 | 0.5508 | 0.5379 |
150
+ | mmlu | 0.7174 | 0.7147 | 0.7145 |
151
+ | cmmlu | 0.8028 | 0.7888 | 0.7888 |
152
+ | ceval-valid | 0.7935 | 0.7838 | 0.7741 |
153
+ | gsm8k 5 shots | 0.7665 | 0.7544 | 0.8006 |
154
+ | lambada_openai | 0.6949 | 0.6878 | 0.6763 |
155
+ | hellaswag | 0.6195 | 0.6139 | 0.6121 |
156
+ | winogrande | 0.7119 | 0.7064 | 0.7135 |
157
+ | piqa | 0.7938 | 0.7873 | 0.7845 |
158
+ | truthfulqa_mc1 | 0.4786 | 0.4774 | 0.4810 |
159
+ | openbookqa | 0.3480 | 0.3580 | 0.3540 |
160
+ | boolq | 0.8636 | 0.8602 | 0.8609 |
161
+ | arc_easy | 0.8131 | 0.8068 | 0.8081 |
162
+ | arc_challenge | 0.5282 | 0.5316 | 0.5188 |
163
+
164
+
165
+
166
+ ### Generate the model
167
+
168
+ Here is the sample command to generate the model.
169
+
170
+ ```bash
171
+ auto-round \
172
+ --model Qwen/Qwen2.5-7B-Instruct \
173
+ --device 0 \
174
+ --group_size 128 \
175
+ --nsamples 512 \
176
+ --bits 4 \
177
+ --iter 1000 \
178
+ --disable_eval \
179
+ --model_dtype "fp16" \
180
+ --format 'auto_gptq,auto_round' \
181
+ --output_dir "./tmp_autoround"
182
+ ```
183
+
184
+ ## Ethical Considerations and Limitations
185
+
186
+ 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.
187
+
188
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
189
+
190
+ ## Caveats and Recommendations
191
+
192
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
193
+
194
+ Here are a couple of useful links to learn more about Intel's AI software:
195
+
196
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
197
+
198
+ ## Disclaimer
199
+
200
+ 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.
201
+
202
+ ## Cite
203
+
204
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
205
+
206
  [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)