cicdatopea commited on
Commit
f1a680d
·
verified ·
1 Parent(s): 7534ff0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +162 -0
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - NeelNanda/pile-10k
4
+ base_model:
5
+ - deepseek-ai/DeepSeek-R1-Distill-Llama-70B
6
+
7
+
8
+
9
+ ---
10
+
11
+ ## Model Details
12
+
13
+ This model is an int4 model with group_size 128 and symmetric quantization of [deepseek-ai/DeepSeek-R1-Distill-Llama-70B](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Llama-70B) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm.
14
+
15
+ Please follow the license of the original model.
16
+
17
+ ## How To Use
18
+
19
+ **INT4 Inference on CUDA**
20
+
21
+ ~~~python
22
+ import transformers
23
+ from transformers import AutoModelForCausalLM, AutoTokenizer
24
+ import torch
25
+
26
+ quantized_model_dir = "OPEA/DeepSeek-R1-Distill-Llama-70B-int4-gptq-sym-inc"
27
+
28
+ device_map="auto"
29
+ model = AutoModelForCausalLM.from_pretrained(
30
+ quantized_model_dir,
31
+ torch_dtype=torch.float16,
32
+ trust_remote_code=True,
33
+ device_map=device_map,
34
+ )
35
+
36
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, trust_remote_code=True)
37
+ prompts = [
38
+ "9.11和9.8哪个数字大",
39
+ "如果你是人,你最想做什么",
40
+ "How many e in word deepseek",
41
+ "There are ten birds in a tree. A hunter shoots one. How many are left in the tree?",
42
+ ]
43
+
44
+ texts = []
45
+ for prompt in prompts:
46
+ messages = [
47
+ {"role": "user", "content": prompt}
48
+ ]
49
+ text = tokenizer.apply_chat_template(
50
+ messages,
51
+ tokenize=False,
52
+ add_generation_prompt=True
53
+ )
54
+ texts.append(text)
55
+
56
+ inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
57
+
58
+ outputs = model.generate(
59
+ input_ids=inputs["input_ids"].to(model.device),
60
+ attention_mask=inputs["attention_mask"].to(model.device),
61
+ max_length=512, ##change this to align with the official usage
62
+ num_return_sequences=1,
63
+ do_sample=False ##change this to align with the official usage
64
+ )
65
+ generated_ids = [
66
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(inputs["input_ids"], outputs)
67
+ ]
68
+
69
+ decoded_outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
70
+
71
+ for i, prompt in enumerate(prompts):
72
+ input_id = inputs
73
+ print(f"Prompt: {prompt}")
74
+ print(f"Generated: {decoded_outputs[i]}")
75
+ print("-" * 50)
76
+
77
+
78
+ """
79
+ Prompt: 9.11和9.8哪个数字大
80
+
81
+ --------------------------------------------------
82
+ Prompt: 如果你是人类,你最想做什么
83
+
84
+ --------------------------------------------------
85
+ Prompt: How many e in word deepseek
86
+
87
+ --------------------------------------------------
88
+ Prompt: There are ten birds in a tree. A hunter shoots one. How many are left in the tree?
89
+
90
+ ~~~
91
+
92
+ ### Evaluate the model
93
+
94
+ will update later
95
+ <!-- pip3 install lm-eval==0.4.7
96
+ we found lm-eval is very unstable for this model. Please set `add_bos_token=True `to align with the origin model. **Please use autogptq format**
97
+
98
+ ```bash
99
+ lm-eval --model hf --model_args pretrained=OPEA/DeepSeek-R1-Distill-Llama-70B-int4-gptq-sym-inc,add_bos_token=True --tasks leaderboard_mmlu_pro,leaderboard_ifeval,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k --batch_size 16
100
+ ```
101
+ | Metric | BF16 | INT4 |
102
+ | :------------------------ | :---------------------- | :--------------- |
103
+ | avg | 0.6647 | 0.6639|
104
+ | leaderboard_mmlu_pro | - | - |
105
+ | mmlu | 0.7964 | 0.7928 |
106
+ | lambada_openai | 0.6649 | 0.6718 |
107
+ | hellaswag | 0.6292 | 0.6223 |
108
+ | winogrande | 0.7482 | 0.7482 |
109
+ | piqa | 0.8058 | 0.7982 |
110
+ | truthfulqa_mc1 | 0.3831 | 0.3905 |
111
+ | openbookqa | 0.3520 | 0.3520 |
112
+ | boolq | 0.8963 | 0.8972 |
113
+ | arc_easy | 0.8207 | 0.8194 |
114
+ | arc_challenge | 0.5503 | 0.5469 |
115
+ | leaderboard_ifeval | - | - |
116
+ | gsm8k | - | - | -->
117
+
118
+
119
+
120
+ ### Generate the model
121
+ Here is the sample command to generate the model.
122
+
123
+
124
+ ```bash
125
+ auto-round \
126
+ --model deepseek-ai/DeepSeek-R1-Distill-Llama-70B \
127
+ --device 0 \
128
+ --bits 4 \
129
+ --iter 200 \
130
+ --disable_eval \
131
+ --format 'auto_gptq,auto_round,auto_awq' \
132
+ --output_dir "./tmp_autoround"
133
+
134
+ ```
135
+
136
+
137
+
138
+
139
+
140
+ ## Ethical Considerations and Limitations
141
+
142
+ 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.
143
+
144
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
145
+
146
+ ## Caveats and Recommendations
147
+
148
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
149
+
150
+ Here are a couple of useful links to learn more about Intel's AI software:
151
+
152
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
153
+
154
+ ## Disclaimer
155
+
156
+ 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.
157
+
158
+ ## Cite
159
+
160
+ @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} }
161
+
162
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)