OPEA
/

Safetensors
sys-lpot-val commited on
Commit
5e07ee3
1 Parent(s): 0736448

upload auto_round format

Browse files
.gitattributes CHANGED
@@ -42,3 +42,4 @@ tokenizer.json filter=lfs diff=lfs merge=lfs -text
42
  vocab.json filter=lfs diff=lfs merge=lfs -text
43
  added_tokens.json filter=lfs diff=lfs merge=lfs -text
44
  quantization_config.json filter=lfs diff=lfs merge=lfs -text
 
 
42
  vocab.json filter=lfs diff=lfs merge=lfs -text
43
  added_tokens.json filter=lfs diff=lfs merge=lfs -text
44
  quantization_config.json filter=lfs diff=lfs merge=lfs -text
45
+ model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -3,22 +3,18 @@ license: apache-2.0
3
  datasets:
4
  - NeelNanda/pile-10k
5
  ---
6
-
7
  ## Model Details
8
 
9
- This model is an int4 model with group_size 128 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), auto-round is needed to run this model
10
 
11
  ## How To Use
12
 
13
- ### INT4 Inference
14
-
15
 
 
16
 
17
  ```python
18
- ##git clone https://github.com/intel/auto-round.git
19
- ##cd auto-round && pip install -vvv --no-build-isolation -e .
20
- from auto_round import AutoHfQuantizer ##must import
21
- import torch
22
  from transformers import AutoModelForCausalLM,AutoTokenizer
23
  quantized_model_dir = "OPEA/Qwen2.5-7B-Instruct-int4-inc"
24
  tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
@@ -27,6 +23,9 @@ model = AutoModelForCausalLM.from_pretrained(
27
  quantized_model_dir,
28
  torch_dtype='auto',
29
  device_map="auto",
 
 
 
30
  )
31
 
32
  ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
@@ -48,7 +47,7 @@ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
48
 
49
  generated_ids = model.generate(
50
  model_inputs.input_ids,
51
- max_new_tokens=50, ##change this to align with the official usage
52
  do_sample=False ##change this to align with the official usage
53
  )
54
  generated_ids = [
@@ -58,76 +57,114 @@ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_
58
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
59
  print(response)
60
 
61
- ##prompt = "There is a girl who likes adventure,"
62
- ##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?
 
 
 
 
 
 
63
 
64
- ##prompt = "Which one is bigger, 9.11 or 9.8"
65
- ##The number 9.8 is bigger than 9.11. When comparing decimal numbers, you can look at each digit from left to right. Both numbers start with 9, but the second digit after the decimal point is 1 in
 
66
 
 
 
 
 
67
 
68
- ##prompt = "Once upon a time,"
69
- ##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
70
 
71
- ##prompt = "请介绍一下阿里巴巴公司"
72
- ##阿里巴巴集团是一家总部位于中国杭州的全球领先的电子商务和科技公司,成立于1999年。阿里巴巴集团旗下的业务涵盖了电子商务、零售、金融、物流、云计算等多个领域。
73
- ##阿里巴巴集团的主要业务包括:
74
- ##1. 电子商务:
75
 
76
- ```
 
77
 
78
- ### Evaluate the model
 
79
 
80
- pip3 install lm-eval==0.4.4
81
 
82
- ```bash
83
- git clone https://github.com/intel/auto-round
84
- cd auto-round
85
- python -m auto_round --model "OPEA/Qwen2.5-7B-Instruct-int4-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  ```
87
 
88
- | Metric | BF16 | INT4 |
89
- |:-------------- | :----: | :----: |
90
- | Avg | 0.6872 | 0.6863 |
91
- | mmlu | 0.7178 | 0.7131 |
92
- | cmmlu | 0.8018 | 0.7899 |
93
- | ceval-valid | 0.7949 | 0.7741 |
94
- | lambada_openai | 0.6978 | 0.6936 |
95
- | hellaswag | 0.6203 | 0.6152 |
96
- | winogrande | 0.7080 | 0.7056 |
97
- | piqa | 0.7943 | 0.7851 |
98
- | truthfulqa_mc1 | 0.4786 | 0.4798 |
99
- | openbookqa | 0.3480 | 0.3560 |
100
- | boolq | 0.8636 | 0.8590 |
101
- | arc_easy | 0.8182 | 0.8215 |
102
- | arc_challenge | 0.5273 | 0.5307 |
103
- | gsm8k 5 shots | 0.7635 | 0.7983 |
104
 
 
105
 
 
 
 
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
 
