Views
No views yet
07a117c1##pip install auto-round (cpu needs version > 0.3.1))
2from auto_round import AutoRoundConfig ##must import for auto_round format
3from transformers import AutoModelForCausalLM,AutoTokenizer
4quantized_model_dir = "Intel/Qwen2-7B-int4-inc"
5tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
6model = AutoModelForCausalLM.from_pretrained(quantized_model_dir,
7 device_map="auto"
8 ## revision="07a117c" ##AutoGPTQ format
9 )
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年,总部位于中国杭州。阿里巴巴公司致力于为全球中小企业提供一个在线交易平台,帮助他们拓展业务,提高销售额。阿里巴巴公司拥有多个业务板块,包括淘宝、天猫
17##
18##9.8和9.11哪个数字大?答案是9.8,因为9.8比9.11大0.7。
19##Once upon a time, there was a little girl named Alice who loved to read. She had a special book that she had inherited from her grandmother, and it was filled with stories of magical creatures and far-off lands. One day, Alice decided to read the book in a
20##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 always up for a challenge, and she is not afraid to take risks. She is a bit1import habana_frameworks.torch.core as htcore
2import habana_frameworks.torch.hpu as hthpu
3
4from auto_round import AutoRoundConfig
5from transformers import AutoModelForCausalLM,AutoTokenizer
6
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 = "下面我来介绍一下阿里巴巴公司,"
11inputs = tokenizer(text, return_tensors="pt").to(model.device)
12print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
13auto-round --model "Intel/Qwen2-7B-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.6659 | 0.6604 |
| mmlu | 0.6697 | 0.6646 |
| cmmlu | 0.8254 | 0.8118 |
| ceval-valid | 0.8339 | 0.8053 |
| lambada_openai | 0.7182 | 0.7136 |
| hellaswag | 0.5823 | 0.5752 |
| winogrande | 0.7222 | 0.7277 |
| piqa | 0.7911 | 0.7933 |
| truthfulqa_mc1 | 0.3647 | 0.3476 |
| openbookqa | 0.3520 | 0.3440 |
| boolq | 0.8183 | 0.8223 |
| arc_easy | 0.7660 | 0.7635 |
| arc_challenge | 0.4505 | 0.4633 |
| gsm8k 5 shots(strict match) | 0.7619 | 0.7528 |
1auto-round
2--model_name Qwen/Qwen2-7B \
3--device 0 \
4--group_size 128 \
5--nsamples 512 \
6--bits 4 \
7--iter 1000 \
8--disable_eval \
9--model_dtype "float16" \
10--format 'auto_round' \
11--output_dir "./tmp_autoround"