Views
No views yet
1##git clone https://github.com/intel/auto-round.git
2##cd auto-round && pip install -vvv --no-build-isolation -e .
3from auto_round.auto_quantizer import AutoHfQuantizer
4from transformers import AutoModelForCausalLM,AutoTokenizer
5quantized_model_dir = "OPEA/Qwen2-7B-int4-inc"
6tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
7model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, device_map="auto")
8text = "下面我来介绍一下阿里巴巴公司,"
9text = "88+99等于多少?"
10text = "Once upon a time,"
11text = "There is a girl who likes adventure,"
12inputs = tokenizer(text, return_tensors="pt").to(model.device)
13print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
14##下面我来介绍一下阿里巴巴公司,阿里巴巴公司是1999年9月8日由马云在杭州创立的,阿里巴巴集团主要经营业务包括:淘宝网、天猫、聚划算、全球速卖通、阿里巴巴国际交易市场、1688、阿里
15##"88+99等于多少? 88+99=187 \n 计算: (1) 1 2 + 1 3 + 1 4 + 1 5 + 1 6 + 1 7 + 1 8"
16##Once upon a time, there was a little girl named Emily who loved to read books. She would spend hours lost in the pages of her favorite stories, imagining herself in the worlds she read about. One day, Emily stumbled upon a book called "The Enchanted Forest
17##There is a girl who likes adventure, and she is always looking for new experiences. She is a bit of a thrill-seeker, and she loves to push herself to the limit. She is also a bit of a free spirit, and she loves to explore new places and try new things1import habana_frameworks.torch.core as htcore
2import habana_frameworks.torch.hpu as hthpu
3
4from auto_round.auto_quantizer import AutoHfQuantizer
5
6from transformers import AutoModelForCausalLM,AutoTokenizer
7quantized_model_dir = "Intel/Qwen2-7B-int4-inc"
8tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
9model = AutoModelForCausalLM.from_pretrained(quantized_model_dir).to('hpu').to(bfloat16)
10text = "下面我来介绍一下阿里巴巴公司,"
11text = "9.8和9.11哪个大?"
12text = "Once upon a time,"
13text = "There is a girl who likes adventure,"
14inputs = tokenizer(text, return_tensors="pt").to(model.device)
15print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
16##下面我来介绍一下阿里巴巴公司,阿里巴巴公司是1999年9月8日由马云在杭州创立的,阿里巴巴集团主要经营业务包括:淘宝网、天猫、聚划算、全球速卖通、阿里巴巴国际交易市场、1688、阿里
17##9.8和9.11哪个大? 9.8和9.11哪个大? 解:9.8>9.11; 答:9.8大. 阅读下面的文字,完成下列各题。 ①“中国式现代化”是习近平
18##Once upon a time, there was a little girl named Emily who loved to read books. She would spend hours lost in the pages of her favorite stories, imagining herself in the worlds she read about. One day, Emily stumbled upon a book called "The Enchanted Forest
19##There is a girl who likes adventure, and she is always looking for new experiences. She is a bit of a thrill-seeker, and she loves to push herself to the limit. She is also a bit of a free spirit, and she loves to explore new places and try new things1git clone https://github.com/intel/auto-round
2cd auto-round/examples/language-modeling
3python3 eval_042/evluation.py --model_name "OPEA/Qwen2-7B-int4-inc" --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.6655 | 0.6624 |
| mmlu | 0.6706 | 0.6650 |
| cmmlu | 0.8310 | 0.8151 |
| ceval-valid | 0.8232 | 0.8053 |
| lambada_openai | 0.7182 | 0.7254 |
| hellaswag | 0.5823 | 0.5758 |
| winogrande | 0.7222 | 0.7174 |
| piqa | 0.7911 | 0.7905 |
| truthfulqa_mc1 | 0.3647 | 0.3599 |
| openbookqa | 0.3520 | 0.3420 |
| boolq | 0.8183 | 0.8168 |
| arc_easy | 0.7660 | 0.7643 |
| arc_challenge | 0.4505 | 0.4625 |
| gsm8k 5 shots | 0.7619 | 0.7710 |
1git clone https://github.com/intel/auto-round
2cd auto-round/examples/language-modeling
3pip install -r requirements.txt
4python3 main.py \
5--model_name Qwen/Qwen2-7B \
6--device 0 \
7--group_size 128 \
8--nsamples 512 \
9--bits 4 \
10--iter 1000 \
11--disable_eval \
12--model_dtype "float16" \
13--deployment_device 'auto_round' \
14--output_dir "./tmp_autoround"