OPEA
/

Safetensors
sys-lpot-val commited on
Commit
38b23d7
1 Parent(s): 70fbbe9

Signed-off-by: sys-lpot-val <sys_lpot_val@intel.com>

.gitattributes CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ added_tokens.json filter=lfs diff=lfs merge=lfs -text
37
+ generation_config.json filter=lfs diff=lfs merge=lfs -text
38
+ quantization_config.json filter=lfs diff=lfs merge=lfs -text
39
+ vocab.json filter=lfs diff=lfs merge=lfs -text
40
+ config.json filter=lfs diff=lfs merge=lfs -text
41
+ model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
42
+ special_tokens_map.json filter=lfs diff=lfs merge=lfs -text
43
+ tokenizer_config.json filter=lfs diff=lfs merge=lfs -text
44
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,215 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ ---
6
+ ## Model Details
7
+
8
+ This model is an int4 model with group_size 128 and symmetric quantization of [Qwen/Qwen2.5-32B-Instruct](https://huggingface.co/Qwen/Qwen2.5-32B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round).
9
+
10
+ ## How To Use
11
+
12
+ ### INT4 Inference(CPU/HPU/CUDA)
13
+
14
+ CPU/ CUDA requires auto-round version>0.3.1
15
+
16
+ ```python
17
+ from auto_round import AutoRoundConfig ##must import for auto-round format
18
+ from transformers import AutoModelForCausalLM,AutoTokenizer
19
+ quantized_model_dir = "Intel/Qwen2.5-32B-Instruct-int4-inc"
20
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
21
+
22
+ model = AutoModelForCausalLM.from_pretrained(
23
+ quantized_model_dir,
24
+ torch_dtype='auto',
25
+ device_map="auto",
26
+ )
27
+
28
+ ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
29
+ ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
30
+ ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
31
+
32
+ prompt = "There is a girl who likes adventure,"
33
+ messages = [
34
+ {"role": "system", "content": "You are a helpful assistant."},
35
+ {"role": "user", "content": prompt}
36
+ ]
37
+
38
+ text = tokenizer.apply_chat_template(
39
+ messages,
40
+ tokenize=False,
41
+ add_generation_prompt=True
42
+ )
43
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
44
+
45
+ generated_ids = model.generate(
46
+ model_inputs.input_ids,
47
+ max_new_tokens=200, ##change this to align with the official usage
48
+ do_sample=False ##change this to align with the official usage
49
+ )
50
+ generated_ids = [
51
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
52
+ ]
53
+
54
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
55
+ print(response)
56
+
57
+ prompt = "There is a girl who likes adventure,"
58
+ ##INT4:
59
+ """It sounds like you're starting to tell a story! Would you like me to help you continue it? Here's one possible continuation:
60
+
61
+ There is a girl who loves adventure. Her name is Lily and she has always been drawn to the unknown. From a young age, she would spend hours exploring the woods behind her house, imagining herself as a brave explorer discovering new lands. As she grew older, her thirst for adventure only intensified. She began traveling the world, seeking out thrilling experiences and pushing herself out of her comfort zone at every turn.
62
+
63
+ Is there anything specific you had in mind for this character or story? I'd be happy to help develop it further if you have any ideas!"""
64
+
65
+ ##BF16:
66
+ """That sounds exciting! What would you like to know or do regarding this girl who loves adventure? Perhaps you're looking for ideas on activities she might enjoy or ways to support her adventurous spirit. Let me know how I can assist you further!"""
67
+
68
+ prompt = "9.11和9.8哪个数字大"
69
+ #INT4:
70
+ """? 9.8 比 9.11 大。在比较这两个数字时,我们首先看整数部分,它们都是9,所以需要比较小数部分。0.8(即8/10)比0.11(即11/100)要大。因此,9.8 > 9.11。
71
+
72
+ 具体来说:
73
+ - 9.8 = 9 + 0.8
74
+ - 9.11 = 9 + 0.11
75
+
76
+ 显然,0.8 > 0.11,所以 9.8 > 9.11。"""
77
+
78
+ ##BF16:
79
+ """要比较两个数字的大小,我们可以从左到右逐位进行比较。
80
+
81
+ 首先,我们看整数部分:
82
+ - 9.11 的整数部分是 9。
83
+ - 9.8 的整数部分也是 9。
84
+
85
+ 因为它们的整数部分相同,我们需要比较小数部分:
86
+ - 9.11 的小数部分是 0.11。
87
+ - 9.8 的小数部分是 0.8。
88
+
89
+ 接下来,我们比较小数部分的第一位:
90
+ - 0.11 的第一位是 1。
91
+ - 0.8 的第一位是 8。
92
+
93
+ 显然,8 比 1 大。因此,0.8 比 0.11 大。
94
+
95
+ 所以,9.8 比 9.11 大。"""
96
+
97
+
98
+ prompt = "Once upon a time,"
99
+ ##INT4:
100
+ """ there was a king who loved to collect beautiful flowers. He had a vast garden filled with all sorts of colorful and fragrant blooms. However, one day he decided that he wanted to have the most unique flower in the world. So he sent out a proclamation to his kingdom, offering a great reward to anyone who could bring him a flower that no one else had ever seen before.
101
+ A young girl named Lily heard about the king's proclamation and became determined to win the prize. She spent days wandering through the forest, searching for the perfect flower. Finally, she stumbled upon a small, delicate flower that she had never seen before. It was a bright shade of purple and had a sweet fragrance.
102
+ Lily brought the flower back to the king, who was amazed by its beauty and uniqueness. He declared her the winner and gave her the reward. But as she was leaving, the king stopped her and asked if she would teach him how to grow this special flower. Lily agreed and spent the next
103
+ """
104
+
105
+ ##BF16:
106
+ """Once upon a time, in a land far, far away, there was a small village nestled between rolling hills and dense forests. The villagers lived simple lives, farming the land and tending to their livestock. They were a close-knit community, always ready to help one another in times of need.
107
+
108
+ In the heart of this village stood an ancient oak tree, under which the elders would gather to share stories and make important decisions for the community. Among these tales were whispers of a hidden treasure, said to be guarded by a mythical creature deep within the forest.
109
+
110
+ One day, a young girl named Elara overheard these whispers while fetching water from the well. Her curiosity piqued, she decided to embark on a quest to uncover the truth behind the legend. With nothing but her wits, a small backpack, and a map drawn by the village cartographer, Elara set off into the unknown.
111
+
112
+ As she ventured deeper into the forest, she encountered various challenges and made unexpected friends along
113
+ """
114
+
115
+
116
+ prompt = "请简短介绍一下阿里巴巴公司"
117
+ ##INT4:
118
+ """阿里巴巴集团(Alibaba Group)是一家总部位于中国杭州的全球领先的电子商务和科技公司。它成立于1999年,由马云等创始人共同创立。阿里巴巴旗下拥有包括淘宝网、天猫、阿里云、菜鸟网络等多个知名业务板块,涵盖了电子商务、零售、金融、物流、云计算等多个领域。阿里巴巴通过技术创新和商业模式创新,推动了数字经济的发展,并在全球范围内产生了深远影响。2014年,阿里巴巴在纽约证券交易所上市,成为当时全球最大的IPO之一。阿里巴巴集团的愿景是让世界各地的企业没有难做的生意。
119
+ """
120
+ ##BF16:
121
+ """阿里巴巴集团是一家中国跨国科技公司,成立于1999年,总部位于中国杭州。该公司以B2B电子商务平台起家,现已发展成为涵盖零售、金融、物流、云计算等多个领域的综合性企业集团。旗下拥有淘宝、天猫、阿里云等知名业务,是全球最大的电子商务和零售平台之一。阿里巴巴致力于通过技术创新和商业生态系统建设,推动数字经济的发展,并为消费者和企业提供优质的产品与服务。
122
+ """
123
+ ```
124
+
125
+ ### Evaluate the model
126
+
127
+ pip3 install lm-eval==0.4.5
128
+
129
+ ```bash
130
+ auto-round --model "Intel/Qwen2.5-32B-Instruct-int4-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
131
+ ```
132
+
133
+ | Metric | BF16 | INT4 |
134
+ | :----------------------------------------- | :----: | :----: |
135
+ | Avg | 0.7120 | 0.7089 |
136
+ | leaderboard_mmlu_pro 5 shots | 0.5917 | 0.5795 |
137
+ | leaderboard_ifeval inst_level_strict_acc | 0.7314 | 0.7254 |
138
+ | leaderboard_ifeval prompt_level_strict_acc | 0.6248 | 0.6285 |
139
+ | mmlu | 0.8169 | 0.8148 |
140
+ | cmmlu | 0.8673 | 0.8586 |
141
+ | ceval-valid | 0.8811 | 0.8700 |
142
+ | gsm8k 5 shots | 0.7680 | 0.8052 |
143
+ | lambada_openai | 0.7522 | 0.7417 |
144
+ | hellaswag | 0.6685 | 0.6643 |
145
+ | winogrande | 0.7372 | 0.7324 |
146
+ | piqa | 0.8085 | 0.8134 |
147
+ | truthfulqa_mc1 | 0.4871 | 0.4749 |
148
+ | openbookqa | 0.3580 | 0.3480 |
149
+ | boolq | 0.8966 | 0.8841 |
150
+ | arc_easy | 0.8237 | 0.8228 |
151
+ | arc_challenge | 0.5785 | 0.5785 |
152
+
153
+
154
+
155
+ ### Generate the model
156
+
157
+ Here is the sample command to generate the model.
158
+
159
+ For symmetric quantization, we found overflow/NAN will occur for some backends, so better fallback some layers. auto_round requires version >0.4.1
160
+
161
+ ```bash
162
+ auto-round \
163
+ --model Qwen/Qwen2.5-32B-Instruct \
164
+ --device 0 \
165
+ --group_size 128 \
166
+ --nsamples 512 \
167
+ --bits 4 \
168
+ --iter 1000 \
169
+ --disable_eval \
170
+ --fp_layers "model.layers.5.mlp.down_proj,model.layers.5.mlp.up_proj,model.layers.5.mlp.gate_proj" \
171
+ --model_dtype "fp16" \
172
+ --format 'auto_round' \
173
+ --output_dir "./tmp_autoround"
174
+ ```
175
+
176
+ Asym
177
+
178
+ ```bash
179
+ auto-round \
180
+ --model Qwen/Qwen2.5-32B-Instruct \
181
+ --device 0 \
182
+ --group_size 128 \
183
+ --nsamples 512 \
184
+ --bits 4 \
185
+ --iter 1000 \
186
+ --disable_eval \
187
+ --asym
188
+ --model_dtype "fp16" \
189
+ --format 'auto_round' \
190
+ --output_dir "./tmp_autoround"
191
+ ```
192
+
193
+ ## Ethical Considerations and Limitations
194
+
195
+ 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.
196
+
197
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
198
+
199
+ ## Caveats and Recommendations
200
+
201
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
202
+
203
+ Here are a couple of useful links to learn more about Intel's AI software:
204
+
205
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
206
+
207
+ ## Disclaimer
208
+
209
+ 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.
210
+
211
+ ## Cite
212
+
213
+ @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} }
214
+
215
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58b54bbe36fc752f79a24a271ef66a0a0830054b4dfad94bde757d851968060b
3
+ size 605
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4726408bb524e5291c29db99ab10bc0b710685336e081e4372cb5db052e3737
3
+ size 1709
generation_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:519a8db66fcfd0d18731eb75169ff8393a6f9c479fd50142fb5ee2580bb9ae64
3
+ size 243
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e1b4830a7e76276ff2a1a05fe91f66c623e81aeaf4eaffb113d66b227d63c93
3
+ size 4994322792
model-00002-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f51e330f9d77c7bea641c82bc0ae3db5bf8b969cf2c268b4a928781d94d3625
3
+ size 4978962760
model-00003-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4522ab2b8073a01ceb18ed1a37e2b13c1bc5b5b28e46434ecb7ff3e04bd1a3aa
3
+ size 4998217960
model-00004-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03d64ef392501e2a91b22c4eee66bc10bd711110734e089255b2b05b1abc8e53
3
+ size 3443908984
model-00005-of-00005.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:132750ebd6011fe663d944a95e381ee72e139804991819b96a0440a242c2bb3a
3
+ size 1557135488
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e83221b29a9a7136c2bc9ac7a4f29955417a34f6c61b4908668ce4440a2e945
3
+ size 171773
quantization_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8efae236afcfbc14af96dd5b2655f862874bfde8951b2cb0ac77892cb5cc2e7e
3
+ size 867
special_tokens_map.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76862e765266b85aa9459767e33cbaf13970f327a0e88d1c65846c2ddd3a1ecd
3
+ size 613
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
3
+ size 11421896
tokenizer_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e88129d9769a0b14b1587a7d5e829fe93ac0e1511636471fdfc0811951418e6
3
+ size 7306
vocab.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910
3
+ size 2776833