--- license: apache-2.0 datasets: - NeelNanda/pile-10k --- ## Model Details This model is an int4 model with group_size 128 of [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) generated by [intel/auto-round](https://github.com/intel/auto-round). ## How To Use ### Use the model ### INT4 Inference with AutoGPTQ Install [AutoGPTQ](https://github.com/AutoGPTQ/AutoGPTQ) from source first ```python from transformers import AutoModelForCausalLM, AutoTokenizer quantized_model_dir = "Intel/phi-2-int4-inc" tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir) model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, device_map="auto", trust_remote_code=True) text = "There is a girl who likes adventure," inputs = tokenizer(text, return_tensors="pt", return_attention_mask=False).to(model.device) outputs = model.generate(**inputs, max_new_tokens=50) text = tokenizer.batch_decode(outputs)[0] print(text) ``` ### Evaluate the model Install [lm-eval-harness 0.4.2](https://github.com/EleutherAI/lm-evaluation-harness.git) from source. Since we encountered an issue evaluating this model with lm-eval, we opted to evaluate the qdq model instead. In our assessment, we found that its accuracy closely matches that of the real quantized model in most cases except for some small models like opt-125m. | Metric | FP16 | INT4 qdq | | -------------- | ------ | ------ | | Avg. | 0.6138 | 0.6115 | | mmlu | 0.5325 | 0.5417 | | lambada_openai | 0.6276 | 0.6225 | | hellaswag | 0.5584 | 0.5498 | | winogrande | 0.7561 | 0.7545 | | piqa | 0.7867 | 0.7824 | | truthfulqa_mc1 | 0.3146 | 0.3060 | | openbookqa | 0.4020 | 0.4100 | | boolq | 0.8330 | 0.8327 | | arc_easy | 0.7992 | 0.7955 | | arc_challenge | 0.5282 | 0.5196 | ### Reproduce the model Here is the sample command to reproduce the model ```bash git clone https://github.com/intel/auto-round cd auto-round/examples/language-modeling pip install -r requirements.txt python3 main.py \ --model_name microsoft/phi-2 \ --device 0 \ --group_size 128 \ --bits 4 \ --iters 1000 \ --enable_minmax_tuning \ --disable_quanted_input \ --deployment_device 'gpu' \ --scale_dtype 'fp32' \ --eval_bs 32 \ --output_dir "./tmp_autoround" \ --amp ``` ## 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}, journal={arXiv preprint arXiv:2309.05516}, year={2023} } [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)