n1ck-guo commited on
Commit
beb68cb
1 Parent(s): 807d0b7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +122 -3
README.md CHANGED
@@ -1,3 +1,122 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ ---
6
+
7
+ ---
8
+ license: apache-2.0
9
+ datasets:
10
+ - NeelNanda/pile-10k
11
+
12
+ ## Model Details
13
+
14
+ This model is an int4 model with group_size 128 with quantized lm-head of [Qwen/Qwen2-7B](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), auto-round is needed to run this model
15
+
16
+ ## How To Use
17
+
18
+ ### INT4 Inference
19
+
20
+
21
+
22
+ ```python
23
+ ##git clone https://github.com/intel/auto-round.git
24
+ ##cd auto-round && pip install -vvv --no-build-isolation -e .
25
+ from auto_round.auto_quantizer import AutoHfQuantizer
26
+ from transformers import AutoModelForCausalLM,AutoTokenizer
27
+ quantized_model_dir = "Intel/Qwen2.5-0.5B-Instruct-int4-inc"
28
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
29
+ model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, device_map="auto")
30
+ text = "下面我来介绍一下阿里巴巴公司,"
31
+ text = "88+99等于多少?"
32
+ text = "Once upon a time,"
33
+ text = "There is a girl who likes adventure,"
34
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
35
+ print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
36
+ ##下面我来介绍一下阿里巴巴公司,阿里巴巴公司是1999年9月8日由马云在杭州创立的,阿里巴巴集团主要经营业务包括:淘宝网、天猫、聚划算、全球速卖通、阿里巴巴国际交易市场、1688、阿里
37
+ ##"88+99等于多少? 88+99=187 \n 计算: (1) 1 2 + 1 3 + 1 4 + 1 5 + 1 6 + 1 7 + 1 8"
38
+ ##Once upon a time, there was a little girl named Emily who loved to read books. She would spend hours lost in the pages of her favorite stories, imagining herself in the worlds she read about. One day, Emily stumbled upon a book called "The Enchanted Forest
39
+ ##There is a girl who likes adventure, and she is always looking for new experiences. She is a bit of a thrill-seeker, and she loves to push herself to the limit. She is also a bit of a free spirit, and she loves to explore new places and try new things
40
+ ```
41
+
42
+ ### Evaluate the model
43
+
44
+ pip3 install lm-eval==0.4.2
45
+
46
+ ```bash
47
+ git clone https://github.com/intel/auto-round
48
+ cd auto-round/examples/language-modeling
49
+ python3 eval_042/evluation.py --model_name "Intel/Qwen2.5-0.5B-Instruct-int4-inc" --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,truthfulqa_mc2,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid
50
+ ```
51
+
52
+ | Metric | BF16 | INT4 |
53
+ | -------------- | ------ | ------ |
54
+ | Avg | 0.4604 | 0.4469 |
55
+ | mmlu | 0.4587 | 0.4440 |
56
+ | cmmlu | 0.5036 | 0.4580 |
57
+ | ceval-valid | 0.5312 | 0.4844 |
58
+ | lambada_openai | 0.5015 | 0.4524 |
59
+ | hellaswag | 0.4064 | 0.3931 |
60
+ | winogrande | 0.5604 | 0.5683 |
61
+ | piqa | 0.7035 | 0.7008 |
62
+ | truthfulqa_mc1 | 0.2693 | 0.2583 |
63
+ | truthfulqa_mc2 | 0.4183 | 0.4123 |
64
+ | openbookqa | 0.3520 | 0.3420 |
65
+ | boolq | 0.2400 | 0.2360 |
66
+ | arc_easy | 0.6557 | 0.6536 |
67
+ | arc_challenge | 0.3063 | 0.2935 |
68
+ | gsm8k 5 shots | 0.2115 | 0.2191 |
69
+
70
+
71
+
72
+
73
+
74
+ ### Reproduce the model
75
+
76
+ Here is the sample command to reproduce the model. We observed a larger accuracy drop in Chinese tasks and recommend using a high-quality Chinese dataset for calibration. However, we did not achieve better accuracy with some public datasets.
77
+
78
+ ```bash
79
+ git clone https://github.com/intel/auto-round
80
+ cd auto-round/examples/language-modeling
81
+ pip install -r requirements.txt
82
+ python3 main.py \
83
+ --model_name Qwen/Qwen2.5-0.5B-Instruct \
84
+ --device 0 \
85
+ --group_size 128 \
86
+ --nsamples 512 \
87
+ --bits 4 \
88
+ --iter 1000 \
89
+ --disable_eval \
90
+ --model_dtype "float16" \
91
+ --deployment_device 'auto_round' \
92
+ --output_dir "./tmp_autoround"
93
+ ```
94
+
95
+
96
+
97
+ ## Ethical Considerations and Limitations
98
+
99
+ 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.
100
+
101
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
102
+
103
+ ## Caveats and Recommendations
104
+
105
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
106
+
107
+ Here are a couple of useful links to learn more about Intel's AI software:
108
+
109
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
110
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
111
+
112
+ ## Disclaimer
113
+
114
+ 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.
115
+
116
+
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)