|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- NeelNanda/pile-10k |
|
|
|
|
|
--- |
|
|
|
|
|
## Model Details |
|
|
|
This model is an int4 model symmetric quantized 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), if you need AutoGPTQ format, please load the model with revision `730c79e` . |
|
|
|
|
|
|
|
### INT4 CPU/CUDA Inference |
|
|
|
```python |
|
## pip install auto-round (cpu needs version > 0.3.1) |
|
from auto_round import AutoRoundConfig ##must import for auto-round format |
|
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 = AutoModelForCausalLM.from_pretrained( |
|
quantized_model_dir, |
|
torch_dtype=torch.float16, |
|
device_map="auto", |
|
##revision="730c79e" ## AutoGTPQ format |
|
) |
|
prompt = "There is a girl who likes adventure," |
|
messages = [ |
|
{"role": "system", "content": "You are a helpful assistant."}, |
|
{"role": "user", "content": prompt} |
|
] |
|
|
|
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) |
|
text = tokenizer.apply_chat_template( |
|
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 this to align with the official usage |
|
) |
|
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) |
|
|
|
##prompt = "请介绍一下阿里巴巴公司" |
|
##阿里巴巴集团是一家中国跨国科技公司,成立于1999年,总部位于中国杭州。阿里巴巴是全球最大的零售交易平台之一,拥有淘宝、天猫、阿里云等知名业务。阿里巴巴的使命是“让天下没有难做的生意 |
|
|
|
##prompt = "9.8大还是9.11大" |
|
##9.8和9.11都是小数,要比较它们的大小,我们只需要比较它们的小数部分。在这个情况下,9.8小于9.11。因此,答案是9.11大。 |
|
|
|
##prompt = "Once upon a time," |
|
##there was a land far, far away where magic and wonder filled the air. In this land, there lived a young girl named Lily who had a heart full of dreams and a spirit that could not be tamed. One day, while wandering throughy. |
|
|
|
##prompt = "There is a girl who likes adventure," |
|
##That's great to hear! Adventure can be a wonderful way to explore new places, learn about different cultures, and challenge yourself physically and mentally. If the girl you're referring to is looking for adventure ideas, here are some suggestions: |
|
|
|
##1. Travel |
|
|
|
``` |
|
|
|
|
|
|
|
### Evaluate the model |
|
|
|
pip3 install lm-eval==0.4.4,auto-round |
|
|
|
```bash |
|
auto-round --model_name "Intel/Qwen2-57B-A14B-Instruct-int4-inc" --eval_bs 16 --eval --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid |
|
``` |
|
|
|
| Metric | BF16 | INT4 | |
|
| ---------------------- | :----: | :----: | |
|
| Avg | 0.7062 | 0.7065 | |
|
| mmlu | 0.7454 | 0.7363 | |
|
| cmmlu | 0.8729 | 0.8637 | |
|
| ceval-valid | 0.8744 | 0.8566 | |
|
| gsm8k 5 shots (strict) | 0.7718 | 0.7559 | |
|
| lambada_openai | 0.7442 | 0.7403 | |
|
| hellaswag | 0.6517 | 0.6474 | |
|
| winogrande | 0.7245 | 0.7309 | |
|
| piqa | 0.8063 | 0.8134 | |
|
| truthfulqa_mc1 | 0.4333 | 0.4455 | |
|
| openbookqa | 0.3400 | 0.3300 | |
|
| boolq | 0.8829 | 0.8841 | |
|
| arc_easy | 0.8035 | 0.8270 | |
|
| arc_challenge | 0.5299 | 0.5538 | |
|
|
|
|
|
|
|
## Generate the model |
|
|
|
~~~bash |
|
auto-round \ |
|
--model_name Qwen/Qwen2-57B-A14B-Instruct \ |
|
--device 0 \ |
|
--group_size 128 \ |
|
--nsamples 512 \ |
|
--bits 4 \ |
|
--iter 1000 \ |
|
--disable_eval \ |
|
--format 'auto_round' \ |
|
--output_dir "./tmp_autoround" |
|
~~~ |
|
|
|
|
|
|
|
## Ethical Considerations and Limitations |
|
|
|
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. |
|
|
|
Therefore, before deploying any applications of the model, developers should perform safety testing. |
|
|
|
|
|
|
|
## Caveats and Recommendations |
|
|
|
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 for Transformers [link](https://github.com/intel/intel-extension-for-transformers) |
|
|
|
|
|
|
|
## Disclaimer |
|
|
|
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. |
|
|
|
|
|
|
|
## Cite |
|
|
|
@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} } |
|
|
|
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round) |