cicdatopea commited on
Commit
7cb2129
1 Parent(s): 1bfb497

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +122 -0
README.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - NeelNanda/pile-10k
4
+ ---
5
+
6
+ ## Model Details
7
+
8
+ This model is an int4 model with group_size 128 and symmetric quantization of [falcon3-3B]() generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision `1839199` to use AutoGPTQ format
9
+
10
+ ## How To Use
11
+ ### INT4 Inference(CPU/HPU/CUDA)
12
+ ```python
13
+ from auto_round import AutoRoundConfig ##must import for auto_round format
14
+ from transformers import AutoModelForCausalLM, AutoTokenizer
15
+
16
+ quantized_model_dir = "/data5/quant/iter2000/falcon3-3B-w4g128-auto-round/"
17
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
18
+ model = AutoModelForCausalLM.from_pretrained(
19
+ quantized_model_dir,
20
+ device_map="auto"
21
+ ## revision="07a117c" ##AutoGPTQ format
22
+ )
23
+ text = "下面我来介绍一下阿里巴巴公司,"
24
+ inputs = tokenizer(text, return_tensors="pt", return_token_type_ids=False).to(model.device)
25
+ print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))
26
+ ##INT4:
27
+ ## 下面我来介绍一下阿里巴巴公司,阿里巴巴公司是阿里网的首席执行官,他在阿里网的创始人,阿里巴巴公司的首席执行官,他在阿里
28
+
29
+ ##BF16:
30
+ ## 下面我来介绍一下阿里巴巴公司,以及阿里巴巴的产品和服务。
31
+ ## 阿里巴巴公司是阿里网公司的首席执行官,是阿里网公司的首席执行官,是阿
32
+
33
+ text = "9.8和9.11哪个数字大?答案是"
34
+ ##INT4:
35
+ ## 9.8和9.11哪个数字大?答案是9.8。
36
+ ## Q: 哪个数字大:9.8和9.11?
37
+ ## A: 9.8
38
+ ## Q: 9.8和9.11哪个数字
39
+
40
+ ##BF16:
41
+ ## 9.8和9.11哪个数字大?答案是9.8。
42
+ ## Q: 哪个数字大:9.8和9.11?
43
+ ## A: 9.8
44
+ ## Q: 9.8和9.11哪个数字
45
+
46
+ text = "Once upon a time,"
47
+ ##INT4:
48
+ ## Once upon a time, there was a little girl named Lily who loved to play in the garden. She would spend hours picking flowers, digging in the dirt, and watching the bees buzz around the colorful blooms. One day, while she was picking a bouquet of daisies, she
49
+
50
+ ##BF16:
51
+ ## Once upon a time, there was a little girl named Lily who loved to play with her toys. One day, she found a special box in her attic. The box was old and dusty, but when she opened it, she found a beautiful, shiny object inside. It
52
+
53
+ text = "There is a girl who likes adventure,"
54
+ ##INT4:
55
+ ## There is a girl who likes adventure, she likes to go on adventures with her friends. She likes to go on adventures with her friends because she likes to go on adventures with her friends. She likes to go on adventures with her friends because she likes to go on adventures with her friends.
56
+
57
+ ##BF16:
58
+ ## There is a girl who likes adventure, she likes to go on adventures with her friends. She likes to go on adventures with her friends because she likes to go on adventures with her friends. She likes to go on adventures with her friends because she likes to go on adventures with her friends.
59
+ ```
60
+
61
+ ### Evaluate the model
62
+
63
+ pip3 install lm-eval==0.4.5
64
+
65
+ ```bash
66
+ auto-round --model "OPEA/falcon3-3B-int4-sym-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu
67
+ ```
68
+
69
+ | Metric | BF16 | INT4 |
70
+ | :-------------------------- | :----: | :----: |
71
+ | Avg | 0.5816 | 0.5751 |
72
+ | mmlu | 0.5192 | 0.5127 |
73
+ | lambada_opeai | 0.6109 | 0.6103 |
74
+ | hellaswage | 0.5357 | 0.5285 |
75
+ | winogrande | 0.6614 | 0.6638 |
76
+ | piqa | 0.7753 | 0.7715 |
77
+ | truthfulqa_mc1 | 0.2803 | 0.2742 |
78
+ | openbookqa | 0.3560 | 0.3360 |
79
+ | boolq | 0.8040 | 0.7884 |
80
+ | arc_easy | 0.7896 | 0.7845 |
81
+ | arc_challenge | 0.4838 | 0.4812 |
82
+
83
+ ### Generate the model
84
+
85
+ Here is the sample command to generate the model.
86
+ ```bash
87
+ auto-round \
88
+ --model falcon3-3B \
89
+ --device 0 \
90
+ --group_size 128 \
91
+ --nsamples 512 \
92
+ --bits 4 \
93
+ --iter 2000 \
94
+ --disable_eval \
95
+ --model_type float16 \
96
+ --format 'auto_gptq,auto_round' \
97
+ --output_dir "./tmp_autoround"
98
+ ```
99
+
100
+ ## Ethical Considerations and Limitations
101
+
102
+ 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.
103
+
104
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
105
+
106
+ ## Caveats and Recommendations
107
+
108
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
109
+
110
+ Here are a couple of useful links to learn more about Intel's AI software:
111
+
112
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
113
+
114
+ ## Disclaimer
115
+
116
+ 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.
117
+
118
+ ## Cite
119
+
120
+ @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} }
121
+
122
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)