cicdatopea commited on
Commit
ba0dd81
·
verified ·
1 Parent(s): 99602f3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +132 -0
README.md ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 [falcon-three-7b]() generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision `` to use AutoGPTQ format, with revision `` to use AutoAWQ 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 = "OPEA/falcon-three-7b-int4-sym-inc"
17
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
18
+ model = AutoModelForCausalLM.from_pretrained(
19
+ quantized_model_dir,
20
+ device_map="auto"
21
+ ## revision="" ##AutoGPTQ format
22
+ ## revision="" ##AutoAWQ format
23
+ )
24
+ text = "How many r in strawberry? The answer is "
25
+ inputs = tokenizer(text, return_tensors="pt", return_token_type_ids=False).to(model.device)
26
+ print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
27
+
28
+ ##INT4:
29
+ ## How many r in strawberry? The answer is 1.000000000000000000000000000000000000000000000000
30
+
31
+ ##BF16:
32
+ ## How many r in strawberry? The answer is 1.
33
+
34
+ ### Additional Questions and Answers
35
+
36
+ #### 11. **What is the value of 10000000000000000000000000
37
+
38
+
39
+ text = "Which number is bigger, 9.8 or 9.11? The answer is"
40
+ ##INT4:
41
+ ## Which number is bigger, 9.8 or 9.11? The answer is 9.8.
42
+ ## **Answer:**
43
+ ## To compare 9.8 and 9.11, we need to look at the digits in each place value.
44
+
45
+ ## 1. **Whole number part:**
46
+ ## - Both
47
+
48
+ ##BF16:
49
+ ## Which number is bigger, 9.8 or 9.11? The answer is 9.8.
50
+
51
+ #### 10. **What is the smallest number?**
52
+ ## **Answer:**
53
+ ## The smallest number in the context of whole numbers is 0. However, if we consider the set of natural numbers,
54
+
55
+ text = "Once upon a time,"
56
+ ##INT4:
57
+ ## Once upon a time, in a land far away, there was a magical place called the "Library of Knowledge." This library had shelves and shelves filled with books about everything you could ever imagine - stories, science, history, and more! But one day, something
58
+
59
+ ##BF16:
60
+ ## Once upon a time, in a land far away, there was a magical place called the "Library of Alexandria." This library was home to thousands upon thousands of scrolls filled with stories, poems, and knowledge from all over the world. It was a place where people could
61
+
62
+ text = "There is a girl who likes adventure,"
63
+ ##INT4:
64
+ ## There is a girl who likes adventure, and she is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She
65
+
66
+ ##BF16:
67
+ ## There is a girl who likes adventure, and she is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She is going to go on a trip to the mountains. She
68
+ ```
69
+
70
+ ### Evaluate the model
71
+
72
+ pip3 install lm-eval==0.4.5
73
+
74
+ ```bash
75
+ auto-round --model "OPEA/falcon-three-7b-int4-sym-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu
76
+ ```
77
+
78
+ | Metric | BF16 | INT4 |
79
+ | :-------------------------- | :----: | :----: |
80
+ | Avg | 62.43 | 61.69 |
81
+ | mmlu | 67.43 | 66.41 |
82
+ | lambada_opeai | 68.52 | 68.12 |
83
+ | hellaswage | 56.41 | 55.88 |
84
+ | winogrande | 70.96 | 70.09 |
85
+ | piqa | 77.86 | 77.48 |
86
+ | truthfulqa_mc1 | 37.33 | 37.58 |
87
+ | openbookqa | 30.80 | 30.60 |
88
+ | boolq | 81.56 | 80.58 |
89
+ | arc_easy | 80.81 | 79.80 |
90
+ | arc_challenge | 51.11 | 49.57 |
91
+
92
+ ### Generate the model
93
+
94
+ Here is the sample command to generate the model.
95
+ ```bash
96
+ auto-round \
97
+ --model falcon-three-7b \
98
+ --device 0 \
99
+ --group_size 128 \
100
+ --bits 4 \
101
+ --nsamples 512 \
102
+ --seqlen 2048 \
103
+ --iters 1000 \
104
+ --model_dtype "float16" \
105
+ --dataset NeelNanda/pile-10k \
106
+ --format 'auto_awq,auto_gptq,auto_round' \
107
+ --output_dir "./tmp_autoround"
108
+ ```
109
+
110
+ ## Ethical Considerations and Limitations
111
+
112
+ 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.
113
+
114
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
115
+
116
+ ## Caveats and Recommendations
117
+
118
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
119
+
120
+ Here are a couple of useful links to learn more about Intel's AI software:
121
+
122
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
123
+
124
+ ## Disclaimer
125
+
126
+ 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.
127
+
128
+ ## Cite
129
+
130
+ @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} }
131
+
132
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)