wenhuach commited on
Commit
c309a07
1 Parent(s): b6c5c24

Signed-off-by: wenhuach <wenhuach87@gmail.com>

Files changed (2) hide show
  1. README.md +32 -114
  2. config.json +3 -0
README.md CHANGED
@@ -1,124 +1,42 @@
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 of [Qwen/Qwen2-57B-A14B-Instruct](https://huggingface.co/Qwen/Qwen2-57B-A14B-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-57B-A14B-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 = "9.89.11哪个大?"
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年,是一家以客户需求为导向的公司。我们的业务涵盖了电子商务、金融、物流、云计算等多个领域。阿里巴巴集团的使命是让世界各地的企业都能轻松地进行全球贸易。我们致力于通过技术创新和卓越
37
- ##9.8和9.11哪个大? 9.8比9.11大。在数学中,数字的大小是根据它们的数值来比较的。在这个情况下,9.8和9.11都是小数,但是9.8的数值更大
38
- ##Once upon a time, there was a young man who was very interested in the world of business. He had always been fascinated by the idea of starting his own company and making a name for himself in the business world. However, he didn't know where to start or what
39
- ##There is a girl who likes adventure, and she has a dream to become a pilot. She is a very brave girl and she wants to fly the plane in the sky. She has a lot of courage and she is ready for this challenge. She is going to take off from the airport
40
  ```
41
-
42
-
43
-
44
- ### Evaluate the model
45
-
46
- pip3 install lm-eval==0.4.2
47
-
48
- ```bash
49
- git clone https://github.com/intel/auto-round
50
- cd auto-round/examples/language-modeling
51
- python3 eval_042/evluation.py --model_name "Intel/Qwen2-57B-A14B-Instruct-int4-inc" --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid --trust_remote_code
52
- ```
53
-
54
- | Metric | BF16 |INT4-GPTQ| INT4-AutoRound|
55
- | -------------- | ------ | ------ | ------ |
56
- | Avg | 0.7040 | 0.6990 | 0.7043 |
57
- | mmlu | 0.7438 | 0.7409 | 0.7408 |
58
- | cmmlu | 0.8505 | 0.8475 | 0.8448 |
59
- | ceval-valid | 0.8767 | 0.8507 | 0.8611 |
60
- | lambada_openai | 0.7452 | 0.7524 | 0.7444 |
61
- | hellaswag | 0.6517 | 0.6471 | 0.6475 |
62
- | winogrande | 0.7245 | 0.7198 | 0.7285 |
63
- | piqa | 0.8058 | 0.8041 | 0.8058 |
64
- | truthfulqa_mc1 | 0.4345 | 0.4272 | 0.4321 |
65
- | openbookqa | 0.3400 | 0.3300 | 0.3560 |
66
- | boolq | 0.8835 | 0.8810 | 0.8844 |
67
- | arc_easy | 0.8035 | 0.8001 | 0.8051 |
68
- | arc_challenge | 0.5299 | 0.5265 | 0.5392 |
69
- | gsm8k 5 shots | 0.7627 | 0.7597 | 0.7657 |
70
-
71
-
72
-
73
-
74
-
75
- ### Reproduce the model
76
-
77
- 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.
78
-
79
- ```bash
80
- git clone https://github.com/intel/auto-round
81
- cd auto-round/examples/language-modeling
82
- pip install -r requirements.txt
83
- python3 main.py \
84
- --model_name Qwen/Qwen2-57B-A14B-Instruct \
85
- --device 0 \
86
- --group_size 128 \
87
- --bits 4 \
88
- --iter 1000 \
89
- --disable_eval \
90
- --nsamples 512 \
91
- --disable_low_gpu_mem_usage \
92
- --layer_blacklist "shared_expert_gate,gate" \
93
- --deployment_device 'auto_round' \
94
- --output_dir "./tmp_autoround"
95
- ```
96
-
97
-
98
-
99
  ## Ethical Considerations and Limitations
100
-
101
- 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.
102
-
103
- Therefore, before deploying any applications of the model, developers should perform safety testing.
104
-
105
  ## Caveats and Recommendations
106
-
107
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
108
-
109
- Here are a couple of useful links to learn more about Intel's AI software:
110
-
111
- * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
112
- * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
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
-
119
-
120
  ## Cite
121
-
122
- @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} }
123
-
124
- [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
 
1
+ --- license: apache-2.0 datasets: - NeelNanda/pile-10k --- --- license: apache-2.0 datasets: - NeelNanda/pile-10k
 
 
 
 
 
 
 
 
 
 
2
  ## Model Details
 
3
  This model is an int4 model with group_size 128 of [Qwen/Qwen2-57B-A14B-Instruct](https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), auto-round is needed to run this model
 
4
  ## How To Use
5
+ ### INT4 CPU/CUDA Inference
 
 
 
 
6
  ```python
7
+ ##git clone https://github.com/intel/auto-round.git cd auto-round && pip install -vvv --no-build-isolation -e .
8
+ from auto_round import AutoHfQuantizer ##must import import torch from transformers import AutoModelForCausalLM,AutoTokenizer quantized_model_dir = "Intel/Qwen2-57B-A14B-Instruct-int4-inc" tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) model =
9
+ AutoModelForCausalLM.from_pretrained(
10
+ quantized_model_dir, torch_dtype=torch.float16, device_map="auto", ) prompt = "There is a girl who likes adventure," messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt} ] tokenizer =
11
+ AutoTokenizer.from_pretrained(quantized_model_dir) text = tokenizer.apply_chat_template(
12
+ messages, tokenize=False, add_generation_prompt=True ) model_inputs = tokenizer([text], return_tensors="pt").to(model.device) generated_ids = model.generate( model_inputs.input_ids, max_new_tokens=50, ##change this to align with the official usage do_sample=False ##change
13
+ this to align with the official usage
14
+ ) generated_ids = [ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) ] response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] print(response)
15
+ ##prompt = "请介绍一下阿里巴巴公司" 阿里巴巴集团是一家中国跨国科技公司,成立于1999年,总部位于杭州。阿里巴巴的业务涵盖了电子商务、零售、金融、物流、云计算等多个领域,是全球最大的电子商务公司之一。\n 阿里巴巴旗下拥有淘宝网、天猫、 prompt = "9.8大还是9.11"
16
+ ##9.8和9.11都是小数,但是9.8比9.11大。在数学中,小数的大小取决于它们的数值,数值越大则越“大”。在这个情况下,9.8的 prompt = "Once upon a time," there was a kingdom far, far away. In this kingdom, there lived a beautiful princess who had hair as golden as the sun and eyes as blue
17
+ ##as the sea. The princess was kind and gentle, and everyone in the kingdom loved her dearly. prompt = "There is a girl who likes adventure," That's great to hear! Adventure can be a wonderful way to explore new places, learn new things, and challenge yourself in exciting ways.
18
+ ##If you're looking for ideas on how to embark on an adventure, here are a few suggestions: 1.
 
 
 
 
 