109
- ### Reproduce the model
110
 
111
- Here is the sample command to reproduce the model. We observed a larger accuracy drop in Chinese tasks and recommend using a high-quality Chinese dataset for calibration. However, we did not achieve better accuracy with some public datasets.
 
 
112
 
113
  ```bash
114
- git clone https://github.com/intel/auto-round
115
- cd auto-round
116
- python -m auto_round \
117
- --model_name Qwen/Qwen2.5-7B-Instruct \
118
  --device 0 \
119
  --group_size 128 \
120
  --nsamples 512 \
121
  --bits 4 \
122
  --iter 1000 \
123
  --disable_eval \
124
- --model_dtype "float16" \
125
- --format 'auto_round' \
126
  --output_dir "./tmp_autoround"
127
  ```
128
 
129
-
130
-
131
  ## Ethical Considerations and Limitations
132
 
133
  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.
@@ -140,15 +177,12 @@ Users (both direct and downstream) should be made aware of the risks, biases and
140
 
141
  Here are a couple of useful links to learn more about Intel's AI software:
142
 
143
- * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
144
- * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
145
 
146
  ## Disclaimer
147
 
148
  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.
149
 
150
-
151
-
152
  ## Cite
153
 
154
  @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} }
 
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-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
9
 
10
  ## How To Use
11
 
12
+ ### INT4 Inference(CPU/HPU/CUDA)
 
13
 
14
+ CPU 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 = "OPEA/Qwen2.5-7B-Instruct-int4-inc"
20
  tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
 
23
  quantized_model_dir,
24
  torch_dtype='auto',
25
  device_map="auto",
26
+ ##revision="0b70f95" ##AutoGPTQ format
27
+ ##revision="5a6d912" ##Quantized lm-head version
28
+
29
  )
30
 
31
  ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
 
47
 
48
  generated_ids = model.generate(
49
  model_inputs.input_ids,
50
+ max_new_tokens=200, ##change this to align with the official usage
51
  do_sample=False ##change this to align with the official usage
52
  )
