wenhuach commited on
Commit
f769926
·
2 Parent(s): 8fe0735 cba3df0

Merge branch 'main' of https://huggingface.co/OPEA/DeepSeek-V3-int4-sym-gptq-inc-preview into main

Browse files
Files changed (1) hide show
  1. README.md +185 -0
README.md ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - NeelNanda/pile-10k
4
+ base_model:
5
+ - deepseek-ai/DeepSeek-V3
6
+ ---
7
+ ## Model Details
8
+
9
+ This model is an int4 model with group_size 128 and symmetric quantization of [deepseek-ai/DeepSeek-V3](https://huggingface.co/deepseek-ai/DeepSeek-V3) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm.
10
+
11
+ **Please note that loading the model in Transformers can be quite slow. Consider using an alternative serving framework for better performance.**
12
+
13
+ Due to limited GPU resources, we have only tested a few prompts on a CPU backend with QBits. If this model does not meet your performance expectations, you may explore another quantized model in AWQ format, generated via AutoRound with different hyperparameters. This alternative model will be uploaded soon.
14
+
15
+ Please follow the license of the original model.
16
+
17
+ ## How To Use
18
+
19
+ ### INT4 Inference
20
+
21
+ ````python
22
+ from transformers import AutoModelForCausalLM, AutoTokenizer
23
+ import torch
24
+ quantized_model_dir = "OPEA/DeepSeek-V3-int4-sym-gptq-inc-preview"
25
+
26
+ model = AutoModelForCausalLM.from_pretrained(
27
+ quantized_model_dir,
28
+ torch_dtype=torch.float16,
29
+ trust_remote_code=True,
30
+ device_map="auto"
31
+
32
+ )
33
+
34
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir,trust_remote_code=True)
35
+ prompt = "There is a girl who likes adventure,"
36
+ messages = [
37
+ {"role": "system", "content": "You are a helpful assistant."},
38
+ {"role": "user", "content": prompt}
39
+ ]
40
+ text = tokenizer.apply_chat_template(
41
+ messages,
42
+ tokenize=False,
43
+ add_generation_prompt=True
44
+ )
45
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
46
+
47
+ generated_ids = model.generate(
48
+ model_inputs.input_ids,
49
+ max_new_tokens=200, ##change this to align with the official usage
50
+ do_sample=False ##change this to align with the official usage
51
+ )
52
+ generated_ids = [
53
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
54
+ ]
55
+
56
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
57
+ print(response)
58
+
59
+
60
+ ## The following result is inferred on CPU with qbits backend
61
+ prompt = "9.11和9.8哪个数字大"
62
+
63
+ ##INT4
64
+ """要比较 **9.11** 和 **9.8** 的大小,可以按照以下步骤进行:
65
+
66
+ 1. **比较整数部分**:
67
+ - 两个数的整数部分都是 **9**,所以整数部分相同。
68
+
69
+ 2. **比较小数部分**:
70
+ - **9.11** 的小数部分是 **0.11**
71
+ - **9.8** 的小数部分是 **0.8**(即 **0.80**)
72
+
73
+ 3. **分析小数部分**:
74
+ - **0.80** 大于 **0.11**
75
+
76
+ 因此,**9.8** 大于 **9.11**。
77
+
78
+ 最终答案:\boxed{9.8}
79
+
80
+ """
81
+
82
+ prompt = "strawberry中有几个r?"
83
+ ##INT4
84
+ """
85
+ ### 第一步:理解问题
86
+
87
+ 首先,我需要明确问题的含义。问题是:“strawberry中有几个r?”。这里的“strawberry”是一个英文单词,意思是“草莓”。问题问的是这个单 词中有多少个字母“r”。
88
+
89
+ ### 第二步:分解单词
90
+
91
+ 为了找出“strawberry”中有多少个“r”,我需要将这个单词分解成单个字母。让我们逐个字母来看:
92
+
93
+ - s
94
+ - t
95
+ - r
96
+ - a
97
+ - w
98
+ - b
99
+ - e
100
+ - r
101
+ - r
102
+ - y
103
+
104
+ ### 第三步:识别字母“r”
105
+
106
+ 现在,我需要找出这些字母中哪些是“r”。让我们逐一检查:
107
+
108
+ 1. s - 不是r
109
+ 2. t - 不是r
110
+ 3. r - 是r
111
+ 4. a - 不是r
112
+ 5. w - 不是r
113
+ 6. b - 不是r
114
+ 7. e - 不是r
115
+ 8. r - 是r
116
+ """
117
+
118
+ prompt = "How many r in strawberry."
119
+ ##INT4
120
+ """The word "strawberry" contains **3 "r"s.
121
+ """
122
+
123
+ prompt = "There is a girl who likes adventure,"
124
+ ##INT4:
125
+ """That's wonderful! A girl who loves adventure is likely curious, brave, and eager to explore the world around her. Here are some ideas to fuel her adventurous spirit:
126
+
127
+ ### **Outdoor Adventures**
128
+
129
+ - **Hiking:** Explore local trails, national parks, or mountains.
130
+ - **Camping:** Spend a night under the stars and connect with nature.
131
+ - **Rock Climbing:** Challenge herself with bouldering or climbing walls.
132
+ - **Kayaking/Canoeing:** Paddle through rivers, lakes, or even the ocean.
133
+ - **Zip-lining:** Soar through the treetops for an adrenaline rush.
134
+
135
+ ### **Travel Adventures**
136
+
137
+ - **Road Trips:** Plan a journey to new cities or scenic destinations.
138
+ - **Backpacking:** Travel light and explore different cultures and landscapes.
139
+ - **Volunteer Abroad:** Combine adventure with helping others in a new country.
140
+
141
+ ### **Creative Adventures**
142
+
143
+ - **Photography:** Capture the beauty
144
+ """
145
+
146
+ prompt = "Please give a brief introduction of DeepSeek company."
147
+ ##INT4:
148
+ """DeepSeek Artificial Intelligence Co., Ltd. (referred to as "DeepSeek" or "深度求索") , founded in 2023, is a Chinese company dedicated to making AGI a reality"""
149
+
150
+
151
+ ````
152
+
153
+ ### Evaluate the model
154
+
155
+ we have no enough resource to evaluate the model
156
+
157
+ ### Generate the model
158
+
159
+ need 200G GPU memory, details will be updated later
160
+
161
+
162
+
163
+ ## Ethical Considerations and Limitations
164
+
165
+ 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.
166
+
167
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
168
+
169
+ ## Caveats and Recommendations
170
+
171
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
172
+
173
+ Here are a couple of useful links to learn more about Intel's AI software:
174
+
175
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
176
+
177
+ ## Disclaimer
178
+
179
+ 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.
180
+
181
+ ## Cite
182
+
183
+ @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} }
184
+
185
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)