19
  ```
20
+ ### Evaluate the model
21
+ pip3 install lm-eval==0.4.2 ```bash git clone https://github.com/intel/auto-round cd auto-round/examples/language-modeling python3 eval_042/evluation.py --model_name "Intel/Qwen2-57B-A14B-Instruct-int4-inc" --eval_bs 16 --tasks
22
+ lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid --trust_remote_code ```
23
+ | Metric | BF16 | INT4-AutoRound | [official GPTQ](https://huggingface.co/Qwen/Qwen2-57B-A14B-Instruct-GPTQ-Int4) | ---------------------- | ------ | -------------- | ------------------------------------------------------------ | Avg | 0.7040 | 0.7043 | 0.6990 | mmlu | 0.7438 |
24
+ | 0.7408 | 0.7409 | cmmlu | 0.8505 | 0.8448 | 0.8475 | ceval-valid | 0.8767 | 0.8611 | 0.8507 | gsm8k 5 shots (strict) | 0.7627 | 0.7657 | 0.7597 | lambada_openai | 0.7452 | 0.7444 | 0.7524 | hellaswag | 0.6517 | 0.6475 | 0.6471 | winogrande | 0.7245 | 0.7285 | 0.7198 | piqa |
25
+ | 0.8058 | 0.8058 | 0.8041 | truthfulqa_mc1 | 0.4345 | 0.4321 | 0.4272 | openbookqa | 0.3400 | 0.3560 | 0.3300 | boolq | 0.8835 | 0.8844 | 0.8810 | arc_easy | 0.8035 | 0.8051 | 0.8001 | arc_challenge | 0.5299 | 0.5392 | 0.5265 |
26
+ ## Reproduce
27
+ we found the output of model.layers.3.mlp.shared_expert.down_proj could be up to ~50k if adding chat template and will cause some backend like exllamav2 oeverflow. so after quantizing the model, please manually add this to config.json ~~bash "extra_config": {
28
+ "model.layers.3.mlp.shared_expert.down_proj": { "clip": true
29
+ },
30
+ ~~
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ## Ethical Considerations and Limitations
32
+ 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
33
+ offensive outputs. Therefore, before deploying any applications of the model, developers should perform safety testing.
 
 
 
34
  ## Caveats and Recommendations
35
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. Here are a couple of useful links to learn more about Intel's AI software: * Intel Neural Compressor [link](https://github.com/intel/neural-compressor) * Intel Extension
36
+ for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
 
 
 
 
 
 
37
  ## Disclaimer
 
38
  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.
 
 
 
39
  ## Cite
40
+ @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},
41
+ year={2023} }
42
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
 
config.json CHANGED
@@ -33,6 +33,9 @@
33
  "enable_minmax_tuning": true,
34
  "enable_quanted_input": true,
35
  "extra_config": {
 
 
 
36
  "model.layers.0.mlp.gate": {
37
  "bits": 32,
38
  "data_type": "bfloat",
 
33
  "enable_minmax_tuning": true,
34
  "enable_quanted_input": true,
35
  "extra_config": {
36
+ "model.layers.3.mlp.shared_expert.down_proj": {
37
+ "clip": true
38
+ },
39
  "model.layers.0.mlp.gate": {
40
  "bits": 32,
41
  "data_type": "bfloat",