Edit model card

Model Details

This model is an int4 model with group_size 128 of microsoft/phi-2 generated by intel/auto-round.

How To Use

Use the model

INT4 Inference with AutoGPTQ

Install AutoGPTQ from source first

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 from source, and the git id f3b7917091afba325af3980a35d8a6dcba03dc3f is used

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.6155 0.6163
mmlu 0.5448 0.5417
lambada_openai 0.6268 0.6225
hellaswag 0.5585 0.5498
winogrande 0.7530 0.7545
piqa 0.7867 0.7824
truthfulqa_mc1 0.3133 0.3060
openbookqa 0.4000 0.4100
boolq 0.8339 0.8327
rte 0.6245 0.6643
arc_easy 0.7997 0.7955
arc_challenge 0.5290 0.5196

Reproduce the model

Here is the sample command to reproduce the model

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
  • Intel Extension for Transformers link

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 github

Downloads last month
26
Safetensors
Model size
600M params
Tensor type
I32
·
FP16
·

Dataset used to train Intel/phi-2-int4-inc