Edit model card

Model Details

This model is an int4 model with group_size 128 of Qwen/Qwen2.5-32B-Instruct generated by intel/auto-round, auto-round is needed to run this model

How To Use

INT4 Inference

##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 = "Intel/Qwen2.5-32B-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 sounds exciting! What would you like to know or do regarding this girl who loves adventure? Perhaps you're looking for ideas on activities she might enjoy or ways to support her adventurous spirit. Let me know how I can assist you further!That sounds exciting! What kind of adventures does she enjoy? Is there something specific you'd like to plan or discuss related to her love for adventure?

##prompt = "Which one is bigger, 9.11 or 9.8"
##To compare the two numbers, 9.11 and 9.8, you can look at their decimal places:
##- 9.11 has a tenths place of 1.
##- 9.8 can be written as


##prompt = "Once upon a time,"
##Once upon a time, in a land far, far away, there was a small village nestled between rolling hills and dense forests. The villagers lived simple lives, farming the land and tending to their livestock. They were a close-knit community,

##prompt = "请介绍一下阿里巴巴公司"
##阿里巴巴集团(Alibaba Group)是一家总部位于中国杭州的全球领先的电子商务和科技公司。它成立于1999年,由马云等18位创始人共同创立。阿里巴巴最初以B2B在线市场起家,后来

Evaluate the model

pip3 install lm-eval==0.4.4

git clone https://github.com/intel/auto-round
cd auto-round
python -m auto_round --model "Intel/Qwen2.5-32B-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
Avg 0.7258 0.7273
mmlu 0.8166 0.8064
cmmlu 0.8672 0.8600
ceval-valid 0.8796 0.8744
lambada_openai 0.7512 0.7561
hellaswag 0.6679 0.6662
winogrande 0.7372 0.7459
piqa 0.8079 0.8079
truthfulqa_mc1 0.4871 0.4859
openbookqa 0.3640 0.3420
boolq 0.8951 0.8966
arc_easy 0.8224 0.8291
arc_challenge 0.5776 0.5845
gsm8k 5 shots 0.7612 0.7998

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.

git clone https://github.com/intel/auto-round
cd auto-round
python -m auto_round \
--model_name  Qwen/Qwen2.5-32B-Instruct \
--device 0 \
--group_size 128 \
--nsamples 512 \
--bits 4 \
--iter 1000 \
--disable_eval \
--model_dtype "float16" \
--deployment_device '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
  • 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 and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }

arxiv github

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model's library. Check the docs .

Dataset used to train Intel/Qwen2.5-32B-Instruct-int4-inc