53
  generated_ids = [
 
57
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
58
  print(response)
59
 
60
+ prompt = "There is a girl who likes adventure,"
61
+ ##INT4:
62
+ """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?
63
+ """
64
+
65
+ ##BF16:
66
+ """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?
67
+ """
68
 
69
+ prompt = "9.119.8哪个数字大"
70
+ #INT4:
71
+ """在比较9.11和9.8时,我们从左到右逐位进行比较:
72
 
73
+ 1. 首先比较整数部分:两个数的整数部分都是9,相等。
74
+ 2. 接下来比较小数部分:
75
+ - 9.11的小数部分是0.11
76
+ - 9.8的小数部分是0.8
77
 
78
+ 将0.11和0.8进行比较,显然0.8大于0.11。
 
79
 
80
+ 因此,9.8比9.11大。
81
+ """
 
 
82
 
83
+ ##BF16:
84
+ """在比较9.11和9.8这两个数字时,我们可以直接进行比较:
85
 
86
+ - 9.11 是九点一一
87
+ - 9.8 是九点八
88
 
89
+ 显然,9.8 9.11 大。这是因为9.8中的十分位是8,而9.11中的十分位是1,8大于1。
90
 
91
+ 所以,9.8 > 9.11。"""
92
+
93
+
94
+ prompt = "Once upon a time,"
95
+ ##INT4:
96
+ """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.
97
+
98
+ 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.
99
+
100
+ As she approached the tree, she noticed a small, shimmering door carved into its bark. Curious, Elara reached out and"""
101
+
102
+ ##BF16:
103
+ """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.
104
+
105
+ 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.
106
+
107
+ 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"""
108
+
109
+
110
+ prompt = "请简短介绍一下阿里巴巴公司"
111
+ ##INT4:
112
+ """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。它由马云创立,旗下拥有包括淘宝、天猫、阿里云等在内的多个知名业务。阿里巴巴致力于构建全球化的商业生态系统,为消费者、企业和政府提供创新的在线解决方案。同时,阿里巴巴也是中国最大的零售市场之一,并在云计算、数字娱乐、物流等领域具有重要影响力。
113
+ """
114
+
115
+ ##BF16:
116
+ """阿里巴巴集团是一家总部位于中国杭州的全球领先电子商务和科技公司,成立于1999年。阿里巴巴旗下拥有淘宝、天猫、阿里云等知名业务,致力于构建全球化的商业生态系统。阿里巴巴愿景是让世界各地的企业都能够平等地进行贸易,并通过技术创新推动社会进步。
117
+ """
118
  ```
119
 
120
+ ### Evaluate the model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
+ pip3 install lm-eval==0.4.5
123
 
124
+ ```bash
125
+ auto-round --model "OPEA/Qwen2.5-7B-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
126
+ ```
127
 
128
+ | Metric | BF16 | INT4 (5.3G) | INT4 lm-head (4.5G) |
129
+ | :----------------------------------------- | :----: | :----: | ------------------- |
130
+ | Avg | 0.6649 | 0.6586 | 0.6577 |
131
+ | leaderboard_mmlu_pro 5 shots | 0.4458 | 0.4436 | 0.4384 |
132
+ | leaderboard_ifeval inst_level_strict_acc | 0.6859 | 0.6715 | 0.6595 |
133
+ | leaderboard_ifeval prompt_level_strict_acc | 0.5730 | 0.5508 | 0.5379 |
134
+ | mmlu | 0.7174 | 0.7147 | 0.7145 |
135
+ | cmmlu | 0.8028 | 0.7888 | 0.7888 |
136
+ | ceval-valid | 0.7935 | 0.7838 | 0.7741 |
137
+ | gsm8k 5 shots | 0.7665 | 0.7544 | 0.8006 |
138
+ | lambada_openai | 0.6949 | 0.6878 | 0.6763 |
139
+ | hellaswag | 0.6195 | 0.6139 | 0.6121 |
140
+ | winogrande | 0.7119 | 0.7064 | 0.7135 |
141
+ | piqa | 0.7938 | 0.7873 | 0.7845 |
142
+ | truthfulqa_mc1 | 0.4786 | 0.4774 | 0.4810 |
143
+ | openbookqa | 0.3480 | 0.3580 | 0.3540 |
144
+ | boolq | 0.8636 | 0.8602 | 0.8609 |
145
+ | arc_easy | 0.8131 | 0.8068 | 0.8081 |
146
+ | arc_challenge | 0.5282 | 0.5316 | 0.5188 |
147
 
148
 
 
149
 
150
+ ### Generate the model
151
+
152
+ Here is the sample command to generate the model.
153
 
154
  ```bash
155
+ auto-round \
156
+ --model Qwen/Qwen2.5-7B-Instruct \
 
 
157
  --device 0 \
158
  --group_size 128 \
159
  --nsamples 512 \
160
  --bits 4 \
161
  --iter 1000 \
162
  --disable_eval \
163
+ --model_dtype "fp16" \
164
+ --format 'auto_gptq,auto_round' \
165
  --output_dir "./tmp_autoround"
166
  ```
167
 
 
 
168
  ## Ethical Considerations and Limitations
169
 
170
  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.
 
177
 
178
  Here are a couple of useful links to learn more about Intel's AI software:
179
 
180
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
 
181
 
182
  ## Disclaimer
183
 
184
  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.
185
 
 
 
186
  ## Cite
187
 
188
  @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} }
config.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a5f67fb8cbba7e9da14cd29bbb8c8e583bec9d06bbd057596b0e9b57c7f9e7c8
3
- size 1532
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd52d04bbcc8107b52f6ef647c99991addd69e6a805cca4ea306d157f759b420
3
+ size 1382
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f22e89adbbec038db494ac9f6462bf2b855412eb2ddd53b3f172e9018eaea0df
3
+ size 4485386456
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:053d06aa9a6579967b3653c789151a7edf361899e7804c10a756b53286f602e8
3
+ size 1089994880
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d227f90df7f45f36c6444eec8a0753bfc91ab176f5dfc3bd24be39935ce75f87
3
+ size 75421
quantization_config.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:471028953fe4ef095d6c33ba5a374d5d43b3fae4544728626e8c3204677148c6
3
- size 709
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f92209e21368ef298866e57e5f3838e7590119ba042ef4c15bf642f7f60e4f40
3
+ size 575
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
3
- size 11421896
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:913950e4971737031da511cdd1b410daae4566f62eb845b3975bca5a102323d8
3
+ size 11421995