wenhuach commited on
Commit
394be49
·
2 Parent(s): 6d3d2cf d9fa691

Merge branch 'main' of https://huggingface.co/OPEA/DeepSeek-V2.5-1210-int4-sym-inc into main

Browse files
Files changed (1) hide show
  1. README.md +217 -0
README.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - NeelNanda/pile-10k
4
+ base_model:
5
+ - deepseek-ai/DeepSeek-V2.5-1210
6
+ ---
7
+ ## Model Details
8
+
9
+ This model is an int4 model with group_size 128 and and symmetric quantization of [deepseek-ai/DeepSeek-V2.5-1210](https://huggingface.co/deepseek-ai/DeepSeek-V2.5-1210) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm. Load the model with `revision="90bb8ef"` to use AutoGPTQ format. **Please note that loading the model in Transformers can be quite slow. Consider using an alternative serving framework for better performance.**
10
+
11
+ ## How To Use
12
+
13
+ ### INT4 Inference(CPU/CUDA)
14
+
15
+ ````python
16
+ from auto_round import AutoRoundConfig ##must import for auto-round format
17
+ from transformers import AutoModelForCausalLM, AutoTokenizer,GenerationConfig
18
+ import torch
19
+ model_name = quantized_model_dir
20
+ max_memory = {i: "75GB" for i in range(2)}
21
+
22
+ model = AutoModelForCausalLM.from_pretrained(
23
+ quantized_model_dir,
24
+ torch_dtype=torch.float16,
25
+ device_map="sequential",
26
+ attn_implementation="eager",
27
+ trust_remote_code=True,
28
+ max_memory=max_memory,
29
+ ##revision="90bb8ef" ##AutoGPTQ format
30
+
31
+ )
32
+ model.generation_config = GenerationConfig.from_pretrained(model_name)
33
+ model.generation_config.pad_token_id = model.generation_config.eos_token_id
34
+
35
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir,trust_remote_code=True)
36
+ prompt = "There is a girl who likes adventure,"
37
+ messages = [
38
+ {"role": "user", "content": prompt}
39
+ ]
40
+
41
+ text = tokenizer.apply_chat_template(
42
+ messages,
43
+ tokenize=False,
44
+ add_generation_prompt=True
45
+ )
46
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
47
+
48
+ generated_ids = model.generate(
49
+ model_inputs.input_ids,
50
+ max_new_tokens=512, ##change this to align with the official usage
51
+ do_sample=False ##change this to align with the official usage
52
+ )
53
+ generated_ids = [
54
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
55
+ ]
56
+
57
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
58
+ print(response)
59
+
60
+
61
+
62
+ prompt = "strawberry中有几个r?"
63
+ ##INT4
64
+ """### 第一步:理解问题
65
+
66
+ 首先,我需要明确问题的含义。问题是:“strawberry中有几个r?” 这里的“strawberry”指的是一种水果,而“r”则是英文字母。问题实际上是在问,单词“strawberry”中包含了多少个字母“r”。
67
+
68
+ ### 第二步:分析单词结构
69
+
70
+ 为了回答这个问题,我需要仔细分析单词“strawberry”的结构,找出其中所有的字母“r”。
71
+
72
+ 单词“strawberry”拼写如下:
73
+
74
+ ```
75
+ s t r a w b e r r y
76
+ ```
77
+
78
+ ### 第三步:逐个字母检查
79
+
80
+ 接下来,我将逐个字母检查,看看哪些字母是“r”。
81
+
82
+ 1. **s** - 不是“r”
83
+ 2. **t** - 不是“r”
84
+ 3. **r** - 是“r”
85
+ 4. **a** - 不是“r”
86
+ 5. **w** - 不是“r”
87
+ 6. **b** - 不是“r”
88
+ 7. **e** - 不是“r”
89
+ 8. **r** - 是“r”
90
+ 9. **r** - 是“r”
91
+ 10. **y** - 不是“r”
92
+
93
+ ### 第四步:统计“r”的数量
94
+
95
+ 通过上述检查,我发现单词“strawberry”中共有三个字母“r”。
96
+
97
+ ### 第五步:验证结果
98
+
99
+ 为了确保我的答案正确,我再次检查了单词的拼写,并重新数了一遍“r”的数量,确认确实有三个“r”。
100
+
101
+ ### 最终答案
102
+
103
+ 综上所述,单词“strawberry”中共有**三个**字母“r”。"""
104
+
105
+
106
+ prompt = "9.11和9.8哪个数字大"
107
+
108
+ ##INT4
109
+ """要比较 **9.11** 和 **9.8** 的大小,可以按照以下步骤进行:
110
+
111
+ 1. **比较整数部分**:
112
+ - 两个数的整数部分都是 **9**,因此需要比较小数部分。
113
+
114
+ 2. **比较小数部分**:
115
+ - **9.11** 的小数部分是 **0.11**
116
+ - **9.8** 的小数部分是 **0.8**
117
+
118
+ 3. **比较小数部分的大小**:
119
+ - **0.8** 大于 **0.11**
120
+
121
+ 4. **得出结论**:
122
+ - 由于小数部分 **0.8** 大于 **0.11**,所以 **9.8** 大于 **9.11**。
123
+
124
+ 最终答案是:
125
+
126
+ \[
127
+ \boxed{9.8}
128
+ \]"""
129
+
130
+
131
+ prompt = "Please give a brief introduction of DeepSeek company."
132
+ ##INT4:"""DeepSeek Artificial Intelligence Co., Ltd. (referred to as "DeepSeek" or "深度求索") , founded in 2023, is a Chinese company dedicated to making AGI a reality."""
133
+
134
+ prompt = "There is a girl who likes adventure,"
135
+ ##INT4:
136
+ """It sounds like you're setting the stage for a story or a character introduction! Here's a little continuation to spark your imagination:
137
+
138
+ ---
139
+
140
+ There is a girl who likes adventure. Her name is Lily, and her eyes sparkle with curiosity whenever she hears the word "explore." Whether it's hiking through dense forests, diving into the mysteries of the ocean, or wandering through bustling city streets in search of hidden treasures, Lily is always ready for the next thrill.
141
+
142
+ Her backpack is never without a map, a compass, and a notebook where she scribbles down her discoveries. She believes that every adventure, no matter how small, holds a story waiting to be told. Her friends often joke that she has a sixth sense for finding the most exciting paths, but Lily knows it's just her unwavering determination to seek out the unknown.
143
+
144
+ One day, while exploring an old, abandoned library, Lily stumbles upon a dusty, leather-bound book. As she flips through its pages, she discovers a series of cryptic clues leading to a legendary treasure hidden deep within the mountains. Without hesitation, she packs her bag and sets off on her greatest adventure yet, ready to uncover the secrets that have eluded others for centuries.
145
+
146
+ ---
147
+
148
+ Feel free to expand on this or let me know if you'd like to explore a different direction!"""
149
+
150
+ ````
151
+
152
+ ### Evaluate the model
153
+
154
+ pip3 install lm-eval==0.4.5
155
+
156
+ ```bash
157
+ auto-round --model "OPEA/DeepSeek-V2-Lite-int4-sym-inc" --eval --eval_bs 8 --tasks leaderboard_ifeval,leaderboard_mmlu_pro,gsm8k,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,cmmlu,ceval-valid --devices 0,1,2,3
158
+ ```
159
+
160
+ | Metric | BF16 | INT4 |
161
+ | :----------------------------------------- | :--: | :----: |
162
+ | Avg | | |
163
+ | leaderboard_mmlu_pro 5 shots | | |
164
+ | leaderboard_ifeval inst_level_strict_acc | | |
165
+ | leaderboard_ifeval prompt_level_strict_acc | | |
166
+ | mmlu | | 0.7690 |
167
+ | cmmlu | | |
168
+ | ceval-valid | | |
169
+ | gsm8k 5 shots | | |
170
+ | lambada_openai | | |
171
+ | hellaswag | | |
172
+ | winogrande | | |
173
+ | piqa | | |
174
+ | truthfulqa_mc1 | | |
175
+ | openbookqa | | |
176
+ | boolq | | |
177
+ | arc_easy | | |
178
+ | arc_challenge | | |
179
+
180
+
181
+
182
+ ### Generate the model
183
+
184
+ Here is the sample command to generate the model.
185
+
186
+ ```bash
187
+ auto-round \
188
+ --model deepseek-ai/DeepSeek-V2.5-1210 \
189
+ --device 0 \
190
+ --disable_eval \
191
+ --format 'auto_gptq,auto_round' \
192
+ --output_dir "./tmp_autoround"
193
+ ```
194
+
195
+ ## Ethical Considerations and Limitations
196
+
197
+ 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.
198
+
199
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
200
+
201
+ ## Caveats and Recommendations
202
+
203
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
204
+
205
+ Here are a couple of useful links to learn more about Intel's AI software:
206
+
207
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
208
+
209
+ ## Disclaimer
210
+
211
+ 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.
212
+
213
+ ## Cite
214
+
215
+ @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} }
216
+
217
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)