--- license: apache-2.0 datasets: - NeelNanda/pile-10k --- ## Model Details This model is an int4 model with group_size 128 with quantized lm-head of [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), auto-round is needed to run this model ## How To Use ### INT4 Inference ```python ##git clone https://github.com/intel/auto-round.git ##cd auto-round && pip install -vvv --no-build-isolation -e . from auto_round import AutoHfQuantizer ##must import import torch from transformers import AutoModelForCausalLM,AutoTokenizer quantized_model_dir = "OPEA/Qwen2.5-1.5B-Instruct-int4-inc" tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) model = AutoModelForCausalLM.from_pretrained( quantized_model_dir, torch_dtype='auto', device_map="auto", ) ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU prompt = "There is a girl who likes adventure," messages = [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt} ] 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 = "There is a girl who likes adventure," ##That's great! What kind of adventure does she like? ##prompt = "Which one is bigger, 9.11 or 9.8" ##To determine which number is larger between 9.11 and 9.8, you can compare them directly: ##1. Start with the numbers: 9.11 and 9.8. ##2. Compare their digits from left to ##prompt = "Once upon a time," ##once upon a time, there was a young girl named Lily who lived in a small village nestled among the rolling hills of England. She had always been fascinated by nature and the beauty of the world around her.One day, while exploring the woods near\ ##prompt = "请介绍一下阿里巴巴公司" ##阿里巴巴集团是一家全球领先的电子商务和科技企业,成立于1999年。阿里巴巴集团总部位于中国杭州,并在全球范围内拥有超过20个运营中心。 ##阿里巴巴集团的业务范围包括: ##1. 电子商务:阿里巴巴集团是全球 ``` ### Evaluate the model pip3 install lm-eval==0.4.2 ```bash git clone https://github.com/intel/auto-round cd auto-round python -m auto_round --model "OPEA/Qwen2.5-1.5B-Instruct-int4-inc" --eval --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid ``` | Metric | BF16 | INT4(group_size 128) | INT4(group_size 32) | |:-------------- | :----: | :----: |:------:| | Avg | 0.5646 | 0.5668 | 0.5699 | | mmlu | 0.6010 | 0.5876 | 0.5924 | | cmmlu | 0.6497 | 0.6146 | 0.6259 | | ceval-valid | 0.6597 | 0.6382 | 0.6404 | | lambada_openai | 0.6095 | 0.5886 | 0.6082 | | hellaswag | 0.5082 | 0.4985 | 0.5012 | | winogrande | 0.6298 | 0.6204 | 0.6409 | | piqa | 0.7633 | 0.7519 | 0.7650 | | truthfulqa_mc1 | 0.3109 | 0.3158 | 0.3060 | | openbookqa | 0.3160 | 0.2940 | 0.3020 | | boolq | 0.7789 | 0.7703 | 0.7681 | | arc_easy | 0.7677 | 0.7660 | 0.7681 | | arc_challenge | 0.4343 | 0.4454 | 0.4360 | | gsm8k 5 shots | 0.3101 | 0.4776 | 0.4519 | ### Reproduce the model 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. ```bash git clone https://github.com/intel/auto-round cd auto-round python -m auto_round \ --model_name Qwen/Qwen2.5-1.5B-Instruct \ --device 0 \ --group_size 128 \ --nsamples 512 \ --bits 4 \ --iter 1000 \ --disable_eval \ --model_dtype "float16" \ --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)